Skip to content

Commit

Permalink
fix(build): resolves umd mime issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bent10 committed Oct 20, 2023
1 parent 70014e8 commit 6a3e632
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<body>
<h1>Open your browser console to see the result!</h1>

<script type="module">
import jsonLoose from "https://cdn.jsdelivr.net/npm/json-loose/+esm"

<script src="https://cdn.jsdelivr.net/npm/moo/moo.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/json-loose/dist/index.umd.js"></script>
<script>
const input = `[
"foo",
true,
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
"stringify"
],
"type": "module",
"main": "./dist/index.cjs",
"browser": "./dist/index.umd.cjs",
"module": "./dist/index.js",
"main": "./dist/index.cjs.js",
"browser": "./dist/index.umd.js",
"module": "./dist/index.es.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"import": "./dist/index.es.js",
"require": "./dist/index.cjs.js",
"types": "./dist/index.d.ts"
}
},
Expand Down
10 changes: 5 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ yarn add json-loose

Alternatively, you can also include this module directly in your HTML file from [CDN](https://www.jsdelivr.com/package/npm/json-loose?tab=files&path=dist):

```html
<script type="module">
import jsonLoose from 'https://cdn.jsdelivr.net/npm/json-loose/+esm'
</script>
```
| Type | URL |
| :--- | :---------------------------------------------------------- |
| ESM | `https://cdn.jsdelivr.net/npm/json-loose/+esm` |
| CJS | `https://cdn.jsdelivr.net/npm/json-loose/dist/index.cjs.js` |
| UMD | `https://cdn.jsdelivr.net/npm/json-loose/dist/index.umd.js` |

## Usage

Expand Down
5 changes: 4 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export default defineConfig({
},
rollupOptions: {
external: ['moo'],
output: { globals: { moo: 'moo' } }
output: {
globals: { moo: 'moo' },
entryFileNames: '[name].[format].js'
}
}
},
test: {
Expand Down

0 comments on commit 6a3e632

Please sign in to comment.