Replies: 3 comments 6 replies
-
Just to be clear, I really think this is effectively a bug, but since it had been working in the other environments which were in use at the time, I hesitated to file it as such. But one is indeed not able to use your package from native Node ESM without using |
Beta Was this translation helpful? Give feedback.
-
Since these packages don’t support real ESM, the CJS variant is used. Because the CJS uses a format that Node.js can’t consume using named imports, it can be used like this: import IntlMessageFormat from 'intl-messageformat'
const message = new IntlMessageFormat.IntlMessageFormat() However, the TypeScript types don’t match. I think this makes it a bug. The following steps would fix it:
|
Beta Was this translation helpful? Give feedback.
-
It sounds like you want to wait for more stability, but just FWIW, there is experimental support apparently against nightly TypeScript per https://www.typescriptlang.org/docs/handbook/esm-node.html#new-file-extensions |
Beta Was this translation helpful? Give feedback.
-
Currently in attempting a native Node ESM import, I am required to use
default
(since native Node doesn't know to look upmodule
, it will treat it as CommonJS, and look tomain
, and the main file defines it ondefault
).Ideally, the
package.json
for this project would havetype: 'module'
(and perhapsexports
in place of, or in addition to,module
). See https://nodejs.org/api/packages.html .Beta Was this translation helpful? Give feedback.
All reactions