diff --git a/README.md b/README.md index c4c442fc..98da93da 100644 --- a/README.md +++ b/README.md @@ -23,23 +23,48 @@ and example links. There is also a validator that demonstrates how to use the library in a webpage in the [tools/](https://github.com/kewisch/ical.js/tree/main/tools) subdirectory. -[Try the validator online](http://kewisch.github.io/ical.js/validator.html), it always uses the latest release of ICAL.js. +[Try the validator online](http://kewisch.github.io/ical.js/validator.html), it always uses the +latest release of ICAL.js. ## Installing -You can install ICAL.js via [npm](https://www.npmjs.com/), if you would like to use it in Node.js: -``` +ICAL.js has no dependencies and is written in modern JavaScript. You can install ICAL.js via +[npm](https://www.npmjs.com/), if you would like to use it in Node.js: +```bash npm install ical.js ``` +Then simply import it for use: +```javascript +import ICAL from "ical.js"; +``` -ICAL.js has no dependencies and is written in modern JavaScript. A version transpiled to ES5 is -available as well. It should work in all versions of Node.js and modern browsers. +If you are working with a browser, be aware this is an ES6 module: + +```html + +``` + +If you need to make use of a script tag, you can use the transpiled ES5 version: +```html + + + +``` ## Timezones The stock ical.js does not register any timezones, due to the additional size it brings. If you'd like to do timezone conversion, and the timezone definitions are not included in the respective ics files, you'll need to use `ical.timezones.js` or its minified counterpart. +This file is not included in the distribution since it pulls in IANA timezones that might change +regularly. See the github actions on building your own timezones during CI, or grab a recent build +from main. + ## Documentation For a few guides with code samples, please check out diff --git a/package-lock.json b/package-lock.json index 62386110..48bf106b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ical.js", - "version": "2.0.0", + "version": "2.0.1", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 13738585..63f46c0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ical.js", - "version": "2.0.0", + "version": "2.0.1", "author": "Philipp Kewisch", "contributors": [ "Github Contributors (https://github.com/kewisch/ical.js/graphs/contributors)" diff --git a/rollup.config.js b/rollup.config.js index ac2ea43b..a819dbcc 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -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'] }) ] -}; +}];