Skip to content

Conversation

@UmbraCi
Copy link
Contributor

@UmbraCi UmbraCi commented Oct 22, 2025

Summary

This PR adds support for multiple build output formats to better serve different use cases.

Changes

  • Configure Rollup to generate three output formats:
    • ES Module () - for modern bundlers with tree-shaking support
    • CommonJS () - for require/legacy toolchains
    • UMD () - for direct usage with global variables
  • Update package.json:
    • Set main to CommonJS entry
    • Set module to ES Module entry
    • Add unpkg fields for CDN usage
    • Update exports field to support conditional imports
    • Add all output directories to files field
  • Update .gitignore to exclude build outputs

Benefits

  • Modern bundlers can use ES modules for better tree-shaking
  • Legacy tools can continue using CommonJS
  • CDN users can directly include UMD builds via <script> tags
  • Better compatibility across different environments

Testing

  • ✅ Build succeeds and generates all three formats
  • ✅ All formats include source maps
  • ✅ Main library and plugins are built in all formats

- Configure Rollup to generate three output formats:
  - ES Module (es/) for modern bundlers with tree-shaking
  - CommonJS (lib/) for require/legacy toolchains
  - UMD (dist/) for direct script usage with global variables
- Update package.json exports to support all formats
- Add build outputs to .gitignore
- Support both unpkg and jsdelivr CDN usage
@UmbraCi
Copy link
Contributor Author

UmbraCi commented Dec 11, 2025

@hizzgdev 辛苦看下

Copy link
Owner

@hizzgdev hizzgdev left a comment

Choose a reason for hiding this comment

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

@UmbraCi 多output 这两种格式的好处是什么呢?之前有什么问题呢?

"version": "0.9.0",
"description": "jsMind is a pure javascript library for mindmap, it base on html5 canvas. jsMind was released under BSD license, you can embed it in any project, if only you observe the license.",
"main": "es6/jsmind.js",
"main": "lib/jsmind.js",
Copy link
Owner

Choose a reason for hiding this comment

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

之前的 "main":"es6/jsmind.js" 其实是现在的 "dist/jsmind.js"
这里要与之前的版本保持兼容。

// ES Module - for modern bundlers with tree-shaking support
{
file: 'es/jsmind.js',
format: 'es',
Copy link
Owner

Choose a reason for hiding this comment

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

为什么需要导出为 es 格式呢?需要的话是不是可以直接使用源码?这样的 output 它会把其它依赖的文件打包在一起吗?

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