Skip to content

v7.1.0

Latest

Choose a tag to compare

@github-actions github-actions released this 11 Nov 15:51
· 3 commits to main since this release

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, paths aliases resolved, CSS / ?raw / JSON / wasm / native addons supported, and 'use client'-style directives kept on the files that declare them.
  • Declarations: .d.ts and .d.cts files are emitted for every module the public types reach. As in bundled builds, they follow the types condition in exports.
  • Bundled dependencies go into _vendor/ instead of node_modules/, because npm pack drops node_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_CONFLICT or BUNCHEE_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:
    • Single-entry packages share one Rollup graph across their ESM and CJS outputs (#774).
    • Declaration plugins are initialized only for type graphs, not for JS graphs (#771).
    • The CSS injection helper is emitted only in chunks that contain CSS (#773).

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 exports map (#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