include worker
This commit is contained in:
parent
f485a415d1
commit
83ef26ead1
3 changed files with 73 additions and 49 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -66,3 +66,5 @@ typings/
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
|
||||||
1.*
|
1.*
|
||||||
|
|
||||||
|
dist/cache
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
"@types/pdfkit": "^0.10.4",
|
"@types/pdfkit": "^0.10.4",
|
||||||
"rollup": "^1.26.3",
|
"rollup": "^1.26.3",
|
||||||
"rollup-plugin-commonjs": "^10.1.0",
|
"rollup-plugin-commonjs": "^10.1.0",
|
||||||
|
"rollup-plugin-multi-entry": "^2.1.0",
|
||||||
"rollup-plugin-node-builtins": "^2.1.2",
|
"rollup-plugin-node-builtins": "^2.1.2",
|
||||||
"rollup-plugin-node-globals": "^1.4.0",
|
"rollup-plugin-node-globals": "^1.4.0",
|
||||||
"rollup-plugin-node-resolve": "^5.2.0",
|
"rollup-plugin-node-resolve": "^5.2.0",
|
||||||
|
|
119
rollup.config.js
119
rollup.config.js
|
@ -5,6 +5,7 @@ import builtins from "rollup-plugin-node-builtins"
|
||||||
import nodeGlobals from "rollup-plugin-node-globals"
|
import nodeGlobals from "rollup-plugin-node-globals"
|
||||||
import json from "@rollup/plugin-json"
|
import json from "@rollup/plugin-json"
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
|
import multiEntry from "rollup-plugin-multi-entry"
|
||||||
|
|
||||||
const getBannerText = () => {
|
const getBannerText = () => {
|
||||||
const packageJson = JSON.parse(fs.readFileSync("./package.json", "utf-8"))
|
const packageJson = JSON.parse(fs.readFileSync("./package.json", "utf-8"))
|
||||||
|
@ -14,54 +15,74 @@ const getBannerText = () => {
|
||||||
return bannerText
|
return bannerText
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
const plugins = [
|
||||||
input: "src/main.ts",
|
typescript({
|
||||||
output: {
|
target: "ES6",
|
||||||
file: "dist/main.js",
|
sourceMap: false,
|
||||||
format: "iife",
|
allowJs: true,
|
||||||
sourcemap: false,
|
lib: [
|
||||||
banner: getBannerText,
|
"ES6",
|
||||||
// intro: "const global = typeof window === 'object' && window.window === window ? window : typeof self === 'object' && self.self === self ? self : typeof commonjsGlobal === 'object' && commonjsGlobal.global === commonjsGlobal ? commonjsGlobal : void 0"
|
"dom"
|
||||||
},
|
],
|
||||||
plugins: [
|
}),
|
||||||
typescript({
|
resolve({
|
||||||
target: "ES6",
|
preferBuiltins: true,
|
||||||
sourceMap: false,
|
jsnext: true,
|
||||||
allowJs: true,
|
extensions: [".js", ".ts"]
|
||||||
lib: [
|
}),
|
||||||
"ES6",
|
commonjs({
|
||||||
"dom"
|
extensions: [".js", ".ts"]
|
||||||
],
|
}),
|
||||||
}),
|
json(),
|
||||||
resolve({
|
builtins(),
|
||||||
preferBuiltins: true,
|
nodeGlobals({
|
||||||
jsnext: true,
|
dirname: false,
|
||||||
extensions: [".js", ".ts"]
|
filename: false,
|
||||||
}),
|
baseDir: false,
|
||||||
commonjs({
|
}),
|
||||||
extensions: [".js", ".ts"]
|
{
|
||||||
}),
|
/**
|
||||||
json(),
|
* remove tslib license comments
|
||||||
builtins(),
|
* @param {string} code
|
||||||
nodeGlobals({
|
* @param {string} id
|
||||||
dirname: false,
|
*/
|
||||||
filename: false,
|
transform(code, id) {
|
||||||
baseDir: false,
|
if (id.includes("tslib")) {
|
||||||
}),
|
code = code.split(/\r?\n/g).slice(15).join("\n")
|
||||||
{
|
|
||||||
/**
|
|
||||||
* remove tslib license comments
|
|
||||||
* @param {string} code
|
|
||||||
* @param {string} id
|
|
||||||
*/
|
|
||||||
transform(code, id) {
|
|
||||||
if (id.includes("tslib")) {
|
|
||||||
code = code.split(/\r?\n/g).slice(15).join("\n")
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
code
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return {
|
||||||
|
code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
input: "src/worker.ts",
|
||||||
|
output: {
|
||||||
|
file: "dist/cache/worker.js",
|
||||||
|
format: "iife",
|
||||||
|
name: "PDFWorker",
|
||||||
|
sourcemap: false,
|
||||||
},
|
},
|
||||||
]
|
plugins,
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
input: [
|
||||||
|
"dist/cache/worker.js",
|
||||||
|
"src/main.ts",
|
||||||
|
],
|
||||||
|
output: {
|
||||||
|
file: "dist/main.js",
|
||||||
|
format: "iife",
|
||||||
|
sourcemap: false,
|
||||||
|
banner: getBannerText,
|
||||||
|
// intro: "const global = typeof window === 'object' && window.window === window ? window : typeof self === 'object' && self.self === self ? self : typeof commonjsGlobal === 'object' && commonjsGlobal.global === commonjsGlobal ? commonjsGlobal : void 0"
|
||||||
|
},
|
||||||
|
plugins:[
|
||||||
|
...plugins,
|
||||||
|
multiEntry({ exports: false }),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
Loading…
Reference in a new issue