You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add exports in to make /native work in Node 16.x ESM modules (#318)
If you're trying to import `react-content-loader/native` from Node 16.x
from within a ESM context (`"type": "module"`). You'll get the following
error:
```
node:internal/process/esm_loader:97
internalBinding('errors').triggerUncaughtException(
^
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '~/node_modules/react-content-loader/native' is not supported resolving ES modules imported from /Users/swen/Code/cheetah/test/test.mjs
Did you mean to import react-content-loader/native/react-content-loader.native.cjs.js?
at new NodeError (node:internal/errors:387:5)
at finalizeResolution (node:internal/modules/esm/resolve:425:17)
at moduleResolve (node:internal/modules/esm/resolve:1006:10)
at defaultResolve (node:internal/modules/esm/resolve:1214:11)
at nextResolve (node:internal/modules/esm/loader:165:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:844:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:431:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
at link (node:internal/modules/esm/module_job:75:36) {
code: 'ERR_UNSUPPORTED_DIR_IMPORT',
url: 'file:///~/node_modules/react-content-loader/native'
}
```
By setting up an explicit export for the `/native` subdirectory
the import works. No other changes are made to maintain backwards
compatibility.
0 commit comments