Repository navigation
v7.1.0
unbundle mode (--unbundle) — #776
Unbundle mode emits one output file per source module instead of bundling, with a layout that mirrors src/. Entries still come from package.json#exports, and their output paths match what exports declares.
bunchee --unbundle- Same plugins as a bundled build: dual ESM/CJS output, import extensions rewritten for each format,
pathsaliases resolved, CSS /?raw/ JSON / wasm / native addons supported, and'use client'-style directives kept on the files that declare them. - Declarations:
.d.tsand.d.ctsfiles are emitted for every module the public types reach. As in bundled builds, they follow thetypescondition inexports. - Bundled dependencies go into
_vendor/instead ofnode_modules/, becausenpm packdropsnode_modules/directories. Rollup virtual modules go into_virtual/, with names that are the same on every machine. - Output path conflicts are errors, never silent overwrites. Every error has a named code, such as
BUNCHEE_UNBUNDLE_OUTPUT_CONFLICTorBUNCHEE_UNBUNDLE_OUTSIDE_ROOT. - The build log lists the public entries and summarizes internal modules in one line.
This mode does not yet support --watch, -o, or local modules outside the package's source root.
CSP-safe CSS injection — #781
Imported CSS is now applied as a constructable stylesheet added to document.adoptedStyleSheets, instead of an inline <style> tag. Pages whose Content Security Policy omits 'unsafe-inline' from style-src now apply the styles without a nonce. Fixes #686.
- Fallback: browsers without
adoptedStyleSheets(Chrome < 73, Firefox < 101, Safari < 16.4), and CSS containing@import, still use a<style>tag. ⚠️ Cascade change: adopted stylesheets come after the document's own stylesheets. When specificity is equal, a library's styles now win over page styles that were added after the import. If you relied on page CSS overriding library CSS at equal specificity, raise the specificity of the page rule.
Improvements
- One build pipeline (#782): watch mode and builds given a CLI entry file now use the same merged module graphs as every other build. In watch mode, editing a module rebuilds every output of its graph together. Builds with a CLI entry file now share code between entries as chunks instead of building each entry separately.
- Faster builds:
Internal
- Build policies are split out behind a build-mode contract (#777), and entry selection is now a pure function (#779).
- Entry discovery no longer modifies the parsed
exportsmap (#780). - The output-state plugin can summarize internal files, and unbundle mode uses it instead of its own copy (#779).
- The worker pool and declaration sharding are covered by tests again.
- A real-browser test checks CSS under a strict CSP in CI.
- The docs site moved to Devjar (#770).
Full Changelog: v7.0.2...v7.1.0
Contributors: @huozhi