Skip to content

Commit

Permalink
feat: native Node.js ES Modules (isolated state approach)
Browse files Browse the repository at this point in the history
  • Loading branch information
ctavan committed Apr 24, 2020
1 parent ce93af9 commit 0e755bf
Show file tree
Hide file tree
Showing 12 changed files with 245 additions and 31 deletions.
1 change: 0 additions & 1 deletion .local/wrapper.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion bundlewatch.config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"files": [
{ "path": "./examples/browser-rollup/dist/v1-size.js", "maxSize": "0.8 kB" },
{ "path": "./examples/browser-rollup/dist/v1-size.js", "maxSize": "0.9 kB" },
{ "path": "./examples/browser-rollup/dist/v3-size.js", "maxSize": "1.8 kB" },
{ "path": "./examples/browser-rollup/dist/v4-size.js", "maxSize": "0.5 kB" },
{ "path": "./examples/browser-rollup/dist/v5-size.js", "maxSize": "1.2 kB" },
Expand Down
141 changes: 141 additions & 0 deletions examples/browser-rollup/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/browser-rollup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"uuid": "file:../../.local"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-node-resolve": "^7.1.3",
"rollup": "^2.6.1",
"rollup-plugin-terser": "^5.3.0"
Expand Down
9 changes: 8 additions & 1 deletion examples/browser-rollup/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
const commonjs = require('@rollup/plugin-commonjs');
const resolve = require('@rollup/plugin-node-resolve');
const { terser } = require('rollup-plugin-terser');

const plugins = [resolve({ browser: true }), terser()];
const plugins = [
resolve({ browser: true }),
commonjs({
extensions: ['.cjs'],
}),
terser(),
];
module.exports = [
{
input: './example-all.js',
Expand Down
53 changes: 53 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
"main": "./dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./wrapper.mjs"
"import": "./dist/esm-node/index.mjs"
},
"module": "./dist/esm-node/index.js",
"module": "./dist/esm-node/index.mjs",
"browser": {
"./dist/md5.js": "./dist/md5-browser.js",
"./dist/rng.js": "./dist/rng-browser.js",
"./dist/sha1.js": "./dist/sha1-browser.js",
"./dist/esm-node/index.js": "./dist/esm-browser/index.js"
"./dist/esm-node/index.mjs": "./dist/esm-browser/index.js"
},
"files": [
"CHANGELOG.md",
Expand All @@ -39,15 +39,15 @@
"v1.js",
"v3.js",
"v4.js",
"v5.js",
"wrapper.mjs"
"v5.js"
],
"devDependencies": {
"@babel/cli": "7.8.4",
"@babel/core": "7.9.0",
"@babel/preset-env": "7.9.5",
"@commitlint/cli": "8.3.5",
"@commitlint/config-conventional": "8.3.4",
"@rollup/plugin-commonjs": "11.1.0",
"@rollup/plugin-node-resolve": "7.1.3",
"@wdio/browserstack-service": "6.0.12",
"@wdio/cli": "6.0.15",
Expand Down
9 changes: 8 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import nodeResolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser';

function chunk(input, name) {
Expand All @@ -10,7 +11,13 @@ function chunk(input, name) {
name,
compact: true,
},
plugins: [nodeResolve({ browser: true }), terser()],
plugins: [
nodeResolve({ browser: true }),
commonjs({
extensions: ['.cjs'],
}),
terser(),
],
};
}

Expand Down
Loading

0 comments on commit 0e755bf

Please sign in to comment.