Skip to content

Commit

Permalink
Adopting a dual dist/ bundled UMD and bundled ES Module strategy.
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed May 14, 2018
1 parent 40919ec commit ca71bc4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 12 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.2",
"license": "ISC",
"main": "src/index",
"module": "dist/notebook-stdlib.js",
"author": {
"name": "Observable, Inc."
},
Expand All @@ -29,6 +30,7 @@
"jsdom": "^11.6.2",
"rollup": "^0.52.0",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-uglify": "^3.0.0",
"tape": "^4.9.0",
"tape-await": "0.1.0"
}
Expand Down
39 changes: 27 additions & 12 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
import node from "rollup-plugin-node-resolve";
import uglify from "rollup-plugin-uglify";

export default {
input: "src/index.js",
plugins: [
node()
],
output: {
extend: true,
banner: `// @observablehq/notebook-stdlib Copyright ${(new Date).getFullYear()} Observable, Inc.`,
file: "dist/notebook-stdlib.js",
format: "umd",
name: "Observable"
}
const defaultOutput = {
banner: `// @observablehq/notebook-stdlib Copyright ${(new Date).getFullYear()} Observable, Inc.`,
};

function config(output) {
return {
input: "src/index.js",
plugins: [
node(),
uglify()
],
output: Object.assign(output, defaultOutput)
};
}

export default [
config({
format: "es",
file: "dist/notebook-stdlib.js"
}),
config({
format: "umd",
extend: true,
name: "Observable",
file: "dist/notebook-stdlib.umd.js"
})
];
21 changes: 21 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ combined-stream@^1.0.5, combined-stream@~1.0.5:
dependencies:
delayed-stream "~1.0.0"

commander@~2.13.0:
version "2.13.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c"

[email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
Expand Down Expand Up @@ -1138,6 +1142,12 @@ rollup-plugin-node-resolve@^3.0.0:
is-module "^1.0.0"
resolve "^1.1.6"

rollup-plugin-uglify@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-uglify/-/rollup-plugin-uglify-3.0.0.tgz#a34eca24617709c6bf1778e9653baafa06099b86"
dependencies:
uglify-es "^3.3.7"

rollup@^0.52.0:
version "0.52.3"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.52.3.tgz#020d99fffe9619351e47b3894fd397c26f5e1bf6"
Expand Down Expand Up @@ -1200,6 +1210,10 @@ source-map@~0.5.6:
version "0.5.7"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"

source-map@~0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"

sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
Expand Down Expand Up @@ -1360,6 +1374,13 @@ typedarray@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"

uglify-es@^3.3.7:
version "3.3.9"
resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.9.tgz#0c1c4f0700bed8dbc124cdb304d2592ca203e677"
dependencies:
commander "~2.13.0"
source-map "~0.6.1"

ultron@~1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.1.1.tgz#9fe1536a10a664a65266a1e3ccf85fd36302bc9c"
Expand Down

0 comments on commit ca71bc4

Please sign in to comment.