Skip to content
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): create package.json with module type, add import extensions… #742

Closed

Conversation

LouisStairwage
Copy link

Do not accept the PR this way the code is error prone because of regex use for parsing imports in JS files.

Hi, this PR will be the first of serie for fixing ESM builds in antd galaxy libraries (antd-icons, rc-*, antd), father is used everywhere in these projects and could help fixing some issues describe by my coworker here : issue on rc-util, issue on antd

It adds :

  • Creation of a package.json file with "type": "module" or "commonjs" in it at build's root.
  • ⚠️ A code block that parses relative esm imports in files with regexs, resolves final relative modules paths (because ESM spec requires full relative path imports), it should certainly not be done that way, parsing files by implementing a transformer plugin or directly parsing ast and transforming it yourselves.

@LouisStairwage
Copy link
Author

LouisStairwage commented Feb 7, 2024

Just as an edit, I just saw fatherBabelPluginImportLib2Es, these adjustments could be implemented in plugins using babel too and implemented in antd / rc projects. Any opinions on this ?

@jer-sen
Copy link

jer-sen commented Aug 13, 2024

@sorrycc why did you close this PR ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants