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

feat!: move packages to ESM first #418

Merged
merged 1 commit into from
Nov 16, 2024

Conversation

userquin
Copy link
Member

This PR moves @intlify/bundle-utils and @intlify/unplugin-vue-i18n to ESM first (right now CJS) fixing packages exports in both packages.

Without this PR

imagen
@intlify/bundle-utils

imagen
@intlify/unplugin-vue-i18n

With this PR

imagen
@intlify/bundle-utils

imagen
@intlify/unplugin-vue-i18n

await Promise.all([
rm(resolve(lib, 'types.cjs')),
rm(resolve(lib, 'types.mjs')),
...['vite', 'webpack'].map(async name => {
Copy link
Member Author

@userquin userquin Nov 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is about removing the extra required .default when requiring vite or webpack plugin (I don't use default export anymore to avoid this, you can remove the hack, run pnpm build && pnpm pack from the package and upload the generated tgz to https://arethetypeswrong.github.io/ or just check https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseExportDefault.md):

const webpack = require('@intlify/unplugin-vue-i18n/webpack').default

Copy link
Member

@kazupon kazupon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good to me!
Thank you! ❤️

@kazupon kazupon merged commit 27ec73f into intlify:main Nov 16, 2024
5 checks passed
@userquin userquin deleted the userquin/feat-move-to-esm-first branch November 16, 2024 14:35
@Tofandel
Copy link

@userquin What is the tool that you used to detect those problems?

@userquin
Copy link
Member Author

userquin commented Dec 13, 2024

@Tofandel I use publint and arethetypeswrong, both can be used with its own CLI, but I use their web version for a quick look at package exports.

arethetypeswrong will use use TypeScript to apply resolutions for node10, node16 and bundler module resolutions: will show the trace and some hints with the problems and how to solve them.

Visit https://arethetypeswrong.github.io/?p=%40intlify%2Funplugin-vue-i18n%405.3.1:

  • hints at top, there are more, check the folder in the repo (click for example on Masquerading as CJS )
  • click Details at bottom, you will see the resolutions for each entry point (subpackage exports) with every module resolution and the visible problems can be found in last entry "problems".

Daniel Roe added arethetypeswrong CLI workflow to Nuxt and later I added it to UnoCSS:

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

Successfully merging this pull request may close these issues.

3 participants