-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make ical.es5.cjs an UMD module for browsers
In version 2.0.0 ical.es5.cjs and ical.es5.min.cjs was a cjs module, which made it work with older version of node and use of `require()`. The regular version uses ES6 modules, so it needs to be imported instead of using a script tag. Therefore, none of the versions could be included in a <script> tag in the browser. You can now use the es5 version if you require <script> tag inclusion and would like an `ICAL` global on the window, and also if you require a cjs module in your node project.
- Loading branch information
Showing
4 changed files
with
73 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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,32 +1,55 @@ | ||
import { getBabelOutputPlugin } from '@rollup/plugin-babel'; | ||
import { babel } from '@rollup/plugin-babel'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
|
||
export default { | ||
const LICENSE = | ||
`/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* Portions Copyright (C) Philipp Kewisch */`; | ||
|
||
const TERSER_OPTIONS = { | ||
format: { | ||
comments: function(node, comment) { | ||
if (comment.type == 'comment2') { | ||
return /terms of the Mozilla Public/.test(comment.value) && comment.pos === 0; | ||
} | ||
return false; | ||
} | ||
} | ||
}; | ||
|
||
export default [{ | ||
input: 'lib/ical/module.js', | ||
output: [ | ||
{ file: 'dist/ical.js', format: 'es', exports: "default" }, | ||
{ file: 'dist/ical.js', format: 'es', exports: 'default' }, | ||
{ | ||
file: 'dist/ical.min.js', | ||
banner: LICENSE, | ||
format: 'es', | ||
exports: "default", | ||
plugins: [terser()] | ||
}, | ||
exports: 'default', | ||
plugins: [terser(TERSER_OPTIONS)] | ||
} | ||
] | ||
}, { | ||
input: 'lib/ical/module.js', | ||
output: [ | ||
{ | ||
file: 'dist/ical.es5.cjs', | ||
exports: "default", | ||
format: 'cjs', | ||
plugins: [ | ||
getBabelOutputPlugin({ presets: ['@babel/preset-env'] }) | ||
], | ||
exports: 'default', | ||
name: 'ICAL', | ||
format: 'umd', | ||
banner: LICENSE, | ||
}, | ||
{ | ||
file: 'dist/ical.es5.min.cjs', | ||
exports: "default", | ||
format: 'cjs', | ||
plugins: [ | ||
getBabelOutputPlugin({ presets: ['@babel/preset-env'] }), | ||
terser() | ||
] | ||
exports: 'default', | ||
name: 'ICAL', | ||
format: 'umd', | ||
banner: LICENSE, | ||
plugins: [terser(TERSER_OPTIONS)], | ||
} | ||
], | ||
plugins: [ | ||
babel({ babelHelpers: 'bundled', presets: ['@babel/preset-env'] }) | ||
] | ||
}; | ||
}]; |