Skip to content

Commit

Permalink
feat: hybrid CommonJS & ECMAScript modules build
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Convert code base to ECMAScript Modules (ESM) and
release CommonJS build for node and ESM build for browser bundlers.
  • Loading branch information
broofa authored and ctavan committed Oct 25, 2019
1 parent 60eb84a commit a3f078f
Show file tree
Hide file tree
Showing 29 changed files with 4,556 additions and 1,544 deletions.
19 changes: 19 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
presets: [],
plugins: [],
env: {
commonjs: {
plugins: [
'babel-plugin-add-module-exports',
],
presets: [
['@babel/preset-env', {targets: {node: '8'}, modules: 'commonjs'}],
],
},
esm: {
presets: [
['@babel/preset-env', {modules: false}],
],
},
},
};
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.babelrc.js
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"mocha": true,
"node": true
},
"extends": ["eslint:recommended"],
"globals": {
"msCrypto": true
},
"parser": "babel-eslint",
"rules": {
"array-bracket-spacing": ["warn", "never"],
"arrow-body-style": ["warn", "as-needed"],
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.idea/**
.DS_Store
node_modules
tmp
dist/
2 changes: 1 addition & 1 deletion README_js.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
```javascript --hide
runmd.onRequire = path => {
if (path == 'rng') return fun
return path.replace(/^uuid/, './');
return path.replace(/^uuid/, './dist/');
}

// Shim Date and crypto so generated ids are consistent across doc revisions
Expand Down
8 changes: 0 additions & 8 deletions index.js

This file was deleted.

8 changes: 0 additions & 8 deletions lib/rng.js

This file was deleted.

Loading

0 comments on commit a3f078f

Please sign in to comment.