Skip to content

Commit 722a0b2

Browse files
committed
fix(build): resolves umd mime issue
1 parent daadc51 commit 722a0b2

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
<body>
1111
<h1>Open your browser console to see the result!</h1>
1212

13-
<script type="module">
14-
import parseAttrs from "https://cdn.jsdelivr.net/npm/attributes-parser/+esm"
15-
13+
<script src="https://cdn.jsdelivr.net/npm/moo/moo.min.js"></script>
14+
<script src="https://cdn.jsdelivr.net/npm/json-loose/dist/index.umd.js"></script>
15+
<script src="https://cdn.jsdelivr.net/npm/attributes-parser/dist/index.umd.js"></script>
16+
<script>
1617
const attr = `id="my-id" class='my-class' num=3.14 numNeg=-3.14 data-num="3.14" options=\'{"key": "value", "array": [1, 2, 3]}\' data-list="[1, 2, 3]" punc="a=b,c,d,e" checked=false checked=false data-checked="false" disabled`
1718
const parsedAttr = parseAttrs(attr)
1819

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
"markdown"
2727
],
2828
"type": "module",
29-
"main": "dist/index.cjs",
30-
"browser": "dist/index.umd.cjs",
31-
"module": "dist/index.js",
29+
"main": "dist/index.cjs.js",
30+
"browser": "dist/index.umd.js",
31+
"module": "dist/index.es.js",
3232
"types": "dist/index.d.ts",
3333
"exports": {
3434
".": {
35-
"import": "./dist/index.js",
36-
"require": "./dist/index.cjs",
35+
"import": "./dist/index.es.js",
36+
"require": "./dist/index.cjs.js",
3737
"types": "./dist/index.d.ts"
3838
}
3939
},

readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ yarn add attributes-parser
1414

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

17-
```html
18-
<script type="module">
19-
import parseAttrs from 'https://cdn.jsdelivr.net/npm/attributes-parser/+esm'
20-
</script>
21-
```
17+
| Type | URL |
18+
| :--- | :----------------------------------------------------------------- |
19+
| ESM | `https://cdn.jsdelivr.net/npm/attributes-parser/+esm` |
20+
| CJS | `https://cdn.jsdelivr.net/npm/attributes-parser/dist/index.cjs.js` |
21+
| UMD | `https://cdn.jsdelivr.net/npm/attributes-parser/dist/index.umd.js` |
2222

2323
## Usage
2424

vite.config.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
/// <reference types="vitest" />
2-
import { resolve } from 'node:path'
32
import { defineConfig } from 'vite'
43

54
export default defineConfig({
65
build: {
76
lib: {
8-
entry: resolve(__dirname, 'src/index.ts'),
7+
entry: 'src/index.ts',
98
name: 'parseAttrs',
109
formats: ['es', 'cjs', 'umd'],
1110
fileName: 'index'
1211
},
1312
rollupOptions: {
1413
external: ['json-loose', 'moo'],
15-
output: { globals: { 'json-loose': 'jsonLoose', moo: 'moo' } }
14+
output: {
15+
globals: { 'json-loose': 'jsonLoose', moo: 'moo' },
16+
entryFileNames: '[name].[format].js'
17+
}
1618
}
1719
},
1820
test: {

0 commit comments

Comments
 (0)