Repository navigation
fix: ncc build typescript 7 - #64
Merged
Merged
Conversation
The TypeScript 7.0.2 bump (#60) broke `pnpm build`, so the Release workflow's Rebuild dist job has failed on every push since, and release-please (which needs it) hasn't run. ncc 0.45, the latest release, compiles through TypeScript's JS compiler API (ts.sys), which TypeScript 7, the native Go port, does not ship: TypeError: Cannot read properties of undefined (reading 'fileExists') at findConfigFile (.../@vercel/ncc/dist/ncc/loaders/ts-loader.js...) Back to 5.9.3, the version before the bump. Dependabot now ignores typescript >= 7 so it doesn't reopen the bump. Drop the ignore once ncc supports TypeScript 7.
With TypeScript back on 5.9, ncc builds and exits 0, but dist/index.js shrinks from 1.7 MB to 36 kB and fails on its first line: Error: Cannot find module '@actions/core' @actions/core 3 (#58) and @actions/github 9 (#59) are ESM-only: their `exports` have just an `import` condition. With "module": "commonjs", TypeScript turns our imports into require() calls, webpack resolves those with the `require` condition, finds nothing, and ncc bundles a stub that throws at runtime rather than failing the build. Emit ES modules ("module": "esnext") and resolve the way a bundler does ("moduleResolution": "bundler"), so webpack follows the `import` condition. ncc still writes a CommonJS dist/index.js, so __dirname (readWrapperVersion) still works. "lib" goes to es2022 for the ErrorOptions type that @octokit/request-error now uses. That only affects type checking, and node24 runs ES2022 natively. Checked by running the old and new bundles with fake npx/npm on PATH. Both build the same `dcd cloud` command from the same inputs and PR event, report wrapper version 2.6.0, and write the same four GITHUB_OUTPUT values. The new bundle requires the same Node builtins as the old one. tsc --noEmit is now clean; under node10 resolution it could not find @octokit/core/types.
CI only ran the unit tests, and that is all dependabot PRs get, so the TypeScript 7 and @actions ESM bumps merged green and only failed in the Release workflow after they landed on main. Run `pnpm build` in CI. The build alone is not enough: ncc exits 0 when it can't resolve an import, bundling a stub that throws "Cannot find module" when the action runs. Fail when dist/index.js contains one (webpackMissingModule) and list the modules it could not find.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.