Skip to content

Commit a3f078f

Browse files
broofactavan
authored andcommitted
feat: hybrid CommonJS & ECMAScript modules build
BREAKING CHANGE: Convert code base to ECMAScript Modules (ESM) and release CommonJS build for node and ESM build for browser bundlers.
1 parent 60eb84a commit a3f078f

29 files changed

+4556
-1544
lines changed

.babelrc.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
presets: [],
3+
plugins: [],
4+
env: {
5+
commonjs: {
6+
plugins: [
7+
'babel-plugin-add-module-exports',
8+
],
9+
presets: [
10+
['@babel/preset-env', {targets: {node: '8'}, modules: 'commonjs'}],
11+
],
12+
},
13+
esm: {
14+
presets: [
15+
['@babel/preset-env', {modules: false}],
16+
],
17+
},
18+
},
19+
};

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!.babelrc.js

.eslintrc.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
"env": {
44
"browser": true,
55
"commonjs": true,
6+
"es6": true,
67
"mocha": true,
78
"node": true
89
},
910
"extends": ["eslint:recommended"],
1011
"globals": {
1112
"msCrypto": true
1213
},
14+
"parser": "babel-eslint",
1315
"rules": {
1416
"array-bracket-spacing": ["warn", "never"],
1517
"arrow-body-style": ["warn", "as-needed"],

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
.idea/**
33
.DS_Store
44
node_modules
5+
tmp
6+
dist/

README_js.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
```javascript --hide
22
runmd.onRequire = path => {
33
if (path == 'rng') return fun
4-
return path.replace(/^uuid/, './');
4+
return path.replace(/^uuid/, './dist/');
55
}
66

77
// Shim Date and crypto so generated ids are consistent across doc revisions

index.js

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

lib/rng.js

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

0 commit comments

Comments
 (0)