Skip to content

Commit 501b300

Browse files
committed
Provide bundled module and custom element
1 parent 19297c9 commit 501b300

4 files changed

Lines changed: 53 additions & 4 deletions

File tree

.npmignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
.nyc_output/
2+
coverage/
13
demo/
24
docs/
3-
test/
45
src/**/*.test.js
6+
test/

docs/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
<link rel="shortcut" type="image/x-icon" href="favicon.ico" />
99
<link rel="stylesheet" href="main.css" />
1010

11-
<script src="../src/custom-element.mjs" type="module"></script>
11+
<script
12+
src="https://unpkg.com/mathup/target/module/math-up-element.min.mjs"
13+
type="module"
14+
></script>
1215
<script src="./use-example-element.mjs" type="module"></script>
1316
<script src="./main.mjs" type="module" defer></script>
1417
</head>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"license": "MIT",
1414
"author": "Rúnar Berg Baugsson Sigríðarson <runarberg@zoho.com>",
1515
"main": "target/node/mathup.cjs",
16-
"module": "src/index.mjs",
16+
"module": "target/module/mathup.mjs",
1717
"bin": {
1818
"mathup": "bin/mathup.js"
1919
},

rollup.config.js

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ const defaultConfig = {
3030
format: "cjs",
3131
sourcemap: true,
3232
},
33+
{
34+
file: `target/module/${NAME}.mjs`,
35+
format: "module",
36+
sourcemap: true,
37+
},
38+
{
39+
file: `target/module/${NAME}.min.mjs`,
40+
format: "module",
41+
plugins: [terser()],
42+
},
3343
{
3444
file: `target/browser/${NAME}.iife.js`,
3545
format: "iife",
@@ -51,10 +61,44 @@ const defaultConfig = {
5161
],
5262
};
5363

64+
const customElementConfig = {
65+
input: "src/custom-element.mjs",
66+
output: [
67+
{
68+
file: `target/module/math-up-element.mjs`,
69+
format: "module",
70+
sourcemap: true,
71+
},
72+
{
73+
file: `target/module/math-up-element.min.mjs`,
74+
format: "module",
75+
plugins: [terser()],
76+
},
77+
{
78+
file: `target/browser/math-up-element.iife.js`,
79+
format: "iife",
80+
name: "MathUpElement",
81+
banner: `/*! ${NAME} v${VERSION} | (c) 2015-${YEAR} (${LICENSE}) | ${HOMEPAGE} */`,
82+
sourcemap: true,
83+
},
84+
{
85+
file: `target/browser/math-up-element.iife.min.js`,
86+
format: "iife",
87+
name: "MathUpElement",
88+
plugins: [terser()],
89+
},
90+
],
91+
plugins: [
92+
babel({
93+
runtimeHelpers: true,
94+
}),
95+
],
96+
};
97+
5498
export default function rollup(args) {
5599
if (args.configDeps === true) {
56100
return dependenciesConfig;
57101
}
58102

59-
return [dependenciesConfig, defaultConfig];
103+
return [dependenciesConfig, defaultConfig, customElementConfig];
60104
}

0 commit comments

Comments
 (0)