Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: improve tsup config for turbo #3293

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "mud-monorepo",
"private": true,
"repository": {
"type": "git",
@@ -12,7 +13,7 @@
"build": "turbo run build --concurrency=100%",
"changelog:generate": "tsx scripts/changelog.ts",
"clean": "turbo run clean --concurrency=100%",
"dev": "TSUP_SKIP_DTS=true turbo run dev --concurrency=100% --filter !@latticexyz/explorer",
"dev": "turbo run dev --concurrency=999",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dev task uses persistent: true to mark it as a long running task (which helps warn when other tasks depend on a thing that will never complete)

thus, we need to manually specify concurrency > number of persistent tasks

"dist-tag-rm": "pnpm recursive exec -- sh -c 'npm dist-tag rm $(cat package.json | jq -r \".name\") $TAG || true'",
"docs:generate:api": "tsx scripts/render-api-docs.ts",
"fix:package-json": "sort-package-json package.json 'packages/*/package.json' 'templates/*/package.json' 'templates/*/packages/*/package.json' 'examples/*/package.json' 'examples/*/packages/*/package.json' 'e2e/*/package.json' 'e2e/*/packages/*/package.json' 'docs/package.json' 'test/*/package.json'",
13 changes: 9 additions & 4 deletions packages/abi-ts/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: ["src/index.ts", "src/abi-ts.ts"],
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/block-logs-stream/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: ["src/index.ts"],
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/cli/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -17,15 +17,20 @@ const mudPackages: MudPackages = Object.fromEntries(
.map(([localPath, packageJson]) => [packageJson.name, { localPath }]),
);

export default defineConfig({
export default defineConfig((opts) => ({
entry: ["src/index.ts", "src/mud.ts"],
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
env: {
MUD_PACKAGES: JSON.stringify(mudPackages),
},
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/common/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: {
index: "src/index.ts",
actions: "src/actions/index.ts",
@@ -14,8 +14,13 @@ export default defineConfig({
},
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/config/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: {
index: "src/exports/index.ts",
internal: "src/exports/internal.ts",
"deprecated/node": "src/deprecated/node/index.ts",
},
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
11 changes: 9 additions & 2 deletions packages/create-mud/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: ["src/cli.ts"],
minify: true,
sourcemap: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/dev-tools/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -12,17 +12,22 @@ import packageJson from "./package.json";
const peerDeps = Object.keys(packageJson.peerDependencies);
const bundledDeps = Object.keys(packageJson.dependencies).filter((dep) => !peerDeps.includes(dep));

export default defineConfig({
export default defineConfig((opts) => ({
entry: ["src/index.ts"],
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
injectStyle: true,
// bundle all non-peer deps
noExternal: bundledDeps,
// don't code split otherwise dep imports in bundle seem to break
splitting: false,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/explorer/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
tsconfig: "tsconfig.tsup.json",
entry: ["src/bin/explorer.ts", "src/exports/observer.ts"],
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: false,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/faucet/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: ["src/index.ts", "bin/faucet-server.ts"],
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/gas-report/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: ["ts/index.ts", "ts/gas-report.ts"],
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/protocol-parser/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: {
index: "src/exports/index.ts",
internal: "src/exports/internal.ts",
},
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/react/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: ["src/index.ts"],
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/recs/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: ["src/index.ts", "src/deprecated/index.ts"],
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/schema-type/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: {
index: "src/typescript/exports/index.ts",
internal: "src/typescript/exports/internal.ts",
@@ -9,9 +9,14 @@ export default defineConfig({
outDir: "dist",
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
injectStyle: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/solhint-config-mud/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: ["src/index.ts"],
target: "esnext",
format: ["cjs"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/solhint-plugin-mud/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: ["src/index.ts"],
target: "esnext",
format: ["cjs"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/stash/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: {
index: "src/exports/index.ts",
internal: "src/exports/internal.ts",
},
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/store-indexer/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: [
"src/index.ts",
"bin/postgres-frontend.ts",
@@ -10,8 +10,13 @@ export default defineConfig({
],
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/store-sync/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: [
"src/index.ts",
"src/sqlite/index.ts",
@@ -14,8 +14,13 @@ export default defineConfig({
],
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/store/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: {
"mud.config": "mud.config.ts",
index: "ts/exports/index.ts",
@@ -10,8 +10,13 @@ export default defineConfig({
},
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/utils/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: ["src/index.ts"],
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/world-module-metadata/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: {
"mud.config": "mud.config.ts",
},
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/world-modules/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: {
"mud.config": "mud.config.ts",
},
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
13 changes: 9 additions & 4 deletions packages/world/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "tsup";

export default defineConfig({
export default defineConfig((opts) => ({
entry: {
"mud.config": "mud.config.ts",
index: "ts/exports/index.ts",
@@ -10,8 +10,13 @@ export default defineConfig({
},
target: "esnext",
format: ["esm"],
dts: !process.env.TSUP_SKIP_DTS,
sourcemap: true,
clean: true,
minify: true,
});
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));