Skip to content

Commit 748d690

Browse files
committed
perfected umd
1 parent c5c142e commit 748d690

File tree

8 files changed

+32
-29
lines changed

8 files changed

+32
-29
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/node_modules
22
/dist
33
/coverage
4+
/babel.config.cjs

babel-browser.config.cjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
presets: [
3+
['@babel/preset-env', {
4+
targets: {
5+
ie: '8'
6+
}
7+
}]
8+
]
9+
}

babel-node.config.cjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
presets: [
3+
['@babel/preset-env', {
4+
targets: {
5+
node: '15.4.0'
6+
}
7+
}]
8+
]
9+
}

babel.config.cjs

Lines changed: 0 additions & 3 deletions
This file was deleted.

dev/test-umd.html

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

jest-node.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ module.exports = {
172172
// A map from regular expressions to paths to transformers
173173
// transform: {},
174174
transform: {
175-
'\\.mjs': 'babel-jest'
175+
'\\.mjs': ['babel-jest', {}]
176176
},
177177

178178
// An array of regexp pattern strings that are matched against all source file paths, matched files will

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
},
1212
"browser": "./src/dist/modern-async.umd.js",
1313
"scripts": {
14-
"build": "rollup -c rollup.config.js",
14+
"build": "npm run set-babel-browser && rollup -c rollup.config.js",
1515
"test": "npm run lint && npm run coverage",
1616
"coverage": "npm run jest-node -- --coverage",
1717
"lint": "eslint -c .eslintrc.cjs \"src/**/*.mjs\"",
18-
"jest-node": "jest --config=./jest-node.config.cjs",
18+
"jest-node": "npm run set-babel-node && jest --config=./jest-node.config.cjs",
1919
"docs": "jsdoc -c .jsdoc.json && node dev/docs-collect-version-numbers.cjs",
20-
"babel": "babel --ignore \"**/*.test.js\" --out-dir dist/babel --config-file ./babel.config.js src"
20+
"babel": "babel --ignore \"**/*.test.js\" --out-dir dist/babel --config-file ./babel.config.js src",
21+
"set-babel-node": "cp babel-node.config.cjs babel.config.cjs",
22+
"set-babel-browser": "cp babel-browser.config.cjs babel.config.cjs"
2123
},
2224
"repository": {
2325
"type": "git",

rollup.config.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +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'
4+
import babel from '@rollup/plugin-babel'
55

66
export default [{
77
input: 'src/modern-async.mjs',
@@ -14,26 +14,12 @@ export default [{
1414
input: 'src/modern-async-umd.mjs',
1515
output: {
1616
file: 'dist/modern-async.umd.js',
17-
format: 'esm'
17+
format: 'umd',
18+
name: 'modernAsync'
1819
},
1920
plugins: [
2021
nodeResolve(),
2122
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-
})
23+
babel({ babelHelpers: 'bundled' })
3824
]
3925
}]

0 commit comments

Comments
 (0)