forked from sheetjs/sheetjs
		
	rollup demo [ci skip]
This commit is contained in:
		
							parent
							
								
									81ab4f9b1f
								
							
						
					
					
						commit
						6a100b9085
					
				| @ -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 `<table>` tag | ||||
| 
 | ||||
| ## 0.10.2 (2017-05-16) | ||||
| 
 | ||||
| * Dates are converted to numbers by default (set `cellDates:true` to emit Dates) | ||||
|  | ||||
							
								
								
									
										11
									
								
								Makefile
									
									
									
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										11
									
								
								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 | ||||
|  | ||||
							
								
								
									
										11
									
								
								README.md
									
									
									
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										11
									
								
								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 \<html                                                  | | ||||
| | XML    | starts with \<                                                      | | ||||
| | HTML   | starts with `<html`                                                 | | ||||
| | XML    | starts with `<`                                                     | | ||||
| | DSV    | starts with `/sep=.$/`, separator is the specified character        | | ||||
| | TSV    | one of the first 1024 characters is a tab char `"\t"`               | | ||||
| | CSV    | one of the first 1024 characters is a comma char `","`              | | ||||
| | PRN    | (default)                                                           | | ||||
| 
 | ||||
| </details> | ||||
| 
 | ||||
| <details> | ||||
| @ -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`)             | | ||||
| 
 | ||||
| <details> | ||||
| 	<summary><b>Examples</b> (click to show)</summary> | ||||
|  | ||||
							
								
								
									
										12
									
								
								demos/README.md
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										12
									
								
								demos/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -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. | ||||
| 
 | ||||
							
								
								
									
										3
									
								
								demos/rollup/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										3
									
								
								demos/rollup/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | ||||
| rollup.js | ||||
| rollup.min.js | ||||
| rollup.node.js | ||||
							
								
								
									
										19
									
								
								demos/rollup/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										19
									
								
								demos/rollup/Makefile
									
									
									
									
									
										Normal file
									
								
							| @ -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 - | ||||
							
								
								
									
										26
									
								
								demos/rollup/README.md
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										26
									
								
								demos/rollup/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | ||||
| # 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 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() | ||||
| 	], | ||||
| 	/* ... */ | ||||
| }; | ||||
| ``` | ||||
| 
 | ||||
							
								
								
									
										3
									
								
								demos/rollup/main.js
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										3
									
								
								demos/rollup/main.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | ||||
| /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ | ||||
| import XLSX from 'xlsx'; | ||||
| export default XLSX; | ||||
							
								
								
									
										16
									
								
								demos/rollup/rollup.config.js
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										16
									
								
								demos/rollup/rollup.config.js
									
									
									
									
									
										Normal file
									
								
							| @ -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' | ||||
| }; | ||||
							
								
								
									
										15
									
								
								demos/rollup/rollup.config.node.js
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										15
									
								
								demos/rollup/rollup.config.node.js
									
									
									
									
									
										Normal file
									
								
							| @ -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' | ||||
| }; | ||||
							
								
								
									
										11
									
								
								demos/rollup/xlsxworker.js
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										11
									
								
								demos/rollup/xlsxworker.js
									
									
									
									
									
										Normal file
									
								
							| @ -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)}); | ||||
| }; | ||||
							
								
								
									
										26
									
								
								demos/rollup/xlsxworker1.js
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										26
									
								
								demos/rollup/xlsxworker1.js
									
									
									
									
									
										Normal file
									
								
							| @ -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<data.byteLength/w; ++l) o+=String.fromCharCode.apply(null,new Uint8Array(data.slice(l*w,l*w+w))); | ||||
| 	o+=String.fromCharCode.apply(null, new Uint8Array(data.slice(l*w))); | ||||
| 	return o; | ||||
| } | ||||
| 
 | ||||
| function s2ab(s) { | ||||
|   var b = new ArrayBuffer(s.length*2), v = new Uint16Array(b); | ||||
|   for (var i=0; i != s.length; ++i) v[i] = s.charCodeAt(i); | ||||
|   return [v, b]; | ||||
| } | ||||
| 
 | ||||
| onmessage = function (oEvent) { | ||||
|   var v; | ||||
|   try { | ||||
|     v = XLSX.read(ab2str(oEvent.data), {type: 'binary'}); | ||||
|   } catch(e) { postMessage({t:"e",d:e.stack}); } | ||||
|   var res = {t:"xlsx", d:JSON.stringify(v)}; | ||||
|   var r = s2ab(res.d)[1]; | ||||
| postMessage(r, [r]); | ||||
| }; | ||||
							
								
								
									
										26
									
								
								demos/rollup/xlsxworker2.js
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										26
									
								
								demos/rollup/xlsxworker2.js
									
									
									
									
									
										Normal file
									
								
							| @ -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<data.byteLength/w; ++l) o+=String.fromCharCode.apply(null,new Uint16Array(data.slice(l*w,l*w+w))); | ||||
| 	o+=String.fromCharCode.apply(null, new Uint16Array(data.slice(l*w))); | ||||
| 	return o; | ||||
| } | ||||
| 
 | ||||
| function s2ab(s) { | ||||
|   var b = new ArrayBuffer(s.length*2), v = new Uint16Array(b); | ||||
|   for (var i=0; i != s.length; ++i) v[i] = s.charCodeAt(i); | ||||
|   return [v, b]; | ||||
| } | ||||
| 
 | ||||
| onmessage = function (oEvent) { | ||||
|   var v; | ||||
|   try { | ||||
|     v = XLSX.read(ab2str(oEvent.data), {type: 'binary'}); | ||||
|   } catch(e) { postMessage({t:"e",d:e.stack}); } | ||||
|   var res = {t:"xlsx", d:JSON.stringify(v)}; | ||||
|   var r = s2ab(res.d)[1]; | ||||
| postMessage(r, [r]); | ||||
| }; | ||||
| @ -31,6 +31,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/) | ||||
| 
 | ||||
|  | ||||
| @ -82,12 +82,13 @@ Plaintext format guessing follows the priority order: | ||||
| 
 | ||||
| | Format | Test                                                                | | ||||
| |:-------|:--------------------------------------------------------------------| | ||||
| | HTML   | starts with \<html                                                  | | ||||
| | XML    | starts with \<                                                      | | ||||
| | HTML   | starts with `<html`                                                 | | ||||
| | XML    | starts with `<`                                                     | | ||||
| | DSV    | starts with `/sep=.$/`, separator is the specified character        | | ||||
| | TSV    | one of the first 1024 characters is a tab char `"\t"`               | | ||||
| | CSV    | one of the first 1024 characters is a comma char `","`              | | ||||
| | PRN    | (default)                                                           | | ||||
| 
 | ||||
| </details> | ||||
| 
 | ||||
| <details> | ||||
|  | ||||
| @ -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`)             | | ||||
| 
 | ||||
| <details> | ||||
| 	<summary><b>Examples</b> (click to show)</summary> | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user