Skip to content

Commit

Permalink
Provide bundled module and custom element
Browse files Browse the repository at this point in the history
  • Loading branch information
runarberg committed Jan 12, 2020
1 parent 19297c9 commit 501b300
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.nyc_output/
coverage/
demo/
docs/
test/
src/**/*.test.js
test/
5 changes: 4 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
<link rel="shortcut" type="image/x-icon" href="favicon.ico" />
<link rel="stylesheet" href="main.css" />

<script src="../src/custom-element.mjs" type="module"></script>
<script
src="https://unpkg.com/mathup/target/module/math-up-element.min.mjs"
type="module"
></script>
<script src="./use-example-element.mjs" type="module"></script>
<script src="./main.mjs" type="module" defer></script>
</head>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"license": "MIT",
"author": "Rúnar Berg Baugsson Sigríðarson <runarberg@zoho.com>",
"main": "target/node/mathup.cjs",
"module": "src/index.mjs",
"module": "target/module/mathup.mjs",
"bin": {
"mathup": "bin/mathup.js"
},
Expand Down
46 changes: 45 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ const defaultConfig = {
format: "cjs",
sourcemap: true,
},
{
file: `target/module/${NAME}.mjs`,
format: "module",
sourcemap: true,
},
{
file: `target/module/${NAME}.min.mjs`,
format: "module",
plugins: [terser()],
},
{
file: `target/browser/${NAME}.iife.js`,
format: "iife",
Expand All @@ -51,10 +61,44 @@ const defaultConfig = {
],
};

const customElementConfig = {
input: "src/custom-element.mjs",
output: [
{
file: `target/module/math-up-element.mjs`,
format: "module",
sourcemap: true,
},
{
file: `target/module/math-up-element.min.mjs`,
format: "module",
plugins: [terser()],
},
{
file: `target/browser/math-up-element.iife.js`,
format: "iife",
name: "MathUpElement",
banner: `/*! ${NAME} v${VERSION} | (c) 2015-${YEAR} (${LICENSE}) | ${HOMEPAGE} */`,
sourcemap: true,
},
{
file: `target/browser/math-up-element.iife.min.js`,
format: "iife",
name: "MathUpElement",
plugins: [terser()],
},
],
plugins: [
babel({
runtimeHelpers: true,
}),
],
};

export default function rollup(args) {
if (args.configDeps === true) {
return dependenciesConfig;
}

return [dependenciesConfig, defaultConfig];
return [dependenciesConfig, defaultConfig, customElementConfig];
}

0 comments on commit 501b300

Please sign in to comment.