react-component / father-plugin Goto Github PK
View Code? Open in Web Editor NEWfather plugin for all react-component project
License: MIT License
father plugin for all react-component project
License: MIT License
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:
- "main": "./lib/index",
- "module": "./es/index",
+ "exports": {
+ ".": {
+ "types": {
+ "import": "./es/index.d.ts",
+ "default": "./lib/index.d.ts"
+ },
+ "import": "./es/index.js",
+ "default": "./lib/index.js"
+ },
+ "./*": {
+ "types": {
+ "import": "./es/*",
+ "require": "./lib/*"
+ },
+ "import": "./es/*",
+ "require": "./lib/*"
+ }
+ },
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:
- "main": "./lib/index",
- "module": "./es/index",
+ "exports": {
+ ".": {
+ "types": {
+ "import": "./es/index.d.ts",
+ "default": "./lib/index.d.ts"
+ },
+ "import": "./es/index.js",
+ "default": "./lib/index.js"
+ },
+ "./es/*": {
+ "types": {
+ "import": "./es/*"
+ },
+ "import": "./es/*"
+ },
+ "./lib/*": {
+ "types": {
+ "require": "./lib/*"
+ },
+ "require": "./lib/*"
+ },
+ "./*": {
+ "types": {
+ "import": "./es/*",
+ "require": "./lib/*"
+ },
+ "import": "./es/*",
+ "require": "./lib/*"
+ },
+ },
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:
- "main": "./lib/index",
- "module": "./es/index",
+ "exports": {
+ ".": {
+ "types": {
+ "import": "./es/index.d.ts",
+ "default": "./lib/index.d.ts"
+ },
+ "import": "./es/index.js",
+ "default": "./lib/index.js"
+ },
+ "./es/*": {
+ "types": {
+ "import": "./es/*",
+ "require": "./es/*"
+ },
+ "import": "./es/*",
+ "require": "./es/*"
+ },
+ "./lib/*": {
+ "types": {
+ "import": "./lib/*",
+ "require": "./lib/*"
+ },
+ "import": "./lib/*",
+ "require": "./lib/*"
+ },
+ "./*": {
+ "types": {
+ "import": "./es/*",
+ "require": "./lib/*"
+ },
+ "import": "./es/*",
+ "require": "./lib/*"
+ },
+ },
查了下好像添加这个就可以继续构建下去 --no-error-on-unmatched-pattern
npx eslint src/ --ext .tsx,.ts --rule '@typescript-eslint/consistent-type-exports: error' --no-error-on-unmatched-pattern
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.