From 02b12a95411dc5be3e453ed42e274344d4e2b0be Mon Sep 17 00:00:00 2001 From: Philipp Kewisch Date: Wed, 10 Apr 2024 08:26:32 +0200 Subject: [PATCH] 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 +``` + +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'] }) ] -}; +}];