core icon indicating copy to clipboard operation
core copied to clipboard

Warning (node:11836) [MODULE_TYPELESS_PACKAGE_JSON] when using @module-federation/rsbuild-plugin

Open vincesp opened this issue 11 months ago • 13 comments

Describe the bug

Clone the linked repo.

npm i

Then run

npm run build -w mf-remote-rsbuild

This will yield:

(node:43128) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///C:/Users/me/git/stackblitz-starters-h6gf2a5j/node_modules/@module-federation/rsbuild-plugin/dist/index.esm.js 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 C:\Users\me\git\stackblitz-starters-h6gf2a5j\node_modules@module-federation\rsbuild-plugin\package.json.

Reproduction

https://github.com/vincesp/stackblitz-starters-h6gf2a5j

Used Package Manager

npm

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 Intel(R) Xeon(R) W-11955M CPU @ 2.60GHz
    Memory: 8.41 GB / 31.73 GB
  Binaries:
    Node: 22.9.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 10.3.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.15.4 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (130.0.2849.68)

Validations

vincesp avatar Feb 28 '25 13:02 vincesp

the package is supposed to be typeless, will see if anything can be done about it - its a limitation of the package build system that makes emitting the right file extensions hard

ScriptedAlchemy avatar Mar 11 '25 17:03 ScriptedAlchemy

Stale issue message

github-actions[bot] avatar May 11 '25 15:05 github-actions[bot]

Not stale

vincesp avatar May 11 '25 16:05 vincesp

add this "type": "module" in your package.json

Ahmat-2000 avatar Jun 12 '25 09:06 Ahmat-2000

add this "type": "module" in your package.json

It is deliberately typeless.

ScriptedAlchemy avatar Jun 12 '25 10:06 ScriptedAlchemy

Stale issue message

github-actions[bot] avatar Aug 11 '25 15:08 github-actions[bot]

What do you mean by "typeless"? If not specified, the default is "commonjs", see https://nodejs.org/api/packages.html#type

vincesp avatar Aug 12 '25 20:08 vincesp

Specify commonjs will cause other issues in esm. Specify esm will cause other issue in cjs. Leaving it typeless mean it depends how you import it which will determine the type it resolves to. Bundler will use cjs and lose good tree shake if I set commonjs.

People file issues if I set it as cjs. People file issues if I set it as module. Nobody file issue when its typeless.

ScriptedAlchemy avatar Aug 19 '25 10:08 ScriptedAlchemy

I guess this very issue is a specimen of the ones that are being filed when it is typeless?

vincesp avatar Aug 24 '25 09:08 vincesp

You're the first :P

ScriptedAlchemy avatar Sep 12 '25 15:09 ScriptedAlchemy

Stale issue message

github-actions[bot] avatar Nov 12 '25 15:11 github-actions[bot]

Are there any news?

vincesp avatar Nov 12 '25 18:11 vincesp