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

chore: use unbuild to bundle plugins #8139

Merged
merged 12 commits into from May 13, 2022
Merged

chore: use unbuild to bundle plugins #8139

merged 12 commits into from May 13, 2022

Conversation

antfu
Copy link
Member

@antfu antfu commented May 12, 2022

Changes

  • All plugins are now using unbuild to bundle and generate DTS (due to the complexity, leave the bundle of core untouched)
  • All plugins are now emitting both CJS and ESM builds, with exports field (probably breaking)
  • Migrated plugin-vue-jsx and plugin-legacy to TypeScript
  • build-vite, build-plugin-* scripts are removed. pnpm run build uses pnpm's recursive runs to build them together.
  • patchEsbuildDist is removed in favor of patchCJS
  • build for plugins no longer deps on Vite's build
  • add a top-level dev script to run all watch build at once.

@antfu antfu changed the title chore: use unbuild to bundle plugins chore: use unbuild to bundle plugins May 12, 2022
@antfu antfu added enhancement New feature or request breaking change labels May 12, 2022
@antfu antfu enabled auto-merge (squash) May 12, 2022 09:11
@antfu antfu merged commit 638b168 into main May 13, 2022
@antfu antfu deleted the chore/unbuild branch May 13, 2022 03:00
@sapphi-red
Copy link
Member

sapphi-red commented May 13, 2022

@antfu Was it ok to merge this? (in case, didn't notice the auto-merge)

@antfu
Copy link
Member Author

antfu commented May 13, 2022

I guess it should be fine :)

@bluwy
Copy link
Member

bluwy commented May 13, 2022

Also partially reviewed this yesterday and it looks good as well.

@antfu antfu added this to the 3.0 milestone May 13, 2022
@bompus
Copy link
Contributor

bompus commented May 18, 2022

I believe this broke @vitejs/plugin-vue@3.0.0-alpha.0 for me. I'm looking at the dist/index.mjs file and tryRequire and other calls are still using require(), but require isn't available in ESM, which causes the tryRequire call to fail.

I'm using vite.config.js inside a project where package.json is using "type": "module", node v18.2.0

Error: Failed to resolve vue/compiler-sfc.
@vitejs/plugin-vue requires vue (>=3.2.25) to be present in the dependency tree.
    at resolveCompiler (file:///cms/node_modules/.pnpm/@vitejs+plugin-vue@3.0.0-alpha.0_tmmodkd2szetyztewt3aaxwddq/node_modules/@vitejs/plugin-vue/dist/index.mjs:12:11)

Previous working → New non-working:

@vitejs/plugin-legacy  1.8.2  →  2.0.0-alpha.0     
@vitejs/plugin-vue     2.3.3  →  3.0.0-alpha.0     
vite                   2.9.9  →  3.0.0-alpha.1

@sapphi-red
Copy link
Member

@bompus Thanks for the report. plugin-*@*.0.0-alpha.1 has been released which includes the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants