-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
chore: upgrade to TypeScript 7 #4318
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
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0ee472f
chore: upgrade to TypeScript 7
carderne 48eb7e1
fix redis-worker
carderne 38ee98e
fix redis esm build
carderne 3961e30
fix(build): keep TypeScript compiler optional for consumers
carderne 3864c62
fix(redis-worker): omit dangling declaration map references
carderne 19b9b0c
fix(observability-map): use TypeScript 6 compatibility API
carderne be87bcb
Update .changeset/typescript-seven-builds.md
carderne b5bbc4a
fix(redis-worker): guard resilient require shim
carderne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| "trigger.dev": patch | ||
| "@trigger.dev/build": patch | ||
| "@trigger.dev/core": patch | ||
| "@trigger.dev/python": patch | ||
| "@trigger.dev/react-hooks": patch | ||
| "@trigger.dev/redis-worker": patch | ||
| "@trigger.dev/rsc": patch | ||
| "@trigger.dev/schema-to-json": patch | ||
| "@trigger.dev/sdk": patch | ||
| --- | ||
|
|
||
| Refresh package builds for TypeScript 7 compatibility while preserving existing runtime entry points. TypeScript remains an optional peer for the decorator metadata build extension, so installing the Trigger.dev CLI does not install an additional compiler. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
internal-packages/observability-map/src/docstringReferences.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
carderne marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/plugins/tsup.config.ts → packages/plugins/tsdown.config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { build } from "esbuild"; | ||
| import { mkdtempSync, readFileSync, rmSync } from "node:fs"; | ||
| import { tmpdir } from "node:os"; | ||
| import { join } from "node:path"; | ||
| import { createRequire } from "node:module"; | ||
| import { fileURLToPath } from "node:url"; | ||
| import { spawnSync } from "node:child_process"; | ||
| import { afterAll, expect, test } from "vitest"; | ||
|
|
||
| const packageDir = fileURLToPath(new URL("../", import.meta.url)); | ||
| const tempDir = mkdtempSync(join(tmpdir(), "redis-worker-build-output-")); | ||
|
|
||
| const require = createRequire(import.meta.url); | ||
|
|
||
| afterAll(() => { | ||
| rmSync(tempDir, { recursive: true, force: true }); | ||
| }); | ||
|
|
||
| test("the ESM output can be rebundled and loaded as CommonJS", async () => { | ||
| const buildResult = spawnSync("pnpm", ["exec", "tsdown"], { | ||
| cwd: packageDir, | ||
| encoding: "utf8", | ||
| }); | ||
| const buildOutput = [buildResult.stdout, buildResult.stderr].filter(Boolean).join("\n"); | ||
|
|
||
| expect(buildResult.error, buildOutput).toBeUndefined(); | ||
| expect(buildResult.status, buildOutput).toBe(0); | ||
|
|
||
| const esmPath = join(packageDir, "dist/index.js"); | ||
| const esmOutput = readFileSync(esmPath, "utf8"); | ||
| expect(esmOutput).not.toMatch(/\b[\w$]*createRequire[\w$]*\s*\(\s*import\.meta\.url\s*\)/); | ||
|
|
||
| const cjsPath = join(tempDir, "index.cjs"); | ||
| await build({ | ||
| entryPoints: [esmPath], | ||
| outfile: cjsPath, | ||
| bundle: true, | ||
| format: "cjs", | ||
| platform: "node", | ||
| logLevel: "silent", | ||
| }); | ||
|
|
||
| expect(() => require(cjsPath)).not.toThrow(); | ||
| }, 30_000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import { defineConfig } from "tsdown"; | ||
|
|
||
| export default defineConfig({ | ||
| entry: ["src/index.ts"], | ||
| format: ["cjs", "esm"], | ||
| fixedExtension: false, | ||
| tsconfig: "tsconfig.src.json", | ||
| dts: { | ||
| sourcemap: false, | ||
| }, | ||
| sourcemap: true, | ||
| // The CJS declarations are emitted in a separate pass, so their output can | ||
| // disable source maps without affecting the runtime bundle. | ||
| outputOptions(options, _format, { cjsDts }) { | ||
| if (!cjsDts) return; | ||
|
|
||
| return { | ||
| ...options, | ||
| sourcemap: false, | ||
| }; | ||
| }, | ||
|
carderne marked this conversation as resolved.
|
||
| clean: true, | ||
| treeshake: true, | ||
| minify: false, | ||
| deps: { | ||
| onlyBundle: false, | ||
| alwaysBundle: [ | ||
| // Always bundle internal packages | ||
| /^@internal/, | ||
| // Always bundle ESM-only packages | ||
| "nanoid", | ||
| "p-limit", | ||
| ], | ||
|
carderne marked this conversation as resolved.
|
||
| dts: { | ||
| // The TypeScript 7 declaration emitter consumes referenced package declarations. | ||
| neverBundle: [/^@internal/], | ||
| }, | ||
|
carderne marked this conversation as resolved.
carderne marked this conversation as resolved.
|
||
| }, | ||
| // rolldown injects its own `__require` helper in the ESM output as | ||
| // `createRequire(import.meta.url)` with no fallback. When this ESM bundle is | ||
| // re-bundled into a CJS consumer (e.g. the webapp server), esbuild replaces | ||
| // `import.meta.url` with `undefined`, so `createRequire(undefined)` throws at | ||
| // startup. Patch the helper to fall back to a valid path, matching the | ||
| // fallback the previous tsup banner provided. | ||
| plugins: [ | ||
| // The ESM declarations share an output pass with the runtime bundle. | ||
| // Remove their dangling map comment while retaining runtime source maps. | ||
| { | ||
| name: "strip-declaration-sourcemap-comments", | ||
| generateBundle(_options, bundle) { | ||
| for (const output of Object.values(bundle)) { | ||
| if (output.type !== "chunk" || !/\.d\.(?:c|m)?ts$/.test(output.fileName)) { | ||
| continue; | ||
| } | ||
|
|
||
| output.code = output.code.replace(/\n?\/\/# sourceMappingURL=.*$/m, ""); | ||
| } | ||
| }, | ||
| }, | ||
| { | ||
| name: "resilient-create-require", | ||
| renderChunk(code: string) { | ||
| const unsafeCreateRequire = /(\b[\w$]*createRequire[\w$]*\s*\()\s*import\.meta\.url\s*\)/g; | ||
| const patched = code.replace( | ||
| unsafeCreateRequire, | ||
| "$1import.meta.url || process.cwd() + '/index.js')" | ||
| ); | ||
|
|
||
| if (patched === code) return null; | ||
|
|
||
| return { | ||
| code: patched, | ||
| map: null, | ||
| }; | ||
| }, | ||
| generateBundle(_options, bundle) { | ||
| const unsafeCreateRequire = /\b[\w$]*createRequire[\w$]*\s*\(\s*import\.meta\.url\s*\)/; | ||
|
|
||
| for (const output of Object.values(bundle)) { | ||
| if (output.type === "chunk" && unsafeCreateRequire.test(output.code)) { | ||
| throw new Error(`Unsafe createRequire helper remained in ${output.fileName}`); | ||
| } | ||
| } | ||
| }, | ||
| }, | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
|
||
| ], | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.