Skip to content

Remove ts-node support - #937

Open
Elizabeth Craig (ecraig12345) wants to merge 4 commits into
mainfrom
no-ts-node
Open

Elizabeth Craig (ecraig12345) wants to merge 4 commits into
mainfrom
no-ts-node

Conversation

@ecraig12345

@ecraig12345 Elizabeth Craig (ecraig12345) commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

Replace ts-node support with native TypeScript and ES module loading in Node.js 22.18+.

  • Load Just and webpack configs with import(), supporting ESM and top-level await while preserving CommonJS compatibility and existing task export styles. Await asynchronous Just config initializers before registering exported tasks and parsing task options.
  • Support just.config.mjs and just.config.mts
  • Add a shared importModule() helper which provides file-URL conversion and better import errors.
  • Remove ts-node registration, dependencies, and related options. Keep permissive webpack peer ranges and document version-specific native config loading.
  • Convert example configs and scripts to .mts, document native TypeScript restrictions, and add a v3 migration guide.
  • Add native config-loading coverage, including real webpack builds.

Breaking changes

  • TypeScript configs and scripts must comply with Node's type-stripping restrictions. Node does not read tsconfig.json or perform type-checking when loading them.
  • Remove the --esm flag. Config module formats now follow Node's native rules; use .mts to explicitly select ESM or .cts for CommonJS.
  • Remove transpileOnly from webpackTask, and tsconfig and transpileOnly from webpackCliTask and webpackDevServerTask.
  • Remove enableTypeScript, tsconfig, and transpileOnly from nodeExecTask.

Caveats

This is potentially one of the more disruptive changes due to the feature limitations of type stripping. If it's not feasible to migrate, it might be possible to restore ts-node support as an optional mode.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

CommonJS configs exporting a then task can leave loading unresolved, allowing just build to exit successfully without running the requested task.

3 open issues
What changed in this PR

This PR replaces ts-node integration in Just’s task runner and preset tasks with native TypeScript and ES module loading on Node.js 22.18+.

Changes:

  • Load configs through import(), supporting .mjs/.mts, top-level await, and asynchronous initializers.
  • Remove ts-node dependencies and task options; require webpack-cli v7+.
  • Migrate examples, expand native-loading tests, and document v3 migration requirements.
File Description
yarn.lock Removes ts-node dependencies and updates workspace requirements.
packages/​just-task/​src/​index.ts Exports the shared import helper.
packages/​just-task/​src/​importModule.ts Adds file-URL imports with error logging.
packages/​just-task/​src/​enableTypeScript.ts Removes ts-node registration.
packages/​just-task/​src/​config.ts Loads configs asynchronously and discovers ESM extensions.
packages/​just-task/​src/​cli.ts Awaits config initialization before command handling.
packages/​just-task/​src/​__tests__/​resolve.spec.ts Tests additional config extensions.
packages/​just-task/​src/​__tests__/​importModule.spec.ts Tests module imports and error preservation.
packages/​just-task/​src/​__tests__/​cli.spec.ts Adds native config-loading integration coverage.
packages/​just-task/​package.json Removes ts-node dependencies.
packages/​just-task/​etc/​just-task.api.md Records the import helper’s public API.
packages/​just-scripts/​src/​typescript/​getTsNodeEnv.ts Removes ts-node environment helpers.
packages/​just-scripts/​src/​tasks/​webpackTask.ts Imports webpack configs natively.
packages/​just-scripts/​src/​tasks/​webpackDevServerTask.ts Removes ts-node options and environment setup.
packages/​just-scripts/​src/​tasks/​webpackCliTask.ts Delegates native config loading to webpack-cli.
packages/​just-scripts/​src/​tasks/​nodeExecTask.ts Runs scripts without ts-node registration.
packages/​just-scripts/​src/​tasks/​__tests__/​webpackTask.spec.ts Adds real builds using native config formats.
packages/​just-scripts/​src/​tasks/​__tests__/​webpackTask.mock.spec.ts Removes the obsolete TypeScript-enabling mock.
packages/​just-scripts/​src/​tasks/​__tests__/​webpackDevServerTask.mock.spec.ts Updates environment expectations for native loading.
packages/​just-scripts/​src/​tasks/​__tests__/​webpackCliTask.mock.spec.ts Verifies removal of ts-node environment injection.
packages/​just-scripts/​src/​tasks/​__tests__/​nodeExecTask.test.ts Updates script execution tests for native TypeScript.
packages/​just-scripts/​package.json Removes ts-node and raises the webpack-cli minimum.
packages/​just-scripts/​etc/​just-scripts.api.md Records removed task options.
packages/​just-example-lib/​webpack.config.mts Uses an ESM default export.
packages/​just-example-lib/​tsconfig.json Includes renamed .mts configs.
packages/​just-example-lib/​src/​customTask.ts Removes the previous TypeScript script.
packages/​just-example-lib/​src/​customTask.mts Adds its native ESM replacement.
packages/​just-example-lib/​package.json Removes the example’s ts-node dependency.
packages/​just-example-lib/​just.config.mts Adapts paths and script execution for ESM.
docs/​tasks/​index.md Documents native config loading and restrictions.
docs/​migration/​v3.md Expands the v3 migration guide.
docs/​.vuepress/​config.ts Links directly to the v3 migration page.
change/​change-e7f138ae-f57f-449a-8d01-5a5d497f301d.json Records breaking changes for both published packages.
.yarnrc.yml Removes ts-node from the dependency catalog.

Review effort: Balanced

Comment thread packages/just-task/src/importModule.ts Resolved
Comment thread packages/just-scripts/package.json Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The change breaks explicit JSON webpack config loading and can leave symlinked CommonJS initializer tasks unregistered when --preserve-symlinks is enabled.

5 open issues
3 resolved since last review

Review effort: Max

Comment thread packages/just-task/src/config.ts Resolved
Comment thread packages/just-task/src/importModule.ts Resolved
Updated comment to include new features and behavior changes.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants