-
Notifications
You must be signed in to change notification settings - Fork 35
Description
nodejs ignores the 'module' field of package.json and only supports the 'exports' field (which is much more vesatile) if your package is "type": "module"
Please add the exports field to allow nodejs to load the es5m build instead of the es5 build, otherwise e.g. TypeScript with allowSyntheticDefaultImports gets confused and creates 'default' imports from the es5 build instead.
import makeWebsocketObservable from 'rxjs-websocket';
console.log(makeWebsocketObservable);{
normalClosureMessage: 'Normal closure',
default: [Function: makeWebSocketObservable]
}
(should be [Function: makeWebsocketObservable])
see
https://github.com/nodejs/node/blob/v16.14.0/lib/internal/modules/esm/resolve.js#L911 where the nodejs module importer checks for the exports field in the packageConfig (package.json) and will call legacyMainResolve() if it doesn't exist (only checks the package.json main field)
https://github.com/nodejs/node/blob/v16.14.0/lib/internal/modules/esm/resolve.js#L299