Skip to content

Commit

Permalink
build: improve tsup config for turbo (#3293)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic authored Oct 16, 2024
1 parent 84ae33b commit 8b2fda7
Show file tree
Hide file tree
Showing 25 changed files with 218 additions and 95 deletions.
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",
Expand All @@ -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",
"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'",
Expand Down
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
Expand Up @@ -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",
Expand All @@ -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
Expand Up @@ -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",
Expand All @@ -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,
}));
Loading

0 comments on commit 8b2fda7

Please sign in to comment.