From 6a100b9085392eb053e394840b1991716c822b86 Mon Sep 17 00:00:00 2001 From: SheetJS Date: Thu, 8 Jun 2017 02:19:11 -0400 Subject: [PATCH] rollup demo [ci skip] --- CHANGELOG.md | 4 ++++ Makefile | 11 ++++++++++- README.md | 11 ++++++----- demos/README.md | 12 ++++++++++++ demos/rollup/.gitignore | 3 +++ demos/rollup/Makefile | 19 +++++++++++++++++++ demos/rollup/README.md | 26 ++++++++++++++++++++++++++ demos/rollup/main.js | 3 +++ demos/rollup/rollup.config.js | 16 ++++++++++++++++ demos/rollup/rollup.config.node.js | 15 +++++++++++++++ demos/rollup/xlsxworker.js | 11 +++++++++++ demos/rollup/xlsxworker1.js | 26 ++++++++++++++++++++++++++ demos/rollup/xlsxworker2.js | 26 ++++++++++++++++++++++++++ docbits/10_install.md | 1 + docbits/80_parseopts.md | 5 +++-- docbits/82_util.md | 5 ++--- 16 files changed, 183 insertions(+), 11 deletions(-) create mode 100644 demos/README.md create mode 100644 demos/rollup/.gitignore create mode 100644 demos/rollup/Makefile create mode 100644 demos/rollup/README.md create mode 100644 demos/rollup/main.js create mode 100644 demos/rollup/rollup.config.js create mode 100644 demos/rollup/rollup.config.node.js create mode 100644 demos/rollup/xlsxworker.js create mode 100644 demos/rollup/xlsxworker1.js create mode 100644 demos/rollup/xlsxworker2.js diff --git a/CHANGELOG.md b/CHANGELOG.md index f074dc2..0f0b486 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ but not limited to API changes and file location changes. Minor behavioral changes may not be included if they are not expected to break existing code. +## Unreleased (2017-06-??) + +* HTML Table output header/footer should not include `` tag + ## 0.10.2 (2017-05-16) * Dates are converted to numbers by default (set `cellDates:true` to emit Dates) diff --git a/Makefile b/Makefile index 9dcd6a0..f643214 100644 --- a/Makefile +++ b/Makefile @@ -113,8 +113,12 @@ ctest: ## Build browser test fixtures ctestserv: ## Start a test server on port 8000 @cd tests && python -mSimpleHTTPServer +## Demos + +DEMOS=angular browserify requirejs rollup systemjs webpack +DEMOTGTS=$(patsubst %,demo-%,$(DEMOS)) .PHONY: demos -demos: demo-angular demo-browserify demo-webpack demo-requirejs demo-systemjs +demos: $(DEMOTGTS) .PHONY: demo-angular demo-angular: ## Run angular demo build @@ -136,6 +140,11 @@ demo-requirejs: ## Run requirejs demo build make -C demos/requirejs @echo "start a local server and go to demos/requirejs/requirejs.html" +.PHONY: demo-rollup +demo-rollup: ## Run rollup demo build + make -C demos/rollup + @echo "start a local server and go to demos/rollup/rollup.html" + .PHONY: demo-systemjs demo-systemjs: ## Run systemjs demo build make -C demos/systemjs diff --git a/README.md b/README.md index b04604f..2fe756b 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,7 @@ The `demos` directory includes sample projects for: - [`meteor`](demos/meteor/) - [`phantomjs`](demos/phantomjs/) - [`requirejs`](demos/requirejs/) +- [`rollup`](demos/rollup/) - [`systemjs`](demos/systemjs/) - [`webpack`](demos/webpack/) @@ -1388,12 +1389,13 @@ Plaintext format guessing follows the priority order: | Format | Test | |:-------|:--------------------------------------------------------------------| -| HTML | starts with \
@@ -1643,9 +1645,8 @@ produces HTML output. The function takes an options argument: | Option Name | Default | Description | | :---------- | :------: | :-------------------------------------------------- | | editable | false | If true, set `contenteditable="true"` for every TD | -| header | | Override header (default `html body table`) | -| footer | | Override footer (default `/table /body /html`) | - +| header | | Override header (default `html body`) | +| footer | | Override footer (default `/body /html`) |
Examples (click to show) diff --git a/demos/README.md b/demos/README.md new file mode 100644 index 0000000..fb3a47a --- /dev/null +++ b/demos/README.md @@ -0,0 +1,12 @@ +# Demos + +These demos are intended to demonstrate how to load this library in various +ecosystems. The library is designed to be used in the web browser and in node +contexts, using dynamic feature tests to pull in features when necessary. This +works extremely well in common use cases: script tag insertion and node require. + +Systems like webpack try to be clever by performing simple static analysis to +pull in code. However, they do not support dynamic type tests, breaking +compatibility with traditional scripts. Configuration is required. The demos +cover basic configuration steps for various systems and should work as laid out. + diff --git a/demos/rollup/.gitignore b/demos/rollup/.gitignore new file mode 100644 index 0000000..386cd9e --- /dev/null +++ b/demos/rollup/.gitignore @@ -0,0 +1,3 @@ +rollup.js +rollup.min.js +rollup.node.js diff --git a/demos/rollup/Makefile b/demos/rollup/Makefile new file mode 100644 index 0000000..0af6b2c --- /dev/null +++ b/demos/rollup/Makefile @@ -0,0 +1,19 @@ +TOOL=rollup +.PHONY: all +all: $(TOOL).min.js + +$(TOOL).min.js: $(TOOL).js + uglifyjs $< > $@ + +.PHONY: $(TOOL).js +$(TOOL).js: + # node + rollup -c rollup.config.node.js + node -e 'require("./rollup.node")' + # browser + rollup -c + +.PHONY: init +init: + @npm install rollup-plugin-node-resolve rollup-plugin-commonjs + @mkdir -p node_modules; cd node_modules; ln -s ../../../ xlsx; cd - diff --git a/demos/rollup/README.md b/demos/rollup/README.md new file mode 100644 index 0000000..8c01a56 --- /dev/null +++ b/demos/rollup/README.md @@ -0,0 +1,26 @@ +# Rollup + +This library presents itself as a CommonJS library, so some configuration is +required. The examples at can be followed pretty much in +verbatim. This sample demonstrates a rollup for browser as well as for node. + +## Required Plugins + +The `rollup-plugin-node-resolve` and `rollup-plugin-commonjs` plugins are used: + +```js +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() + ], + /* ... */ +}; +``` + diff --git a/demos/rollup/main.js b/demos/rollup/main.js new file mode 100644 index 0000000..7c45417 --- /dev/null +++ b/demos/rollup/main.js @@ -0,0 +1,3 @@ +/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ +import XLSX from 'xlsx'; +export default XLSX; diff --git a/demos/rollup/rollup.config.js b/demos/rollup/rollup.config.js new file mode 100644 index 0000000..f61e86a --- /dev/null +++ b/demos/rollup/rollup.config.js @@ -0,0 +1,16 @@ +/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ +import resolve from 'rollup-plugin-node-resolve'; +import commonjs from 'rollup-plugin-commonjs'; +export default { + entry: 'main.js', + dest: 'rollup.js', + plugins: [ + resolve({ + module: false, + browser: true, + }), + commonjs() + ], + moduleName: 'XLSX', + format: 'iife' +}; diff --git a/demos/rollup/rollup.config.node.js b/demos/rollup/rollup.config.node.js new file mode 100644 index 0000000..0947f8f --- /dev/null +++ b/demos/rollup/rollup.config.node.js @@ -0,0 +1,15 @@ +/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ +import resolve from 'rollup-plugin-node-resolve'; +import commonjs from 'rollup-plugin-commonjs'; +export default { + entry: 'main.js', + dest: 'rollup.node.js', + plugins: [ + resolve({ + module: false, + browser: true, + }), + commonjs() + ], + format: 'cjs' +}; diff --git a/demos/rollup/xlsxworker.js b/demos/rollup/xlsxworker.js new file mode 100644 index 0000000..0035781 --- /dev/null +++ b/demos/rollup/xlsxworker.js @@ -0,0 +1,11 @@ +/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ +importScripts('rollup.min.js'); +postMessage({t:"ready"}); + +onmessage = function (oEvent) { + var v; + try { + v = XLSX.read(oEvent.data.d, {type: oEvent.data.b ? 'binary' : 'base64'}); + } catch(e) { postMessage({t:"e",d:e.stack||e}); } +postMessage({t:"xlsx", d:JSON.stringify(v)}); +}; diff --git a/demos/rollup/xlsxworker1.js b/demos/rollup/xlsxworker1.js new file mode 100644 index 0000000..e1b0c89 --- /dev/null +++ b/demos/rollup/xlsxworker1.js @@ -0,0 +1,26 @@ +/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ +importScripts('rollup.min.js'); +postMessage({t:"ready"}); + +function ab2str(data) { + var o = "", l = 0, w = 10240; + for(; l
diff --git a/docbits/82_util.md b/docbits/82_util.md index 04200d7..b619542 100644 --- a/docbits/82_util.md +++ b/docbits/82_util.md @@ -160,9 +160,8 @@ produces HTML output. The function takes an options argument: | Option Name | Default | Description | | :---------- | :------: | :-------------------------------------------------- | | editable | false | If true, set `contenteditable="true"` for every TD | -| header | | Override header (default `html body table`) | -| footer | | Override footer (default `/table /body /html`) | - +| header | | Override header (default `html body`) | +| footer | | Override footer (default `/body /html`) |
Examples (click to show)