-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ESM exports #491
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are many errors to fix in all
react-component
modules for them to work well when imported from an ESM module.Importing things from
"rc-???"
& types from"rc-???/es/..."
from an ESM module with recommended (less fault-tolerant / strictest) TS config should not raise any error.My
tsconfig.json
contains:Origin of errors:
"rc-???/es/..."
must have.d.mts
or.mjs
extension, or apackage.json
containing{"type":"module"}
must be added to the folder"rc-???/es/..."
do not import any file from CJS exports of a module, there should not have anyimport ... from 'rc-???/lib/...';
=> import will fail if (and it would be a good thing) imported module restricts its/lib/
path to only CJS requires (exports
field inpackage.json
)"rc-???/es/..."
any relative import (specifier or expression) in a.d.ts
or.js
should point to a file (not a directory) and have a file extension => TS error since modules are resolved asany
/*#__PURE__*/
comment and the function call, cfrc-field-form/es/utils/validateUtil.js
=> esbuild error during buildreact
) should not be imported usingimport Module from 'module'
but instead withimport * as Module from 'module'
, cfrc-dialog/es/Dialog/Content/Panel.d.ts
orrc-picker/es/interface.d.ts
=> TS error withallowSyntheticDefaultImports
disabled and runtime error without a bundler that fakes a default importmain
field ofpackage.json
, even when module is imported from an ESM, sopackage.json
should be patched with:Interesting reading:
"module": "node16"
should support extension rewriting microsoft/TypeScript#49083 (comment)The text was updated successfully, but these errors were encountered: