Skip to content

Commit 8116a47

Browse files
Switch UMD to .js
Fixes #135 Co-authored-by: Jake Archibald <jaffathecake@gmail.com>
1 parent aff17a6 commit 8116a47

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ Legacy builds:
4545

4646
- `idb-keyval/dist/compat.js` EcmaScript module, transpiled for older browsers.
4747
- `idb-keyval/dist/compat.cjs` CommonJS module, transpiled for older browsers.
48-
- `idb-keyval/dist/umd.cjs` UMD module, also transpiled for older browsers.
48+
- `idb-keyval/dist/umd.js` UMD module, also transpiled for older browsers.
4949

5050
These built versions are also available on jsDelivr, e.g.:
5151

5252
```html
53-
<script src="https://cdn.jsdelivr.net/npm/idb-keyval@6/dist/umd.cjs"></script>
53+
<script src="https://cdn.jsdelivr.net/npm/idb-keyval@6/dist/umd.js"></script>
5454
<!-- Or in modern browsers: -->
5555
<script type="module">
5656
import { get, set } from 'https://cdn.jsdelivr.net/npm/idb-keyval@6/+esm';

‎rollup.config.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export default async function ({ watch }) {
135135
plugins: [simpleTS('src', { noBuild: true }), commonjs(), resolve()],
136136
output: [
137137
{
138-
file: 'dist/umd.cjs',
138+
file: 'dist/umd.js',
139139
format: 'umd',
140140
name: 'idbKeyval',
141141
plugins: [
@@ -144,6 +144,18 @@ export default async function ({ watch }) {
144144
terser({
145145
compress: { ecma: 5 },
146146
}),
147+
{
148+
// jsDelivr does not serve the correct mimetype for .cjs files.
149+
// However, the cjs version is retained for backwards compatibility.
150+
// TODO: Remove this in the next major version.
151+
generateBundle(_, bundle) {
152+
this.emitFile({
153+
type: 'asset',
154+
fileName: 'umd.cjs',
155+
source: bundle['umd.js'].code,
156+
});
157+
},
158+
},
147159
],
148160
},
149161
],

0 commit comments

Comments
 (0)