From 949c02f4e60b61b5e793b756481dfe3aab83dd3d Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Tue, 3 Aug 2021 11:09:00 +0100 Subject: [PATCH] feat: Include individual bundles Remove test bundle Signed-off-by: Gordon Smith --- package.json | 6 ++-- rollup.config.js | 72 ++++++++++++++---------------------------------- 2 files changed, 25 insertions(+), 53 deletions(-) diff --git a/package.json b/package.json index 91685e3c..989f3804 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,9 @@ "unpkg": "dist/index.min.js", "types": "types/index.d.ts", "files": [ - "dist/*", + "dist/index*.*", + "dist/expat*.*", + "dist/graphviz*.*", "types/*", "src/*.css" ], @@ -102,4 +104,4 @@ "url": "https://github.com/hpcc-systems/hpcc-js-wasm/issues" }, "homepage": "https://github.com/hpcc-systems/hpcc-js-wasm#readme" -} \ No newline at end of file +} diff --git a/rollup.config.js b/rollup.config.js index e8b0e95f..d5c66016 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -6,16 +6,15 @@ import replace from "@rollup/plugin-replace"; // eslint-disable-next-line @typescript-eslint/no-var-requires const pkg = require("./package.json"); - -export default [{ - input: "lib-es6/index", +const browserTpl = (input, umdOutput, esOutput) => ({ + input: input, output: [{ - file: pkg.browser, + file: umdOutput, format: "umd", sourcemap: true, name: pkg.name }, { - file: pkg.module + ".js", + file: esOutput, format: "es", sourcemap: true }], @@ -27,16 +26,17 @@ export default [{ commonjs({}), sourcemaps() ] -}, { - input: "lib-es6/index", +}); +const nodeTpl = (input, cjsOutput, esOutput) => ({ + input: input, external: ["fs", "crypto", "path"], output: [{ - file: pkg.main, + file: cjsOutput, format: "cjs", sourcemap: true, name: pkg.name }, { - file: pkg["module-node"] + ".js", + file: esOutput, format: "es", sourcemap: true }], @@ -56,45 +56,15 @@ export default [{ commonjs({}), sourcemaps() ] -}, { - input: "lib-es6/__tests__/index", - output: { - file: "dist/test.js", - format: "umd", - sourcemap: true, - name: pkg.name - }, - plugins: [ - alias({}), - nodeResolve({ - preferBuiltins: true - }), - commonjs({}), - sourcemaps() - ] -}, { - input: "lib-es6/__tests__/index", - external: ["fs", "crypto", "path"], - output: { - file: "dist/test.node.js", - format: "commonjs", - sourcemap: true, - name: pkg.name - }, - plugins: [ - alias({ - entries: [ - { find: "../build/graphviz/graphvizlib/graphvizlib", replacement: "../build/graphviz/graphvizlib/graphvizlib.node" }, - { find: "../build/expat/expatlib/expatlib", replacement: "../build/expat/expatlib/expatlib.node" } - ] - }), - replace({ - ".node.wasm": ".wasm" - }), - nodeResolve({ - preferBuiltins: true - }), - commonjs({}), - sourcemaps() - ] -}]; \ No newline at end of file +}); + +export default [ + browserTpl("lib-es6/index", pkg.browser, pkg.module + ".js"), + browserTpl("lib-es6/graphviz", "dist/graphviz.js", "dist/graphviz.es6.js"), + browserTpl("lib-es6/expat", "dist/expat.js", "dist/expat.es6.js"), + nodeTpl("lib-es6/index", pkg.main, pkg["module-node"] + ".js"), + nodeTpl("lib-es6/graphviz", "dist/graphviz.node.js", "dist/graphviz.node.es6.js"), + nodeTpl("lib-es6/expat", "dist/expat.node.js", "dist/expat.node.es6.js"), + browserTpl("lib-es6/__tests__/index", "dist/test.js", "dist/test.es6.js"), + nodeTpl("lib-es6/__tests__/index", "dist/test.node.js", "dist/test.node.es6.js") +]; \ No newline at end of file