refactor: ESM-only packages (WIP) - #15000
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
❌ Deploy Preview for vue-sfc-playground failed. Why did it fail? →
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/compiler-vapor
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/runtime-vapor
@vue/server-renderer
@vue/shared
vue
commit: |
Size ReportBundles
Usages
|
|
We can upgrade |
…om, compiler-vapor)
The single `esm` build of @vue/compiler-core and @vue/compiler-dom is now consumed directly by Node tooling (e.g. @vitejs/plugin-vue's compileScript / compileTemplate) since CJS builds were dropped. Those builds were compiled with __BROWSER__=true, which forces prefixIdentifiers off and throws compiler error 48 (X_PREFIX_ID_NOT_SUPPORTED), breaking every SFC/SSR build. Scope the bundler `esm` format of compiler-core and compiler-dom to __BROWSER__=false while leaving their browser-targeted formats (global / esm-browser) untouched. Runtime packages keep __BROWSER__=true for their esm build (e.g. runtime-dom's useCssVars guard).
- server-renderer: prod:false — drop the unused server-renderer.esm-browser.prod.js - reactivity: drop esm-browser from published formats (dev bundle was dead, prod only needed for benchmarks) - build.js: honor explicitly requested formats for a single named target so `prebench` can still build reactivity's esm-browser bundle on demand
The esm-browser build of @vue/server-renderer imports node:stream (in renderToStream.ts), tree-shaken out of browser bundles. The external list only had the bare 'stream' specifier, so rolldown emitted an UNRESOLVED_IMPORT warning that turns fatal on stricter CI/Netlify builds. Add 'node:stream' to treeShakenDeps to suppress it.
|
Aren't the For example, if someone wants to use From a quick search through GitHub I found examples of people doing this, e.g.: I don't know what that application does, but it looks like valid usage to me. More generally, wouldn't we want to encourage people to use |
|
That's a good point. I need to add them back. I wonder if we are ready to drop the iife builds? At least for everything except Edit
|
The dev + prod esm-browser builds are useful for direct browser/CDN usage of @vue/reactivity, so publish them again instead of building the prod bundle on demand for benchmarks only.
- compiler-dom, runtime-dom: esm-only published output; remove the unpkg/jsdelivr fields since there is no browser-loadable bundle left - reactivity: point unpkg/jsdelivr at the esm-browser build instead - size-global: build each target separately so runtime-dom and compiler-dom global prod sizes stay tracked via the on-demand single-target format override in build.js (bundles are no longer published but remain the size-regression signal per package) - buildOptions.name kept: scripts/dev.js still uses it for local global-format dev builds
I suppose they are mainly loaded via CDN (and in turn do not show up in grep.app)? But having esm-browser only seems fine to me. |
|
Updated the table and simplified the list of changes to be more comprehensible |
Move all packages to ESM-only and drop legacy baggage.
vue(node/default) andcompiler-sfc(browser/default). Root"types"kept fornode10tsconfigs. All packages 🟢 on@arethetypeswrong/cli.dist/<pkg>.esm-bundler.js→dist/<pkg>.js.esm-browserbuilds to the ones in use (see table).vueIIFE/globalbuilds are kept.renderToNodeStream(), on-the-fly SSR template compilation) now work in the ESM Node build (__CJS__flag removed).@vue/compat,__COMPAT__,compat/dirs (~7.3k lines).distsize per packageBuilt JS bundles only (min + unmin), excluding
.d.tsand source maps. Base column measured onminorbefore the lastmainmerge, which explains the small drift on otherwise untouched packages (runtime-vapor,vue).minor)Build outputs kept / removed
✅ kept · ❌ removed · 🆕 added · — never had.
esm-bundleris renamed to.js(shown under ESM)..js)vueadditionally keeps its runtime-only and vapor browser builds (vue.runtime.*,vue.runtime-with-vapor.esm-browser[.prod]); only CJS was dropped.vue-compatis removed as a package.