-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Description
Which package?
intl-messageformat@10.4.0
Describe the bug
intl-messageformat@10.4.0 package imports resolve to lib/index.js. This is a .js file in a package that doesn’t specify "type": "module". This makes it CJS, but it contains ESM syntax.
To Reproduce
Reproducible Steps/Repo
Steps to reproduce the behavior:
- Install
intl-messageformat@10.4.0npm install intl-messageformat@10.4.0
- Create a script named
script.mjswith the following content:import 'intl-messageformat'
- Run it
node ./script.mjs
- See error
Expected behavior
Nothing
Screenshots
No screenshot, but a stack trace:
(node:47086) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
node_modules/intl-messageformat/lib/index.js:6
import { IntlMessageFormat } from './src/core';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1195:20)
at Module._compile (node:internal/modules/cjs/loader:1239:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
at Module.load (node:internal/modules/cjs/loader:1133:32)
at Module._load (node:internal/modules/cjs/loader:972:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:165:29)
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
Node.js v19.9.0
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Additional context
The ESM files should be actual ESM. Since everything in the lib directory is ESM, the simplest solution would be to write lib/package.json with the following content:
{
"type": "module"
}Alternatively the .mjs extension should be used, and the .mts extension for TypeScript files.
Type definitions need to match as well. To fix this, the "exports" → ".' → "types" field needs to be removed.
Also ESM requires to use file extensions in the import.
Reactions are currently unavailable