Skip to content

Commit c5c142e

Browse files
committed
umd
1 parent 2706de4 commit c5c142e

File tree

5 files changed

+122
-7
lines changed

5 files changed

+122
-7
lines changed

dev/test-umd.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<html>
2+
<head>
3+
<script src="../dist/modern-async.umd.js"></script>
4+
<script>
5+
console.log(unknown)
6+
/*
7+
window.modernAsync.asyncRoot(async () => {
8+
console.log('hello')
9+
})*/
10+
</script>
11+
</head>
12+
</html>

package-lock.json

Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"import": "./src/modern-async.mjs",
1010
"require": "./dist/modern-async.cjs"
1111
},
12+
"browser": "./src/dist/modern-async.umd.js",
1213
"scripts": {
1314
"build": "rollup -c rollup.config.js",
1415
"test": "npm run lint && npm run coverage",
@@ -31,11 +32,14 @@
3132
"devDependencies": {
3233
"@babel/cli": "^7.12.10",
3334
"@babel/core": "^7.12.10",
35+
"@babel/plugin-transform-modules-umd": "^7.12.1",
3436
"@babel/preset-env": "^7.12.10",
37+
"@rollup/plugin-babel": "^5.2.2",
3538
"@rollup/plugin-commonjs": "^17.0.0",
3639
"@rollup/plugin-node-resolve": "^11.0.0",
3740
"babel-jest": "^26.6.3",
3841
"clean-jsdoc-theme": "^3.0.0",
42+
"core-js": "^3.8.1",
3943
"eslint": "^6.6.0",
4044
"eslint-config-standard": "^14.1.0",
4145
"eslint-plugin-import": "^2.18.2",

rollup.config.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
import { nodeResolve } from '@rollup/plugin-node-resolve'
33
import commonjs from '@rollup/plugin-commonjs'
4+
import { getBabelOutputPlugin } from '@rollup/plugin-babel'
45

56
export default [{
67
input: 'src/modern-async.mjs',
@@ -10,14 +11,29 @@ export default [{
1011
},
1112
plugins: []
1213
}, {
13-
input: 'src/modern-async.mjs',
14+
input: 'src/modern-async-umd.mjs',
1415
output: {
1516
file: 'dist/modern-async.umd.js',
16-
format: 'umd',
17-
name: 'modernAsync'
17+
format: 'esm'
1818
},
19-
plugins: [nodeResolve({
20-
preferBuiltins: false,
21-
browser: true
22-
}), commonjs()]
19+
plugins: [
20+
nodeResolve(),
21+
commonjs(),
22+
getBabelOutputPlugin({
23+
presets: [
24+
['@babel/preset-env', {
25+
targets: {
26+
ie: '8'
27+
}
28+
}]
29+
],
30+
plugins: [
31+
['@babel/plugin-transform-modules-umd',{
32+
globals: {
33+
unknown: 'modernAsync'
34+
}
35+
}]
36+
]
37+
})
38+
]
2339
}]

src/modern-async-umd.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
import 'regenerator-runtime/runtime'
3+
4+
export * from './modern-async.mjs'

0 commit comments

Comments
 (0)