Skip to content

Commit a2c618e

Browse files
committed
Build with tsdown instead of tsup
tsup is no longer maintained (its README now points at tsdown). tsdown is the rolldown-based successor from the same lineage. - migrate all 25 build configs; published files now use explicit .mjs/.cjs extensions, which is what rolldown emits and removes the ambiguity that made module-format detection guess wrong - code splitting cannot be disabled in tsdown, so the self-contained CJS bundles (varlock init-server/init-edge) each get their own build. A shared chunk in those would emit a require() that cannot resolve where they get injected into webpack/turbopack runtimes - rolldown otherwise rewrites bare `require` into a shim calling createRequire(import.meta.url) at module scope. That is undefined in workerd, and it defeats the `typeof require === 'function'` guards that keep runtime/crypto.ts evaluable in edge runtimes, so polyfillRequire is off - @env-spec/utils now emits declarations, which lets tsdown inline its types. varlock's published d.ts has been shipping a broken import of @env-spec/utils/type-utils, hidden only by skipLibCheck - drop keepNames: it was an esbuild-era workaround, and with tsdown it leaked a runtime-chunk import into the parser's declaration files. Class names survive without it since these builds never minify - port keepass's esbuild resolver plugin to a rolldown resolveId hook - infisical patched its bundle by string-replacing 'use strict', which tsdown does not emit. Use a real banner instead - the extension change breaks extensionless runtime resolution, so the nextjs webpack loader and the astro injected route are now explicit - drop two entries that pointed at files which no longer exist; tsup ignored them silently, tsdown errors Also enable publint and attw on every publishable package's build. Both fail the build on real errors, so exports and type-resolution problems surface at build time instead of after publish. attw profile is per package: esm-only where we only ship esm (the node10 algorithm and require() from a cjs consumer are both out of scope), node16 for the genuinely dual and cjs-only packages. Fixing what they found: - repository.url everywhere is a full git+https URL - @varlock/nextjs-integration declares "type": "commonjs" rather than making node sniff it, which is accurate: it is cjs-only to match @next/env. Its tsdown config moves to .mts, since node otherwise loads the .ts config as CJS and tsdown is ESM-only - @env-spec/parser declares "type": "module". Its published output is all explicit .mjs/.cjs so the field governs nothing there, but src/grammar.js is generated by peggy with format: 'es', and that is the one bare .js the field does govern - keepass now emits declarations like every other plugin. dts was off there under tsup; it works fine now, and attw flagged the package as untyped - varlock/test-helpers is internal, so it keeps only the `ts-src` condition and is excluded from attw. Vitest resolves dependencies through the ssr pipeline, which does not inherit resolve.conditions, so the plugin vitest configs now set ssr.resolve.conditions too Review follow-ups (pullfrog on #1021), all the same class of bug: strings in source that resolve against built output, which nothing typechecks. - the turbopack symlink fallback still aliased four .js runtime files. That branch only runs when varlock is symlinked, so the framework tests (which install from packed tarballs) never execute it - .github/workflows/deploy-tests.yaml invoked dist/cli/cli-executable.js - .github/workflows/bundle-size-check.yaml filtered on the removed tsup.config.ts, so a change to the active build config would have silently skipped the size check Add a test pinning that invariant for the nextjs integration: every hardcoded dist path and every relative require.resolve must name a file the build actually emits, with an explicit extension. Also drop two tsup-era workarounds that tsdown makes unnecessary, and update comments that still named tsup.config.ts: - the `typeof execSync` type workaround for egoist/tsup#1367 - the vite integration force-externalized `crypto` for SSR because esbuild stripped the node: prefix, leaving varlock's dist importing bare 'crypto'. rolldown preserves the prefix (dist has no bare node builtins at all), and vite auto-externalizes node:-prefixed specifiers
1 parent 1277ae4 commit a2c618e

105 files changed

Lines changed: 942 additions & 673 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.bumpy/migrate-to-tsdown.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
"@env-spec/parser": patch
3+
varlock: patch
4+
env-spec-language: patch
5+
"@varlock/ci-env-info": patch
6+
"@varlock/cloudflare-integration": patch
7+
"@varlock/expo-integration": patch
8+
"@varlock/vite-integration": patch
9+
"@varlock/nextjs-integration": patch
10+
"@varlock/astro-integration": patch
11+
"@varlock/azure-key-vault-plugin": patch
12+
"@varlock/hashicorp-vault-plugin": patch
13+
"@varlock/pass-plugin": patch
14+
"@varlock/dashlane-plugin": patch
15+
"@varlock/aws-secrets-plugin": patch
16+
"@varlock/doppler-plugin": patch
17+
"@varlock/keepass-plugin": patch
18+
"@varlock/passbolt-plugin": patch
19+
"@varlock/infisical-plugin": patch
20+
"@varlock/akeyless-plugin": patch
21+
"@varlock/bitwarden-plugin": patch
22+
"@varlock/google-secret-manager-plugin": patch
23+
"@varlock/proton-pass-plugin": patch
24+
"@varlock/keeper-plugin": patch
25+
"@varlock/kubernetes-plugin": patch
26+
"@varlock/1password-plugin": patch
27+
---
28+
29+
Build with tsdown instead of tsup; published files now use explicit .mjs/.cjs extensions.

.github/workflows/bundle-size-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ on:
2424
paths:
2525
- 'packages/varlock/src/**'
2626
- 'packages/varlock/package.json'
27-
- 'packages/varlock/tsup.config.ts'
27+
- 'packages/varlock/tsdown.config.ts'
2828
- 'packages/varlock/tsconfig*.json'
2929
- 'scripts/report-bundle-size.ts'
3030
- '.github/workflows/bundle-size-check.yaml'

.github/workflows/deploy-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
# via deploy/.env.schema and injects them into the test process
6565
run: |
6666
cd framework-tests && bun install
67-
node ../packages/varlock/dist/cli/cli-executable.js run --path ./deploy -- bun run test -- --reporter=verbose deploy/
67+
node ../packages/varlock/dist/cli/cli-executable.mjs run --path ./deploy -- bun run test -- --reporter=verbose deploy/
6868
timeout-minutes: 25
6969
env:
7070
OP_CI_TOKEN: ${{ secrets.OP_CI_TOKEN }}

bun.lock

Lines changed: 189 additions & 132 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"packages:sync": "bunx fledgling sync"
3838
},
3939
"devDependencies": {
40+
"@arethetypeswrong/core": "^0.18.5",
4041
"@cloudflare/vite-plugin": "^1.37.1",
4142
"@eslint/js": "^10.0.1",
4243
"@socketsecurity/bun-security-scanner": "^1.1.2",
@@ -54,7 +55,8 @@
5455
"eslint-stylistic-airbnb": "^2.0.1",
5556
"globals": "^17.3.0",
5657
"lefthook": "^2.1.6",
57-
"tsdown": "^0.22.1",
58+
"publint": "^0.3.24",
59+
"tsdown": "catalog:",
5860
"turbo": "^2.9.14",
5961
"typescript": "catalog:",
6062
"typescript-eslint": "^8.56.1",
@@ -85,7 +87,7 @@
8587
"ky": "^1.14.3",
8688
"msw": "^2.12.14",
8789
"outdent": "^0.8.0",
88-
"tsup": "^8.5.1",
90+
"tsdown": "^0.22.14",
8991
"typescript": "^5.9.3",
9092
"vite": "^7.3.1",
9193
"vitest": "^4.0.18"

packages/ci-env-info/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
"type": "module",
66
"repository": {
77
"type": "git",
8-
"url": "https://github.com/dmno-dev/varlock.git",
8+
"url": "git+https://github.com/dmno-dev/varlock.git",
99
"directory": "packages/ci-env-info"
1010
},
11-
"main": "dist/index.js",
12-
"types": "dist/index.d.ts",
11+
"main": "dist/index.mjs",
12+
"types": "dist/index.d.mts",
1313
"exports": {
1414
".": {
1515
"ts-src": "./src/index.ts",
16-
"types": "./dist/index.d.ts",
17-
"import": "./dist/index.js",
18-
"default": "./dist/index.js"
16+
"types": "./dist/index.d.mts",
17+
"import": "./dist/index.mjs",
18+
"default": "./dist/index.mjs"
1919
}
2020
},
2121
"files": ["dist"],
2222
"scripts": {
23-
"build": "tsup",
24-
"dev": "tsup --watch",
23+
"build": "tsdown",
24+
"dev": "tsdown --watch",
2525
"test": "vitest",
2626
"test:ci": "vitest --run",
2727
"typecheck": "tsc --noEmit"
@@ -42,7 +42,7 @@
4242
},
4343
"devDependencies": {
4444
"@types/node": "catalog:",
45-
"tsup": "catalog:",
45+
"tsdown": "catalog:",
4646
"typescript": "catalog:",
4747
"vitest": "catalog:"
4848
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from 'tsup';
1+
import { defineConfig } from 'tsdown';
22

33
export default defineConfig({
44
entry: ['src/index.ts'],
@@ -7,7 +7,9 @@ export default defineConfig({
77
treeshake: true,
88
clean: true,
99
outDir: 'dist',
10+
attw: { level: 'error', profile: 'esm-only' },
11+
publint: true,
1012
format: ['esm'],
11-
splitting: false,
13+
platform: 'node',
1214
target: 'esnext',
1315
});

packages/env-spec-parser/package.json

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,38 @@
11
{
22
"name": "@env-spec/parser",
33
"version": "0.5.0",
4+
"type": "module",
45
"description": "Parser for @env-spec enabled dotenv files",
56
"homepage": "https://varlock.dev",
67
"bugs": "https://github.com/dmno-dev/varlock/issues",
78
"repository": {
89
"type": "git",
9-
"url": "https://github.com/dmno-dev/varlock.git",
10+
"url": "git+https://github.com/dmno-dev/varlock.git",
1011
"directory": "packages/env-spec-parser"
1112
},
12-
"main": "dist/index.js",
13-
"types": "dist/index.d.ts",
13+
"main": "dist/index.cjs",
14+
"types": "dist/index.d.cts",
1415
"files": ["dist"],
1516
"exports": {
1617
".": {
1718
"ts-src": "./src/index.ts",
18-
"types": "./dist/index.d.ts",
19-
"import": "./dist/index.mjs",
20-
"require": "./dist/index.js"
19+
"import": {
20+
"types": "./dist/index.d.mts",
21+
"default": "./dist/index.mjs"
22+
},
23+
"require": {
24+
"types": "./dist/index.d.cts",
25+
"default": "./dist/index.cjs"
26+
}
2127
}
2228
},
2329
"scripts": {
2430
"dev": "bun run --parallel dev:grammar dev:ts",
2531
"dev:grammar": "bun run build:grammar:watch",
26-
"dev:ts": "tsup --watch",
32+
"dev:ts": "tsdown --watch",
2733
"build:grammar": "peggy -c peggy.config.cjs",
2834
"build:grammar:watch": "peggy -c peggy.config.cjs -w",
29-
"build:lib": "tsup",
35+
"build:lib": "tsdown",
3036
"build": "bun run build:grammar && bun run build:lib",
3137
"test": "bun run --parallel build:grammar:watch _test:watch",
3238
"_test:watch": "vitest",
@@ -53,7 +59,7 @@
5359
"ansis": "catalog:",
5460
"outdent": "catalog:",
5561
"peggy": "^5.0.6",
56-
"tsup": "catalog:",
62+
"tsdown": "catalog:",
5763
"vitest": "catalog:"
5864
}
5965
}

packages/env-spec-parser/scripts/dotenv-comparison.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
// we dont need everything to match 100% - but good to know what differences are
88

99
import util from 'node:util';
10-
import { parseEnvSpecDotEnvFile } from '../dist/index.js';
11-
import { simpleResolver } from '../dist/simple-resolver.js';
10+
import { parseEnvSpecDotEnvFile } from '../dist/index.mjs';
11+
import { simpleResolver } from '../dist/simple-resolver.mjs';
1212
const COMPARISON_SCENARIOS = {
1313
scenarios: [
1414
{

packages/env-spec-parser/scripts/playground.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// helpful script for testing the parser - loads .env.playground file
44
import {
55
expand, parseEnvSpecDotEnvFile,
6-
} from '../dist/index.js';
7-
import { simpleResolver } from '../dist/simple-resolver.js';
6+
} from '../dist/index.mjs';
7+
import { simpleResolver } from '../dist/simple-resolver.mjs';
88
import fs from 'node:fs/promises';
99
import path from 'node:path';
1010
import { fileURLToPath } from 'node:url';

0 commit comments

Comments
 (0)