Skip to content

fix(build): eliminate MODULE_TYPELESS_PACKAGE_JSON warning for mkshims - #933

Open
abdul-karim-mia wants to merge 1 commit into
nodejs:mainfrom
abdul-karim-mia:fix/mkshims-typeless-warning
Open

abdul-karim-mia wants to merge 1 commit into
nodejs:mainfrom
abdul-karim-mia:fix/mkshims-typeless-warning

Conversation

@abdul-karim-mia

Copy link
Copy Markdown

Fixes #930

Description

When running yarn build on modern Node.js versions, node ./mkshims.ts prints a [MODULE_TYPELESS_PACKAGE_JSON] warning:

(node:48042) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///.../corepack/mkshims.ts is not specified and it doesn't parse as CommonJS. Reparsing as ES module because module syntax was detected. This incurs a performance overhead. To eliminate this warning, add "type": "module" to /.../corepack/package.json.

Adding "type": "module" to root package.json would break the CommonJS shims in dist/ (which use require()).

This PR resolves the warning cleanly by:

  1. Renaming mkshims.ts to mkshims.mts so Node explicitly recognizes it as an ES module.
  2. Updating the "build" script in package.json to call ./mkshims.mts.
  3. Adding a minimal sources/package.json declaring {"type": "module"} so imported source files in sources/ (e.g. sources/Engine.ts) are evaluated as ESM without reparsing and without affecting root or dist/.

Verification

  • Ran yarn build: shims generated with 0 warnings.
  • Ran yarn typecheck: 0 errors.
  • Ran yarn lint: 0 errors.

Fixes nodejs#930

Since Node.js type-stripping was adopted, running mkshims during yarn build emitted a MODULE_TYPELESS_PACKAGE_JSON warning because module type was not specified in package.json and required reparsing. Renaming mkshims.ts to mkshims.mts and declaring type: module in sources/package.json eliminates the warning without impacting root CommonJS shims in dist.

Signed-off-by: Abdul karim mia <97598943+abdul-karim-mia@users.noreply.github.com>
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.

yarn build prints MODULE_TYPELESS_PACKAGE_JSON warning for mkshims.ts

1 participant