Skip to content

Commit

Permalink
Add output file browser/float16.mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
petamoriken committed Aug 12, 2021
1 parent 5ed00f7 commit b59a4f7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ const { Float16Array, getFloat16, setFloat16, hfround } = require("@petamoriken/

### Browser

Copy `browser/float16.js` file to your project directory.
Serve `browser/float16.mjs` / `browser/float16.js` files from your Web server as JavaScript Content-Type.

```html
<script type="module">
import { Float16Array, getFloat16, setFloat16, hfround } from "DEST/TO/float16.mjs";
</script>
```

```html
<script src="DEST/TO/float16.js"></script>
Expand All @@ -63,6 +69,12 @@ Copy `browser/float16.js` file to your project directory.

Or use jsDelivr CDN.

```html
<script type="module">
import { Float16Array, getFloat16, setFloat16, hfround } from "https://cdn.jsdelivr.net/npm/@petamoriken/float16/browser/float16.mjs/+esm";
</script>
```

```html
<script src="https://cdn.jsdelivr.net/npm/@petamoriken/float16/browser/float16.min.js"></script>
<script>
Expand Down
9 changes: 6 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ const banner = `<%= pkg.name %> ${ version } | <%= pkg.license %> License - <%=

export default {
input: "src/index.mjs",
output: {
name: "float16",
output: [{
file: "browser/float16.js",
format: "iife",
},
name: "float16",
}, {
file: "browser/float16.mjs",
format: "es",
}],
plugins: [
$.nodeResolve({ browser: true }),
$.babel({
Expand Down

0 comments on commit b59a4f7

Please sign in to comment.