From 845a2b8a2ab2fb0ce2760abefb8c117313b37b04 Mon Sep 17 00:00:00 2001 From: Carl-Erik Kopseng Date: Fri, 25 May 2018 12:32:14 +0200 Subject: [PATCH] Initial attempt at fixing #1805 See sinonjs/sinon#1805 Not functional bundle. Gets this error: $ node -r esm -e 'import sinon from ./bundle-esm' file:///home/carlerik/dev/sinon/bundle-esm.js:1 import typeDetect from 'type-detect'; SyntaxError: Missing export 'default' in ES module: file:///home/carlerik/dev/sinon/node_modules/diff/lib/index.js at Object. (file:///home/carlerik/dev/sinon/bundle-esm.js:1) --- package-lock.json | 116 +++++++++++++++++++++++++++++++++++++++++----- package.json | 3 ++ rollup.config.js | 46 ++++++++++++++++++ 3 files changed, 153 insertions(+), 12 deletions(-) create mode 100644 rollup.config.js diff --git a/package-lock.json b/package-lock.json index 3650f6c18..ad2c2c8b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,6 +40,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/@sinonjs/referee/-/referee-2.1.1.tgz", "integrity": "sha512-plsDNXJdEtE7TAqgaeojagzzh+vUrZzqNeSL7y6GjvfQfG9ItgNiu5qIX1enrYyJJdJoiUQAgmasZhHMT7O0Ig==", + "dev": true, "requires": { "array.from": "^1.0.3", "bane": "^1.x", @@ -50,6 +51,16 @@ "samsam": "^1.x" } }, + "@types/estree": { + "version": "0.0.39", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", + "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==" + }, + "@types/node": { + "version": "10.1.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.1.2.tgz", + "integrity": "sha512-bjk1RIeZBCe/WukrFToIVegOf91Pebr8cXYBwLBIsfiGWVQ+ifwWsT59H3RxrWzWrzd1l/Amk1/ioY5Fq3/bpA==" + }, "JSONStream": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", @@ -275,6 +286,7 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/array.from/-/array.from-1.0.3.tgz", "integrity": "sha1-y1hqrZIGfzQSKfQeDtZDKB26Vrc=", + "dev": true, "requires": { "define-properties": "^1.1.2", "es-abstract": "^1.6.1" @@ -383,7 +395,8 @@ "bane": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/bane/-/bane-1.1.2.tgz", - "integrity": "sha1-vGQkjMgjFgx98/I4uH/mLEThB7k=" + "integrity": "sha1-vGQkjMgjFgx98/I4uH/mLEThB7k=", + "dev": true }, "base64-js": { "version": "1.2.1", @@ -1253,6 +1266,7 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz", "integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=", + "dev": true, "requires": { "foreach": "^2.0.5", "object-keys": "^1.0.8" @@ -1433,6 +1447,7 @@ "version": "1.8.2", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.8.2.tgz", "integrity": "sha512-dvhwFL3yjQxNNsOWx6exMlaDrRHCRGMQlnx5lsXDCZ/J7G/frgIIl94zhZSp/galVAYp7VzPi1OrAHta89/yGQ==", + "dev": true, "requires": { "es-to-primitive": "^1.1.1", "function-bind": "^1.1.1", @@ -1445,6 +1460,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.1.1.tgz", "integrity": "sha1-RTVSSKiJeQNLZ5Lhm7gfK3l13Q0=", + "dev": true, "requires": { "is-callable": "^1.1.1", "is-date-object": "^1.0.1", @@ -1454,7 +1470,8 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==" + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", + "dev": true }, "es6-promisify": { "version": "5.0.0", @@ -1662,6 +1679,12 @@ "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", "dev": true }, + "estree-walker": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.5.2.tgz", + "integrity": "sha512-XpCnW/AE10ws/kDAs37cngSkvgIR8aN3G0MS85m7dUpuK2EREo9VJ00uvw6Dg/hXEpfsE1I1TvJOJr+Z+TL+ig==", + "dev": true + }, "esutils": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", @@ -1932,7 +1955,8 @@ "foreach": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", - "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=" + "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", + "dev": true }, "from": { "version": "0.1.7", @@ -2478,7 +2502,8 @@ "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true }, "functional-red-black-tree": { "version": "1.0.1", @@ -2648,6 +2673,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz", "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=", + "dev": true, "requires": { "function-bind": "^1.0.2" } @@ -2895,7 +2921,8 @@ "is-callable": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.3.tgz", - "integrity": "sha1-hut1OSgF3cM69xySoO7fdO52BLI=" + "integrity": "sha1-hut1OSgF3cM69xySoO7fdO52BLI=", + "dev": true }, "is-ci": { "version": "1.0.10", @@ -2909,7 +2936,8 @@ "is-date-object": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", - "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=" + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "dev": true }, "is-directory": { "version": "0.3.1", @@ -3044,6 +3072,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "dev": true, "requires": { "has": "^1.0.1" } @@ -3078,7 +3107,8 @@ "is-symbol": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz", - "integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=" + "integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=", + "dev": true }, "is-unc-path": { "version": "0.1.2", @@ -3651,12 +3681,14 @@ "lodash.includes": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", - "integrity": "sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8=" + "integrity": "sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8=", + "dev": true }, "lodash.isarguments": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", - "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=" + "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", + "dev": true }, "lodash.memoize": { "version": "3.0.4", @@ -3737,6 +3769,15 @@ "yallist": "^2.1.2" } }, + "magic-string": { + "version": "0.22.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.22.5.tgz", + "integrity": "sha512-oreip9rJZkzvA8Qzk9HFs8fZGF/u7H/gtrE8EN6RjKJ9kh2HlC+yQ2QezifqTZfGyiuAV0dRv5a+y/8gBb1m9w==", + "dev": true, + "requires": { + "vlq": "^0.2.2" + } + }, "map-stream": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", @@ -4338,12 +4379,14 @@ "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true }, "object-keys": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.11.tgz", - "integrity": "sha1-xUYBd4rVYPEULODgG8yotW0TQm0=" + "integrity": "sha1-xUYBd4rVYPEULODgG8yotW0TQm0=", + "dev": true }, "object.omit": { "version": "2.0.1", @@ -5238,6 +5281,48 @@ "inherits": "^2.0.1" } }, + "rollup": { + "version": "0.59.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.59.3.tgz", + "integrity": "sha512-A94GFMZlwwtS3t5p6jSTp9w4Asxu5C16NcEoQPUFPfl76FOHFA4bXjOdnirzBysdZqSS/2Dibhz1bdWZ/0UqQQ==", + "requires": { + "@types/estree": "0.0.39", + "@types/node": "*" + } + }, + "rollup-plugin-commonjs": { + "version": "9.1.3", + "resolved": "https://registry.npmjs.org/rollup-plugin-commonjs/-/rollup-plugin-commonjs-9.1.3.tgz", + "integrity": "sha512-g91ZZKZwTW7F7vL6jMee38I8coj/Q9GBdTmXXeFL7ldgC1Ky5WJvHgbKlAiXXTh762qvohhExwUgeQGFh9suGg==", + "dev": true, + "requires": { + "estree-walker": "^0.5.1", + "magic-string": "^0.22.4", + "resolve": "^1.5.0", + "rollup-pluginutils": "^2.0.1" + }, + "dependencies": { + "resolve": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", + "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", + "dev": true, + "requires": { + "path-parse": "^1.0.5" + } + } + } + }, + "rollup-pluginutils": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.3.0.tgz", + "integrity": "sha512-xB6hsRsjdJdIYWEyYUJy/3ki5g69wrf0luHPGNK3ZSocV6HLNfio59l3dZ3TL4xUwEKgROhFi9jOCt6c5gfUWw==", + "dev": true, + "requires": { + "estree-walker": "^0.5.2", + "micromatch": "^2.3.11" + } + }, "run-async": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", @@ -5294,7 +5379,8 @@ "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==" + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", + "dev": true }, "saucelabs": { "version": "1.5.0", @@ -5886,6 +5972,12 @@ "spdx-expression-parse": "~1.0.0" } }, + "vlq": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/vlq/-/vlq-0.2.3.tgz", + "integrity": "sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==", + "dev": true + }, "vm-browserify": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", diff --git a/package.json b/package.json index 9fd3cc0e8..96b5561bd 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "test": "run-s test-node test-headless test-webworker test-es-module", "check-dependencies": "dependency-check package.json --unused --no-dev --ignore-module coveralls --ignore-module esm", "build": "node ./build.js", + "build-esm": "rollup -c", "lint": "run-p lint-js lint-markdown", "lint-js": "eslint '**/*.{js,mjs}'", "lint-markdown": "find docs -type f -name '*.md' ! -name 'changelog.md' | xargs markdownlint", @@ -45,6 +46,7 @@ "lodash.get": "^4.4.2", "lolex": "^2.6.0", "nise": "^1.3.3", + "rollup": "^0.59.3", "supports-color": "^5.4.0", "type-detect": "^4.0.8" }, @@ -69,6 +71,7 @@ "proxyquire-universal": "^1.0.8", "proxyquireify": "^3.2.1", "rimraf": "^2.5.3", + "rollup-plugin-commonjs": "^9.1.3", "samsam": "^1.3.0" }, "files": [ diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 000000000..4c77a3ecb --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,46 @@ +// rollup.config.js +import commonjs from "rollup-plugin-commonjs"; +//import nodeResolve from "rollup-plugin-node-resolve"; + +export default { + input: "./lib/sinon.js", + output: { + file: "pkg/bundle-esm.js", + format: "esm" + }, + plugins: [ + //nodeResolve({ + //jsnext: true, + //main: true + //}), + + commonjs({ + // non-CommonJS modules will be ignored, but you can also + // specifically include/exclude files + //include: "node_modules/**", // Default: undefined + //exclude: ["node_modules/foo/**", "node_modules/bar/**"], // Default: undefined + // these values can also be regular expressions + // include: /node_modules/ + + // search for files other than .js files (must already + // be transpiled by a previous plugin!) + //extensions: [".js", ".coffee"], // Default: [ '.js' ] + + // if true then uses of `global` won't be dealt with by this plugin + ignoreGlobal: false, // Default: false + + // if false then skip sourceMap generation for CommonJS modules + sourceMap: false // Default: true + + // explicitly specify unresolvable named exports + // (see below for more details) + //namedExports: { "./module.js": ["foo", "bar"] }, // Default: undefined + + // sometimes you have to leave require statements + // unconverted. Pass an array containing the IDs + // or a `id => boolean` function. Only use this + // option if you know what you're doing! + //ignore: ["conditional-runtime-dependency"] + }) + ] +};