Skip to content

Commit

Permalink
Merge pull request #2663 from bwl21/bwl21/worker-support
Browse files Browse the repository at this point in the history
see #2382 add a build type for use in a webworker
  • Loading branch information
Uzlopak authored Feb 10, 2020
2 parents 136695d + 62ff192 commit 94064a9
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 18 deletions.
25 changes: 18 additions & 7 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,23 @@ const args = process.argv
}, {});

switch (args.type) {
case "worker":
bundle({
type: args.type,
distFolder: "dist",
config: "./build.worker.conf.js",
context: "global",
minify: args.minify || true,
format: "cjs",
filename: "jspdf.worker"
});
break;
case "node":
bundle({
type: args.type,
distFolder: 'dist',
config: './build.node.conf.js',
context: 'global',
distFolder: "dist",
config: "./build.node.conf.js",
context: "global",
minify: args.minify || true,
format: "cjs",
filename: "jspdf.node"
Expand All @@ -32,8 +43,8 @@ switch (args.type) {
default:
bundle({
type: args.type,
distFolder: 'dist',
config: './build.browser.conf.js',
distFolder: "dist",
config: "./build.browser.conf.js",
minify: args.minify || true,
format: "umd",
context: "window",
Expand All @@ -50,8 +61,8 @@ function bundle(options) {
options.filename +
".debug.js"
);
const plugins = options.type === 'node' ?
rollupConfig.nodePlugins : rollupConfig.plugins;
const plugins =
options.type === "node" ? rollupConfig.nodePlugins : rollupConfig.plugins;
rollup
.rollup({
input: options.config,
Expand Down
45 changes: 45 additions & 0 deletions build.worker.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import './src/license.js';
import './src/worker.polyfill.js';
import './src/jspdf.js';

//import './src/modules/acroform';
import './src/modules/addimage';
import './src/modules/annotations';
import './src/modules/arabic';
import './src/modules/autoprint';
import './src/modules/canvas';
import './src/modules/cell';
import './src/modules/context2d';
import './src/modules/filters';
import './src/modules/fileloading';
import './src/modules/html';
import './src/modules/javascript';
import './src/modules/outline';
import './src/modules/jpeg_support';
import './src/modules/png_support';
import './src/modules/gif_support';
import './src/modules/bmp_support';
import './src/modules/webp_support';
import './src/modules/setlanguage';
import './src/modules/split_text_to_size';
import './src/modules/standard_fonts_metrics';
//import './src/modules/ttfsupport';
import './src/modules/svg';
import './src/modules/total_pages';
import './src/modules/viewerpreferences';
import './src/modules/xmp_metadata';
import './src/modules/utf8';
//import './src/modules/vfs';

//import './src/node.js';

import './src/libs/adler32cs.js';
import './src/libs/bidiEngine.js';
import './src/libs/JPEGEncoder.js';
import './src/libs/BMPDecoder.js';
import './src/libs/WebPDecoder.js';
import './src/libs/Deflater.js';
import './src/libs/rgbcolor.js';
import './src/libs/ttffont.js';
import './src/libs/png.js';
import './src/libs/zlib.js';
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"dist/jspdf.min.js",
"dist/jspdf.node.debug.js",
"dist/jspdf.node.min.js",
"dist/jspdf.worker.debug.js",
"dist/jspdf.worker.min.js",
"types/index.d.ts",
"README.md",
"makeFonts.js"
Expand All @@ -30,32 +32,32 @@
"atob": "^2.1.2",
"btoa": "^1.2.1",
"canvg": "1.5.3",
"es6-promise": "^4.2.6",
"es6-promise": "^4.2.8",
"file-saver": "2.0.1",
"html2canvas": "^1.0.0-rc.1",
"html2canvas": "^1.0.0-rc.5",
"omggif": "1.0.9",
"stackblur-canvas": "2.2.0"
},
"devDependencies": {
"@babel/core": "^7.4.3",
"@babel/core": "^7.8.4",
"@babel/plugin-external-helpers": "7.2.0",
"@babel/preset-env": "^7.4.3",
"acorn": "^6.1.1",
"@babel/preset-env": "^7.8.4",
"acorn": "^6.4.0",
"babel-plugin-rewire-exports": "1.0.1",
"codeclimate-test-reporter": "0.5.1",
"diff": "4.0.1",
"docdash": "1.1.0",
"eslint": "^5.16.0",
"folder-delete": "1.0.4",
"gulp-babel": "^8.0.0",
"inquirer": "^6.2.2",
"jasmine": "^3.4.0",
"inquirer": "^6.5.2",
"jasmine": "^3.5.0",
"jasmine-core": "3.4.0",
"jasmine-expect": "^4.0.1",
"js-yaml": "3.13.1",
"jsdoc": "3.6.0",
"jsdoc": "^3.6.3",
"karma": "4.0.1",
"karma-babel-preprocessor": "^8.0.0",
"karma-babel-preprocessor": "^8.0.1",
"karma-chrome-launcher": "2.2.0",
"karma-coverage": "1.1.2",
"karma-firefox-launcher": "1.1.0",
Expand All @@ -67,7 +69,7 @@
"karma-verbose-reporter": "0.0.6",
"local-web-server": "2.6.1",
"markdown": "0.5.0",
"prettier": "^1.13.7",
"prettier": "^1.19.1",
"promise-polyfill": "8.1.1",
"rollup": "1.12.1",
"rollup-plugin-babel": "4.3.2",
Expand All @@ -78,9 +80,10 @@
},
"scripts": {
"start": "ws",
"build": "node build.js && node build.js type=node",
"build": "node build.js && node build.js type=node && node build.js type=worker",
"build-browser": "node build",
"build-node": "node build type=node",
"build-worker": "node build type=worker",
"version": "npm run build && git add -A dist",
"test": "./node_modules/.bin/karma start karma.saucelabs.conf.js --single-run --verbose && for a in coverage/*; do codeclimate-test-reporter < \"$a/lcov.info\"; break; done",
"test-local": "./node_modules/.bin/karma start karma.conf.js",
Expand Down
6 changes: 6 additions & 0 deletions src/worker.polyfill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* polyfill to make jspdf work in a webworker
* @type {{}}
*/

window = {};

0 comments on commit 94064a9

Please sign in to comment.