-
-
Notifications
You must be signed in to change notification settings - Fork 899
feat: add multiple build output formats (ES/CJS/UMD) #677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
UmbraCi
wants to merge
2
commits into
hizzgdev:master
Choose a base branch
from
UmbraCi:feat/multiple-products
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,76 +1,121 @@ | ||
| import cleanup from 'rollup-plugin-cleanup'; | ||
| import terser from '@rollup/plugin-terser'; | ||
|
|
||
| export default [ | ||
| { | ||
| input: 'src/jsmind.js', | ||
| output: { | ||
| const banner = | ||
| '/**\n* @license BSD-3-Clause\n* @copyright 2014-2025 hizzgdev@163.com\n*\n* Project Home:\n* https://github.com/hizzgdev/jsmind/\n*/'; | ||
|
|
||
| const cleanupPlugin = cleanup({ | ||
| comments: 'none', | ||
| }); | ||
|
|
||
| const terserPlugin = terser({ | ||
| output: { | ||
| comments: 'all', | ||
| }, | ||
| }); | ||
|
|
||
| // Main library configuration | ||
| const mainConfig = { | ||
| input: 'src/jsmind.js', | ||
| output: [ | ||
| // ES Module - for modern bundlers with tree-shaking support | ||
| { | ||
| file: 'es/jsmind.js', | ||
| format: 'es', | ||
| banner, | ||
| sourcemap: true, | ||
| }, | ||
| // CommonJS - for require/legacy toolchains | ||
| { | ||
| file: 'lib/jsmind.js', | ||
| format: 'cjs', | ||
| banner, | ||
| sourcemap: true, | ||
| exports: 'auto', | ||
| }, | ||
| // UMD - for direct <script> usage, exposes global jsMind | ||
| { | ||
| name: 'jsMind', | ||
| file: 'es6/jsmind.js', | ||
| file: 'dist/jsmind.js', | ||
| format: 'umd', | ||
| banner: '/**\n* @license BSD-3-Clause\n* @copyright 2014-2025 hizzgdev@163.com\n*\n* Project Home:\n* https://github.com/hizzgdev/jsmind/\n*/', | ||
| banner, | ||
| sourcemap: true, | ||
| }, | ||
| plugins: [ | ||
| cleanup({ | ||
| comments: 'none', | ||
| }), | ||
| terser({ | ||
| output: { | ||
| comments: 'all', | ||
| }, | ||
| }), | ||
| ], | ||
| }, | ||
| { | ||
| input: 'src/plugins/jsmind.draggable-node.js', | ||
| output: { | ||
| ], | ||
| plugins: [cleanupPlugin, terserPlugin], | ||
| }; | ||
|
|
||
| // Draggable-node plugin configuration | ||
| const draggableNodeConfig = { | ||
| input: 'src/plugins/jsmind.draggable-node.js', | ||
| output: [ | ||
| // ES Module | ||
| { | ||
| file: 'es/jsmind.draggable-node.js', | ||
| format: 'es', | ||
| banner, | ||
| sourcemap: true, | ||
| }, | ||
| // CommonJS | ||
| { | ||
| file: 'lib/jsmind.draggable-node.js', | ||
| format: 'cjs', | ||
| banner, | ||
| sourcemap: true, | ||
| exports: 'named', | ||
| }, | ||
| // UMD | ||
| { | ||
| name: 'jsMindDraggableNode', | ||
| file: 'es6/jsmind.draggable-node.js', | ||
| file: 'dist/jsmind.draggable-node.js', | ||
| format: 'umd', | ||
| banner: '/**\n* @license BSD-3-Clause\n* @copyright 2014-2025 hizzgdev@163.com\n*\n* Project Home:\n* https://github.com/hizzgdev/jsmind/\n*/', | ||
| banner, | ||
| sourcemap: true, | ||
| globals: { | ||
| jsmind: 'jsMind', | ||
| }, | ||
| exports: 'named', | ||
| }, | ||
| external: ['jsmind'], | ||
| plugins: [ | ||
| cleanup({ | ||
| comments: 'none', | ||
| }), | ||
| terser({ | ||
| output: { | ||
| comments: 'all', | ||
| }, | ||
| }), | ||
| ], | ||
| }, | ||
| { | ||
| input: 'src/plugins/jsmind.screenshot.js', | ||
| output: { | ||
| ], | ||
| external: ['jsmind'], | ||
| plugins: [cleanupPlugin, terserPlugin], | ||
| }; | ||
|
|
||
| // Screenshot plugin configuration | ||
| const screenshotConfig = { | ||
| input: 'src/plugins/jsmind.screenshot.js', | ||
| output: [ | ||
| // ES Module | ||
| { | ||
| file: 'es/jsmind.screenshot.js', | ||
| format: 'es', | ||
| banner, | ||
| sourcemap: true, | ||
| }, | ||
| // CommonJS | ||
| { | ||
| file: 'lib/jsmind.screenshot.js', | ||
| format: 'cjs', | ||
| banner, | ||
| sourcemap: true, | ||
| exports: 'named', | ||
| }, | ||
| // UMD | ||
| { | ||
| name: 'jsMindScreenshot', | ||
| file: 'es6/jsmind.screenshot.js', | ||
| file: 'dist/jsmind.screenshot.js', | ||
| format: 'umd', | ||
| banner: '/**\n* @license BSD-3-Clause\n* @copyright 2014-2025 hizzgdev@163.com\n*\n* Project Home:\n* https://github.com/hizzgdev/jsmind/\n*/', | ||
| banner, | ||
| sourcemap: true, | ||
| globals: { | ||
| 'jsmind': 'jsMind', | ||
| 'dom-to-image': 'domtoimage', | ||
| }, | ||
| exports: 'named', | ||
| }, | ||
| external: ['jsmind', 'dom-to-image'], | ||
| plugins: [ | ||
| cleanup({ | ||
| comments: 'none', | ||
| }), | ||
| terser({ | ||
| output: { | ||
| comments: 'all', | ||
| }, | ||
| }), | ||
| ], | ||
| }, | ||
| ]; | ||
| ], | ||
| external: ['jsmind', 'dom-to-image'], | ||
| plugins: [cleanupPlugin, terserPlugin], | ||
| }; | ||
|
|
||
| export default [mainConfig, draggableNodeConfig, screenshotConfig]; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,22 +2,24 @@ | |
| "name": "jsmind", | ||
| "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", | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 之前的 "main":"es6/jsmind.js" 其实是现在的 "dist/jsmind.js" |
||
| "module": "es/jsmind.js", | ||
| "unpkg": "dist/jsmind.js", | ||
| "types": "types/generated/index.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "import": "./es6/jsmind.js", | ||
| "require": "./es6/jsmind.js", | ||
| "import": "./es/jsmind.js", | ||
| "require": "./lib/jsmind.js", | ||
| "types": "./types/generated/index.d.ts" | ||
| }, | ||
| "./draggable-node": { | ||
| "import": "./es6/jsmind.draggable-node.js", | ||
| "require": "./es6/jsmind.draggable-node.js", | ||
| "import": "./es/jsmind.draggable-node.js", | ||
| "require": "./lib/jsmind.draggable-node.js", | ||
| "types": "./types/generated/plugins/jsmind.draggable-node.d.ts" | ||
| }, | ||
| "./screenshot": { | ||
| "import": "./es6/jsmind.screenshot.js", | ||
| "require": "./es6/jsmind.screenshot.js", | ||
| "import": "./es/jsmind.screenshot.js", | ||
| "require": "./lib/jsmind.screenshot.js", | ||
| "types": "./types/generated/plugins/jsmind.screenshot.d.ts" | ||
| }, | ||
| "./style/jsmind.css": "./style/jsmind.css" | ||
|
|
@@ -27,7 +29,9 @@ | |
| "example": "example" | ||
| }, | ||
| "files": [ | ||
| "es6", | ||
| "es", | ||
| "lib", | ||
| "dist", | ||
| "style", | ||
| "types", | ||
| "LICENSE", | ||
|
|
||
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么需要导出为 es 格式呢?需要的话是不是可以直接使用源码?这样的 output 它会把其它依赖的文件打包在一起吗?