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
Not sure that it is the good place for this issue, but it's a global issue for all react-component modules and it's linked to the build.
If we agree that an ESM should always use ESM version of RC modules and that a CJS module should always use CJS version, then package.json of all RC modules should be improved with this patch:
It will fix an issue faced in some modules build to ESM and CJS (such as antd and all RC modules) since path of imports must be fixed (replacing /lib/ with /es/) during the build process (which is complex and not always done, an example here node_modules/antd/es/form/index.d.ts with import type { Rule, RuleObject, RuleRender } from 'rc-field-form/lib/interface';).
It would make babelPluginImportLib2Es of father-plugin useless since Node/TS/bundlers would automatically add the right es or lib prefix when importing/requiring a file of an other RC module from source or es or lib folder. Note that, for this to work, files in es folder should be considered as ESM (files should use .mjs extension or a package.json with "type": "module" should be added to es folder) which is not the case today (bug!). There is a pending PR to fix this bug in father: umijs/father#742
It should be possible to make this change in a backward-compatible manner with this alternative patch which will block access to es from a CJS module and lib from an ESM module:
Not sure that it is the good place for this issue, but it's a global issue for all react-component modules and it's linked to the build.
If we agree that an ESM should always use ESM version of RC modules and that a CJS module should always use CJS version, then package.json of all RC modules should be improved with this patch:
It will fix an issue faced in some modules build to ESM and CJS (such as
antd
and all RC modules) since path of imports must be fixed (replacing/lib/
with/es/
) during the build process (which is complex and not always done, an example herenode_modules/antd/es/form/index.d.ts
withimport type { Rule, RuleObject, RuleRender } from 'rc-field-form/lib/interface';
).It would make
babelPluginImportLib2Es
offather-plugin
useless since Node/TS/bundlers would automatically add the rightes
orlib
prefix when importing/requiring a file of an other RC module from source ores
orlib
folder. Note that, for this to work, files ines
folder should be considered as ESM (files should use.mjs
extension or apackage.json
with"type": "module"
should be added toes
folder) which is not the case today (bug!). There is a pending PR to fix this bug infather
: umijs/father#742It should be possible to make this change in a backward-compatible manner with this alternative patch which will block access to
es
from a CJS module andlib
from an ESM module:Or if we want to be 100% backward-compatible (what I don't recommend because it allows a misuse of RC module) we can keep access to wrong paths with:
The text was updated successfully, but these errors were encountered: