Skip to content

Commit

Permalink
perfected umd
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-van committed Dec 14, 2020
1 parent c5c142e commit 748d690
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules
/dist
/coverage
/babel.config.cjs
9 changes: 9 additions & 0 deletions babel-browser.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
presets: [
['@babel/preset-env', {
targets: {
ie: '8'
}
}]
]
}
9 changes: 9 additions & 0 deletions babel-node.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
presets: [
['@babel/preset-env', {
targets: {
node: '15.4.0'
}
}]
]
}
3 changes: 0 additions & 3 deletions babel.config.cjs

This file was deleted.

7 changes: 3 additions & 4 deletions dev/test-umd.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
<head>
<script src="../dist/modern-async.umd.js"></script>
<script>
console.log(unknown)
/*
window.modernAsync.asyncRoot(async () => {
modernAsync.asyncRoot(async () => {
await modernAsync.delay()
console.log('hello')
})*/
})
</script>
</head>
</html>
2 changes: 1 addition & 1 deletion jest-node.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ module.exports = {
// A map from regular expressions to paths to transformers
// transform: {},
transform: {
'\\.mjs': 'babel-jest'
'\\.mjs': ['babel-jest', {}]
},

// An array of regexp pattern strings that are matched against all source file paths, matched files will
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
},
"browser": "./src/dist/modern-async.umd.js",
"scripts": {
"build": "rollup -c rollup.config.js",
"build": "npm run set-babel-browser && rollup -c rollup.config.js",
"test": "npm run lint && npm run coverage",
"coverage": "npm run jest-node -- --coverage",
"lint": "eslint -c .eslintrc.cjs \"src/**/*.mjs\"",
"jest-node": "jest --config=./jest-node.config.cjs",
"jest-node": "npm run set-babel-node && jest --config=./jest-node.config.cjs",
"docs": "jsdoc -c .jsdoc.json && node dev/docs-collect-version-numbers.cjs",
"babel": "babel --ignore \"**/*.test.js\" --out-dir dist/babel --config-file ./babel.config.js src"
"babel": "babel --ignore \"**/*.test.js\" --out-dir dist/babel --config-file ./babel.config.js src",
"set-babel-node": "cp babel-node.config.cjs babel.config.cjs",
"set-babel-browser": "cp babel-browser.config.cjs babel.config.cjs"
},
"repository": {
"type": "git",
Expand Down
22 changes: 4 additions & 18 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import { getBabelOutputPlugin } from '@rollup/plugin-babel'
import babel from '@rollup/plugin-babel'

export default [{
input: 'src/modern-async.mjs',
Expand All @@ -14,26 +14,12 @@ export default [{
input: 'src/modern-async-umd.mjs',
output: {
file: 'dist/modern-async.umd.js',
format: 'esm'
format: 'umd',
name: 'modernAsync'
},
plugins: [
nodeResolve(),
commonjs(),
getBabelOutputPlugin({
presets: [
['@babel/preset-env', {
targets: {
ie: '8'
}
}]
],
plugins: [
['@babel/plugin-transform-modules-umd',{
globals: {
unknown: 'modernAsync'
}
}]
]
})
babel({ babelHelpers: 'bundled' })
]
}]

0 comments on commit 748d690

Please sign in to comment.