Skip to content

Commit

Permalink
feat: smaller bundle and remove es5 builds since they are not really …
Browse files Browse the repository at this point in the history
…es5 builds anyway (#1114)
  • Loading branch information
domoritz authored Apr 20, 2023
1 parent d7b0aec commit d4133c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"files": [
"src",
"build",
"build-es5",
"patches"
],
"devDependencies": {
Expand Down Expand Up @@ -85,7 +84,7 @@
"prebuild": "yarn clean && yarn build:style",
"build": "rollup -c",
"build:style": "./build-style.sh",
"clean": "del-cli build build-es5 src/style.ts",
"clean": "del-cli build src/style.ts",
"prepublishOnly": "yarn clean && yarn build",
"preversion": "yarn lint && yarn test",
"serve": "browser-sync start --directory -s -f build *.html",
Expand Down
23 changes: 8 additions & 15 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,27 @@ const plugins = (browserslist, declaration) => [
declarationMap: declaration,
}),
transpiler: "babel",
babelConfig: { presets: ["@babel/preset-env"] },
browserslist,
}),
bundleSize(),
];

const outputs = [
export default [
{
input: "src/embed.ts",
output: {
file: "build/vega-embed.module.js",
format: "esm",
sourcemap: true,
},
plugins: plugins(undefined, true),
plugins: plugins(false, true),
external: [...Object.keys(pkg.dependencies), ...Object.keys(pkg.peerDependencies)],
},
];

for (const build of ["es5", "es6"]) {
const buildFolder = build === "es5" ? "build-es5" : "build";
outputs.push({
{
input: "src/index.ts",
output: [
{
file: `${buildFolder}/vega-embed.js`,
file: "build/vega-embed.js",
format: "umd",
sourcemap: true,
name: "vegaEmbed",
Expand All @@ -53,7 +48,7 @@ for (const build of ["es5", "es6"]) {
},
},
{
file: `${buildFolder}/vega-embed.min.js`,
file: "build/vega-embed.min.js",
format: "umd", // cannot do iife because rollup generates code that expects Vega-Lite to be present
sourcemap: true,
name: "vegaEmbed",
Expand All @@ -64,9 +59,7 @@ for (const build of ["es5", "es6"]) {
plugins: [terser()],
},
],
plugins: plugins(build === "es5" ? "defaults" : "defaults and not IE 11", false),
plugins: plugins("defaults", false),
external: ["vega", "vega-lite"],
});
}

export default outputs;
},
];

0 comments on commit d4133c6

Please sign in to comment.