Skip to content

Commit

Permalink
Dual package: bundled ESM file (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurgm authored Oct 27, 2024
2 parents 3a41263 + 3b1cd28 commit 99a7c56
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 23 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ const Polygons = Kage.Polygons;
const Buhin = Kage.Buhin;
```

Bundled ESM file is also available:
```html
<script type="module">
import { Kage, Polygons } from "https://unpkg.com/@kurgm/kage-engine@0.6.0/dist/kage.min.mjs";
// Your code goes here
</script>
```

### Drawing glyphs

*See [docs](docs/classes/Kage.md) for more detailed API documentations (of development version).*
Expand Down
64 changes: 41 additions & 23 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,46 @@ const banner = `/*! kage.js v${pkg.version}
*/`;

/** @type {import("rollup").RollupOptions} */
const options = {
input: "src/browser.ts",
output: [
{
file: "dist/kage.js",
format: "iife",
name: "Kage",
exports: "default",
banner,
},
{
file: "dist/kage.min.js",
format: "iife",
name: "Kage",
exports: "default",
banner,
plugins: [terser()],
},
],
plugins: [
typescript({}),
],
};
const options = [
{
input: "src/browser.ts",
output: [
{
file: "dist/kage.js",
format: "iife",
name: "Kage",
exports: "default",
banner,
},
{
file: "dist/kage.min.js",
format: "iife",
name: "Kage",
exports: "default",
banner,
plugins: [terser()],
},
],
plugins: [
typescript({}),
],
},
{
input: "src/index.ts",
output: [
{
file: "dist/kage.min.mjs",
format: "es",
banner,
plugins: [terser()],
},
],
plugins: [
typescript({
target: "es6",
}),
],
},
];

export default options;

0 comments on commit 99a7c56

Please sign in to comment.