Skip to content

feat: Make library tree-shakable and add separate entrypoints#214

Merged
DecimalTurn merged 9 commits into
dev-v2from
dev-tree-shake2
May 31, 2026
Merged

feat: Make library tree-shakable and add separate entrypoints#214
DecimalTurn merged 9 commits into
dev-v2from
dev-tree-shake2

Conversation

@DecimalTurn

Copy link
Copy Markdown
Owner

This PR is focusing on enabling tree-shaking for bundler consumers. To implement this the previous entrypoint that was minified and bundled had to be unbundled. This means that direct browser/CDN usage will have to use the following URL now to get the actual minified version of the package: https://unpkg.com/@decimalturn/toml-patch/dist/toml-patch.min.js

- add sideEffects: false and move package entry/types to dist/index.js
- switch Rollup to preserveModules output and keep dist/toml-patch.min.js for browser/CDN
- emit per-module .d.ts files
- update benchmark and JS integration test imports from dist/toml-patch.js to dist/index.js
- add benchmark/check-tree-shaking.mjs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the package’s build and public entrypoints to better support bundler tree-shaking by publishing a preserved-modules ESM build, while still shipping a separate minified browser bundle for CDN/direct browser usage.

Changes:

  • Switch Rollup output to preserved ESM modules (dist/index.js, dist/patch.js, dist/format.js) plus a separate minified bundle (dist/toml-patch.min.js).
  • Introduce new source entrypoints (src/patch-entry.ts, src/format-entry.ts) and move patch implementation to src/patch-toml.ts.
  • Update docs, demos, benchmarks, and tests to use the new dist/entrypoint layout.

Reviewed changes

Copilot reviewed 27 out of 28 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/toml-document.ts Update internal import to use the new patch module.
src/patch-toml.ts New patch implementation module (replacing prior entrypoint coupling).
src/patch-entry.ts New subpath entry for ./patch.
src/index.ts Root entry now re-exports patch from patch-toml.
src/format-entry.ts New subpath entry for ./format.
src/tests/validate-cst.test.ts Update test import to new patch module.
src/tests/patch.test.ts Update test import to new patch module.
src/tests/patch.spec-example.test.ts Update test import to new patch module.
src/tests/patch.mlbs.test.ts Update test import to new patch module.
src/tests/patch.mlbs.leb.test.ts Update test import to new patch module.
src/tests/patch.ls.test.ts Update test import to new patch module.
src/tests/inlinetablestart.test.ts Update test import to new patch module.
src/tests/comment-alignment.test.ts Update test import to new patch module.
src/tests/js/toml-format.test.mjs JS integration tests now import from dist/index.js.
src/tests/js/toml-document.test.mjs JS integration tests now import from dist/index.js.
src/tests/js/stringify.test.mjs JS integration tests now import from dist/index.js.
src/tests/js/patch.test.mjs JS integration tests now import from dist/index.js.
scripts/build-demo.mjs Update demo-build script to target the new minified bundle path.
rollup.config.js Produce preserved ESM modules + separate minified browser bundle.
README.md Update browser/CDN usage URL to the new minified bundle path.
package.json Add sideEffects:false, update types/module/exports, and add ./patch + ./format subpath exports.
dev_demo.html Update local demo to import dist/toml-patch.min.js.
demo.html Update demo to import the explicit unpkg minified bundle path.
CHANGELOG.md Document packaging/export changes and new CDN guidance.
benchmark/stringify-benchmark.mjs Update benchmark to import from dist/index.js.
benchmark/profile.mjs Update profiler to import from dist/index.js.
benchmark/parse-benchmark.mjs Update benchmark to import from dist/index.js.
benchmark/check-tree-shaking.mjs Add script to validate tree-shaking size improvements across entrypoints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread rollup.config.js
@DecimalTurn DecimalTurn changed the title feat: Make library tree-shaking and add separate entrypoints feat: Make library tree-shakable and add separate entrypoints May 25, 2026
@DecimalTurn DecimalTurn marked this pull request as ready for review May 31, 2026 05:19
@DecimalTurn DecimalTurn merged commit 7f5168c into dev-v2 May 31, 2026
6 checks passed
@DecimalTurn DecimalTurn deleted the dev-tree-shake2 branch May 31, 2026 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants