sheetjs_sheetjs/demos/rollup
SheetJS 5dd16ae640 version bump 0.12.3: cleanup
- PtgList and old Ptg record support
- fleshed out ftab constants from macrosheet support
- reimplemented / fixed / removed shim functions
- demo refresh
2018-02-28 05:41:49 -05:00
..
.gitignore demo refresh [ci skip] 2017-09-24 19:40:09 -04:00
app.js demo refresh [ci skip] 2017-09-24 19:40:09 -04:00
main.js rollup demo [ci skip] 2017-06-08 02:19:11 -04:00
Makefile version bump 0.12.3: cleanup 2018-02-28 05:41:49 -05:00
README.md demo refresh [ci skip] 2017-09-24 19:40:09 -04:00
rollup.config.js version bump 0.12.3: cleanup 2018-02-28 05:41:49 -05:00
rollup.config.node.js version bump 0.12.3: cleanup 2018-02-28 05:41:49 -05:00
rollup.config.worker.js version bump 0.12.3: cleanup 2018-02-28 05:41:49 -05:00
rollup.html demo refresh [ci skip] 2017-09-24 19:40:09 -04:00
xlsxworker.js demo refresh [ci skip] 2017-09-24 19:40:09 -04:00

Rollup

This library presents itself as a CommonJS library, so some configuration is required. The examples at https://rollupjs.org can be followed pretty much in verbatim. This sample demonstrates a bundle for browser as well as for node.

This demo uses the import form to expose the whole library, enabling client code to access the library with import XLSX from 'xlsx'. The JS code from the root demo was moved to a separate app.js script.

Required Plugins

The rollup-plugin-node-resolve and rollup-plugin-commonjs plugins are used:

import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
export default {
	/* ... */
	plugins: [
		resolve({
			module: false, // <-- this library is not an ES6 module
			browser: true, // <-- suppress node-specific features
		}),
		commonjs()
	],
	/* ... */
};

For the browser deployments, the output format is 'iife'. For node, the output format is 'cjs'.

Worker Scripts

Rollup can also bundle worker scripts! Instead of using importScripts, the worker script should import the module:

-importScripts('dist/xlsx.full.min.js');
+import XLSX from 'xlsx';

Analytics