From 9610a43e41a6500f4ad160526ee676aacd777753 Mon Sep 17 00:00:00 2001 From: Philip Walton Date: Mon, 11 Feb 2019 22:00:39 -0800 Subject: [PATCH] Add a UMD build for workbox-window --- gulp-tasks/utils/build-browser-bundle.js | 47 +-- gulp-tasks/utils/build-window-bundle.js | 60 ++-- infra/testing/server/routes/build-file.js | 2 +- package-lock.json | 301 ++++++------------ package.json | 9 +- packages/workbox-build/package-lock.json | 2 +- .../src/lib/copy-workbox-libraries.js | 26 +- .../workbox-build/src/lib/use-build-type.js | 41 --- packages/workbox-cli/package-lock.json | 43 ++- .../workbox-webpack-plugin/package-lock.json | 2 +- packages/workbox-window/package.json | 5 +- .../node/entry-points/generate-sw.js | 11 +- .../node/lib/copy-workbox-libraries.js | 6 +- test/workbox-build/node/lib/use-build-type.js | 33 -- .../node/generate-sw.js | 14 +- .../node/inject-manifest.js | 14 +- 16 files changed, 211 insertions(+), 405 deletions(-) delete mode 100644 packages/workbox-build/src/lib/use-build-type.js delete mode 100644 test/workbox-build/node/lib/use-build-type.js diff --git a/gulp-tasks/utils/build-browser-bundle.js b/gulp-tasks/utils/build-browser-bundle.js index cc16f8665..5aabbeaca 100644 --- a/gulp-tasks/utils/build-browser-bundle.js +++ b/gulp-tasks/utils/build-browser-bundle.js @@ -6,17 +6,10 @@ https://opensource.org/licenses/MIT. */ -const buffer = require('vinyl-buffer'); const fs = require('fs-extra'); -const gulp = require('gulp'); const oneLine = require('common-tags').oneLine; const path = require('path'); -const rename = require('gulp-rename'); -const rollup = require('rollup'); -const rollupStream = require('rollup-stream'); -const source = require('vinyl-source-stream'); -const sourcemaps = require('gulp-sourcemaps'); - +const {rollup} = require('rollup'); const constants = require('./constants'); const logHelper = require('../../infra/utils/log-helper'); const pkgPathToName = require('./pkg-path-to-name'); @@ -97,7 +90,7 @@ const externalAndPure = (importPath) => { return (importPath.indexOf('workbox-') === 0); }; -module.exports = (packagePath, buildType) => { +module.exports = async (packagePath, buildType) => { const packageName = pkgPathToName(packagePath); const packageIndex = path.join(packagePath, `index.mjs`); @@ -140,15 +133,8 @@ module.exports = (packagePath, buildType) => { const plugins = rollupHelper.getDefaultPlugins(buildType); - return rollupStream({ + const bundle = await rollup({ input: packageIndex, - rollup, - output: { - name: namespace, - sourcemap: true, - format: 'iife', - globals, - }, external: externalAndPure, treeshake: { pureExternalModules: externalAndPure, @@ -170,22 +156,13 @@ module.exports = (packagePath, buildType) => { throw new Error(`Unhandled Rollup Warning: ${warning}`); } }, - }) - .on('error', (err) => { - const args = Object.keys(err).map((key) => `${key}: ${err[key]}`); - logHelper.error(err, `\n\n${args.join('\n')}`); - throw err; - }) - // We must give the generated stream the same name as the entry file - // for the sourcemaps to work correctly - .pipe(source(packageIndex)) - // gulp-sourcemaps don't work with streams so we need - .pipe(buffer()) - // This tells gulp-sourcemaps to load the inline sourcemap - .pipe(sourcemaps.init({loadMaps: true})) - // This renames the output file - .pipe(rename(outputFilename)) - // This writes the sourcemap alongside the final build file - .pipe(sourcemaps.write('.')) - .pipe(gulp.dest(outputDirectory)); + }); + + await bundle.write({ + file: path.join(outputDirectory, outputFilename), + name: namespace, + sourcemap: true, + format: 'iife', + globals, + }); }; diff --git a/gulp-tasks/utils/build-window-bundle.js b/gulp-tasks/utils/build-window-bundle.js index 5715087da..9ebbfd5e5 100644 --- a/gulp-tasks/utils/build-window-bundle.js +++ b/gulp-tasks/utils/build-window-bundle.js @@ -6,16 +6,9 @@ https://opensource.org/licenses/MIT. */ -const buffer = require('vinyl-buffer'); const fs = require('fs-extra'); -const gulp = require('gulp'); const path = require('path'); -const rename = require('gulp-rename'); -const rollup = require('rollup'); -const rollupStream = require('rollup-stream'); -const source = require('vinyl-source-stream'); -const sourcemaps = require('gulp-sourcemaps'); - +const {rollup} = require('rollup'); const constants = require('./constants'); const logHelper = require('../../infra/utils/log-helper'); const pkgPathToName = require('./pkg-path-to-name'); @@ -26,7 +19,7 @@ const ERROR_NO_MODULE_BROWSER = `Could not find the module's index.mjs file: `; -module.exports = (packagePath, buildType) => { +module.exports = async (packagePath, buildType) => { const packageName = pkgPathToName(packagePath); const moduleBrowserPath = path.join(packagePath, `index.mjs`); @@ -37,25 +30,24 @@ module.exports = (packagePath, buildType) => { return Promise.reject(ERROR_NO_MODULE_BROWSER + packageName); } - const outputFilename = `${packageName}.${buildType.slice(0, 4)}.mjs`; const outputDirectory = path.join( packagePath, constants.PACKAGE_BUILD_DIRNAME); + const esFilename = `${packageName}.${buildType.slice(0, 4)}.mjs`; + const umdFilename = `${packageName}.${buildType.slice(0, 4)}.umd.js`; + + logHelper.log( + `Building window module bundle: ${logHelper.highlight(esFilename)}`); logHelper.log( - `Building Window Bundle: ${logHelper.highlight(outputFilename)}`); + `Building window UMD bundle: ${logHelper.highlight(umdFilename)}`); // TODO(philipwalton): ensure all loaded workbox modules conform to // the same conventions we document to external developers. This can be // done with a Rollup plugin that validates them. const plugins = rollupHelper.getDefaultPlugins(buildType, {module: true}); - return rollupStream({ + const bundle = await rollup({ input: moduleBrowserPath, - rollup, - output: { - sourcemap: true, - format: 'es', - }, plugins, onwarn: (warning) => { if (buildType === constants.BUILD_TYPES.prod && @@ -73,22 +65,20 @@ module.exports = (packagePath, buildType) => { throw new Error(`Unhandled Rollup Warning: ${warning}`); } }, - }) - .on('error', (err) => { - const args = Object.keys(err).map((key) => `${key}: ${err[key]}`); - logHelper.error(err, `\n\n${args.join('\n')}`); - throw err; - }) - // We must give the generated stream the same name as the entry file - // for the sourcemaps to work correctly - .pipe(source(moduleBrowserPath)) - // gulp-sourcemaps don't work with streams so we need - .pipe(buffer()) - // This tells gulp-sourcemaps to load the inline sourcemap - .pipe(sourcemaps.init({loadMaps: true})) - // This renames the output file - .pipe(rename(outputFilename)) - // This writes the sourcemap alongside the final build file - .pipe(sourcemaps.write('.')) - .pipe(gulp.dest(outputDirectory)); + }); + + // Generate both a native module and a UMD module (for compat). + await Promise.all([ + bundle.write({ + file: path.join(outputDirectory, esFilename), + sourcemap: true, + format: 'es', + }), + bundle.write({ + file: path.join(outputDirectory, umdFilename), + sourcemap: true, + format: 'umd', + name: 'workbox', + }), + ]); }; diff --git a/infra/testing/server/routes/build-file.js b/infra/testing/server/routes/build-file.js index 00275ef7f..8e5ba3bf6 100644 --- a/infra/testing/server/routes/build-file.js +++ b/infra/testing/server/routes/build-file.js @@ -22,7 +22,7 @@ async function handler(req, res) { const packagePath = path.join(ROOT_DIR, 'packages', pkg.name); const buildPath = path.dirname(path.join(packagePath, pkg.main)); - let fileName = path.basename(pkg.main); + let fileName = path.basename(pkg.workbox.primaryBuild || pkg.main); if (buildType) { fileName = fileName.replace('.prod.', `.${buildType}.`); diff --git a/package-lock.json b/package-lock.json index 06753f4e5..b652e1547 100644 --- a/package-lock.json +++ b/package-lock.json @@ -888,6 +888,7 @@ "resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.2.tgz", "integrity": "sha512-vtv5HtGjcYUgFrXc6Kx747B83MRRVS5R1VTEQoXvuP+kMI+if6uywV0nDGoiydJRy4yk7h9od5Og0kxx4zUXmw==", "dev": true, + "optional": true, "requires": { "dot-prop": "^4.1.0", "graceful-fs": "^4.1.2", @@ -919,6 +920,7 @@ "resolved": "http://registry.npmjs.org/gcp-metadata/-/gcp-metadata-0.6.3.tgz", "integrity": "sha512-MSmczZctbz91AxCvqp9GHBoZOSbJKAICV7Ow/AIWSJZRrRchUd5NL1b2P4OfP+4m490BEUPhhARfpHdqCxuCvg==", "dev": true, + "optional": true, "requires": { "axios": "^0.18.0", "extend": "^3.0.1", @@ -944,6 +946,7 @@ "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-1.6.1.tgz", "integrity": "sha512-jYiWC8NA9n9OtQM7ANn0Tk464do9yhKEtaJ72pKcaBiEwn4LwcGYIYOfwtfsSm3aur/ed3tlSxbmg24IAT6gAg==", "dev": true, + "optional": true, "requires": { "axios": "^0.18.0", "gcp-metadata": "^0.6.3", @@ -959,6 +962,7 @@ "resolved": "https://registry.npmjs.org/google-auto-auth/-/google-auto-auth-0.10.1.tgz", "integrity": "sha512-iIqSbY7Ypd32mnHGbYctp80vZzXoDlvI9gEfvtl3kmyy5HzOcrZCIGCBdSlIzRsg7nHpQiHE3Zl6Ycur6TSodQ==", "dev": true, + "optional": true, "requires": { "async": "^2.3.0", "gcp-metadata": "^0.6.1", @@ -971,6 +975,7 @@ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", "dev": true, + "optional": true, "requires": { "safer-buffer": ">= 2.1.2 < 3" } @@ -1189,57 +1194,6 @@ "xdg-basedir": "^3.0.0" } }, - "@gulp-sourcemaps/identity-map": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@gulp-sourcemaps/identity-map/-/identity-map-1.0.2.tgz", - "integrity": "sha512-ciiioYMLdo16ShmfHBXJBOFm3xPC4AuwO4xeRpFeHz7WK9PYsWCmigagG2XyzZpubK4a3qNKoUBDhbzHfa50LQ==", - "dev": true, - "requires": { - "acorn": "^5.0.3", - "css": "^2.2.1", - "normalize-path": "^2.1.1", - "source-map": "^0.6.0", - "through2": "^2.0.3" - }, - "dependencies": { - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true, - "requires": { - "remove-trailing-separator": "^1.0.1" - } - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, - "@gulp-sourcemaps/map-sources": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@gulp-sourcemaps/map-sources/-/map-sources-1.0.0.tgz", - "integrity": "sha1-iQrnxdjId/bThIYCFazp1+yUW9o=", - "dev": true, - "requires": { - "normalize-path": "^2.0.1", - "through2": "^2.0.3" - }, - "dependencies": { - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true, - "requires": { - "remove-trailing-separator": "^1.0.1" - } - } - } - }, "@lerna/add": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/@lerna/add/-/add-3.3.2.tgz", @@ -4451,7 +4405,8 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=", - "dev": true + "dev": true, + "optional": true }, "columnify": { "version": "1.5.4", @@ -5208,26 +5163,6 @@ "integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=", "dev": true }, - "css": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz", - "integrity": "sha512-oUnjmWpy0niI3x/mPL8dVEI1l7MnG3+HHyRPHf+YFSbK+svOhXpmSOcDURUh2aOCgl2grzrOPt1nHLuCVFULLw==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "source-map": "^0.6.1", - "source-map-resolve": "^0.5.2", - "urix": "^0.1.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, "css-select": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", @@ -5362,17 +5297,6 @@ "ms": "^2.1.1" } }, - "debug-fabulous": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/debug-fabulous/-/debug-fabulous-1.1.0.tgz", - "integrity": "sha512-GZqvGIgKNlUnHUPQhepnUZFIMoi3dgZKQBzKDeL2g7oJF9SNAji/AAu36dusFUas0O+pae74lNeoIPHqXWDkLg==", - "dev": true, - "requires": { - "debug": "3.X", - "memoizee": "0.4.X", - "object-assign": "4.X" - } - }, "debuglog": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/debuglog/-/debuglog-1.0.1.tgz", @@ -5642,12 +5566,6 @@ "integrity": "sha1-OHHMCmoALow+Wzz38zYmRnXwa50=", "dev": true }, - "detect-newline": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-2.1.0.tgz", - "integrity": "sha1-9B8cEL5LAOh7XxPaaAdZ8sW/0+I=", - "dev": true - }, "dezalgo": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.3.tgz", @@ -7589,7 +7507,8 @@ "version": "2.1.1", "resolved": false, "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -7613,13 +7532,15 @@ "version": "1.0.0", "resolved": false, "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": false, "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -7636,19 +7557,22 @@ "version": "1.1.0", "resolved": false, "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": false, "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": false, "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -7779,7 +7703,8 @@ "version": "2.0.3", "resolved": false, "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -7793,6 +7718,7 @@ "resolved": false, "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7809,6 +7735,7 @@ "resolved": false, "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -7817,13 +7744,15 @@ "version": "0.0.8", "resolved": false, "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "resolved": false, "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -7844,6 +7773,7 @@ "resolved": false, "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -7932,7 +7862,8 @@ "version": "1.0.1", "resolved": false, "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -7946,6 +7877,7 @@ "resolved": false, "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -8041,7 +7973,8 @@ "version": "5.1.1", "resolved": false, "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -8083,6 +8016,7 @@ "resolved": false, "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -8104,6 +8038,7 @@ "resolved": false, "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -8152,13 +8087,15 @@ "version": "1.0.2", "resolved": false, "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "resolved": false, "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", - "dev": true + "dev": true, + "optional": true } } }, @@ -9292,39 +9229,6 @@ "vinyl-sourcemaps-apply": "^0.2.0" } }, - "gulp-rename": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.4.0.tgz", - "integrity": "sha512-swzbIGb/arEoFK89tPY58vg3Ok1bw+d35PfUNwWqdo7KM4jkmuGA78JiDNqR+JeZFaeeHnRg9N7aihX3YPmsyg==", - "dev": true - }, - "gulp-sourcemaps": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/gulp-sourcemaps/-/gulp-sourcemaps-2.6.4.tgz", - "integrity": "sha1-y7IAhFCxvM5s0jv5gze+dRv24wo=", - "dev": true, - "requires": { - "@gulp-sourcemaps/identity-map": "1.X", - "@gulp-sourcemaps/map-sources": "1.X", - "acorn": "5.X", - "convert-source-map": "1.X", - "css": "2.X", - "debug-fabulous": "1.X", - "detect-newline": "2.X", - "graceful-fs": "4.X", - "source-map": "~0.6.0", - "strip-bom-string": "1.X", - "through2": "2.X" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, "gulplog": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz", @@ -10557,12 +10461,24 @@ } }, "jest-worker": { - "version": "23.2.0", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-23.2.0.tgz", - "integrity": "sha1-+vcGqNo2+uYOsmlXJX+ntdjqArk=", + "version": "24.0.0", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-24.0.0.tgz", + "integrity": "sha512-s64/OThpfQvoCeHG963MiEZOAAxu8kHsaL/rCMF7lpdzo7vgF0CtPml9hfguOMgykgH/eOm4jFP4ibfHLruytg==", "dev": true, "requires": { - "merge-stream": "^1.0.1" + "merge-stream": "^1.0.1", + "supports-color": "^6.1.0" + }, + "dependencies": { + "supports-color": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", + "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } } }, "jju": { @@ -11820,7 +11736,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", - "dev": true + "dev": true, + "optional": true }, "minimalistic-assert": { "version": "1.0.1", @@ -12640,6 +12557,7 @@ "resolved": false, "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", "dev": true, + "optional": true, "requires": { "kind-of": "^3.0.2", "longest": "^1.0.1", @@ -13006,7 +12924,8 @@ "version": "1.1.6", "resolved": false, "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "dev": true + "dev": true, + "optional": true }, "is-builtin-module": { "version": "1.0.0", @@ -13102,6 +13021,7 @@ "resolved": false, "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -13154,7 +13074,8 @@ "version": "1.0.1", "resolved": false, "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", - "dev": true + "dev": true, + "optional": true }, "lru-cache": { "version": "4.1.3", @@ -13457,7 +13378,8 @@ "version": "1.6.1", "resolved": false, "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true + "dev": true, + "optional": true }, "require-directory": { "version": "2.1.1", @@ -15017,7 +14939,8 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", - "dev": true + "dev": true, + "optional": true }, "preserve": { "version": "0.2.0", @@ -15979,13 +15902,22 @@ } }, "rollup": { - "version": "0.66.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.66.2.tgz", - "integrity": "sha512-+rOLjWO170M3Y2jyyGU4ZJuTu1T1KuKNyH+RszHRzQdsuI5TulRbkSM4vlaMnwcxHm4XdgBNZ1mmNzhQIImbiQ==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.1.2.tgz", + "integrity": "sha512-OkdMxqMl8pWoQc5D8y1cIinYQPPLV8ZkfLgCzL6SytXeNA2P7UHynEQXI9tYxuAjAMsSyvRaWnyJDLHMxq0XAg==", "dev": true, "requires": { "@types/estree": "0.0.39", - "@types/node": "*" + "@types/node": "*", + "acorn": "^6.0.5" + }, + "dependencies": { + "acorn": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.0.tgz", + "integrity": "sha512-MW/FjM+IvU9CgBzjO3UIPCE2pyEwUsoFl+VGdczOPEdxfGFjuKny/gN54mOuX7Qxmb9Rg9MCn2oKiSUeW+pjrw==", + "dev": true + } } }, "rollup-plugin-babel": { @@ -16029,15 +15961,23 @@ } }, "rollup-plugin-terser": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-3.0.0.tgz", - "integrity": "sha512-Ed9zRD7OoCBnh0XGlEAJle5TCUsFXMLClwKzZWnS1zbNO4MelHjfCSdFZxCAdH70M40nhZ1nRrY2GZQJhSMcjA==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-4.0.4.tgz", + "integrity": "sha512-wPANT5XKVJJ8RDUN0+wIr7UPd0lIXBo4UdJ59VmlPCtlFsE20AM+14pe+tk7YunCsWEiuzkDBY3QIkSCjtrPXg==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "jest-worker": "^23.2.0", - "serialize-javascript": "^1.5.0", - "terser": "^3.8.2" + "jest-worker": "^24.0.0", + "serialize-javascript": "^1.6.1", + "terser": "^3.14.1" + }, + "dependencies": { + "serialize-javascript": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.6.1.tgz", + "integrity": "sha512-A5MOagrPFga4YaKQSWHryl7AXvbQkEqpw4NNYMTNYUNV51bA8ABHgYFpqKx+YFFrw59xMV1qGH1R4AgoNIVgCw==", + "dev": true + } } }, "rollup-pluginutils": { @@ -16150,23 +16090,6 @@ } } }, - "rollup-stream": { - "version": "1.24.1", - "resolved": "https://registry.npmjs.org/rollup-stream/-/rollup-stream-1.24.1.tgz", - "integrity": "sha512-iQ159xbWSOPc7ey8tjEYf7pCaQwBz3ov37KNCeDewqh6Qj1gntAgZSmmEJIPs2niXMDNqVZ3rnTFXBXhZ+sYSg==", - "dev": true, - "requires": { - "rollup": "^0.49.2" - }, - "dependencies": { - "rollup": { - "version": "0.49.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.49.3.tgz", - "integrity": "sha512-n/vHRX4GhMIyGZEQRANcSFVtvz99bSRbNMuoC33ar9f4CViqffyF9WklLb2mxIQ6I/uFf7wDEpc66bXBFE7FvA==", - "dev": true - } - } - }, "router": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/router/-/router-1.3.3.tgz", @@ -16882,9 +16805,9 @@ } }, "source-map-support": { - "version": "0.5.9", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.9.tgz", - "integrity": "sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA==", + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.10.tgz", + "integrity": "sha512-YfQ3tQFTK/yzlGJuX8pTwa4tifQj4QS2Mj7UegOu8jAz59MqIiMGPXxQhVQiIMNzayuUSF/jEuVnfFF5JqybmQ==", "dev": true, "requires": { "buffer-from": "^1.0.0", @@ -17197,12 +17120,6 @@ "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", "dev": true }, - "strip-bom-string": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz", - "integrity": "sha1-5SEekiQ2n7uB1jOi8ABE3IztrZI=", - "dev": true - }, "strip-eof": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", @@ -17554,14 +17471,14 @@ } }, "terser": { - "version": "3.8.2", - "resolved": "https://registry.npmjs.org/terser/-/terser-3.8.2.tgz", - "integrity": "sha512-FGSBXiBJe2TSXy6pWwXpY0YcEWEK35UKL64BBbxX3aHqM4Nj0RMqXvqBuoSGfyd80t8MKQ5JwYm5jRRGTSEFNg==", + "version": "3.16.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-3.16.1.tgz", + "integrity": "sha512-JDJjgleBROeek2iBcSNzOHLKsB/MdDf+E/BOAJ0Tk9r7p9/fVobfv7LMJ/g/k3v9SXdmjZnIlFd5nfn/Rt0Xow==", "dev": true, "requires": { "commander": "~2.17.1", "source-map": "~0.6.1", - "source-map-support": "~0.5.6" + "source-map-support": "~0.5.9" }, "dependencies": { "commander": { @@ -18626,16 +18543,6 @@ "replace-ext": "^1.0.0" } }, - "vinyl-buffer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/vinyl-buffer/-/vinyl-buffer-1.0.1.tgz", - "integrity": "sha1-lsGjR5uMU5JULGEgKQE7Wyf4i78=", - "dev": true, - "requires": { - "bl": "^1.2.1", - "through2": "^2.0.3" - } - }, "vinyl-fs": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-3.0.3.tgz", @@ -18661,16 +18568,6 @@ "vinyl-sourcemap": "^1.1.0" } }, - "vinyl-source-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/vinyl-source-stream/-/vinyl-source-stream-2.0.0.tgz", - "integrity": "sha1-84pa+53R6Ttl1VBGmsYYKsT1S44=", - "dev": true, - "requires": { - "through2": "^2.0.3", - "vinyl": "^2.1.0" - } - }, "vinyl-sourcemap": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/vinyl-sourcemap/-/vinyl-sourcemap-1.1.0.tgz", diff --git a/package.json b/package.json index 276edfc7f..d729c987e 100644 --- a/package.json +++ b/package.json @@ -78,8 +78,6 @@ "glob": "^7.1.3", "gulp": "^4.0.0", "gulp-babel": "^8.0.0", - "gulp-rename": "^1.4.0", - "gulp-sourcemaps": "^2.6.4", "gzip-size": "^5.0.0", "html-webpack-plugin": "^3.2.0", "jsdoc": "^3.5.5", @@ -93,12 +91,11 @@ "pre-push": "^0.1.1", "proxyquire": "^2.1.0", "require-dir": "^1.0.0", - "rollup": "^0.66.2", + "rollup": "^1.1.2", "rollup-plugin-babel": "^4.0.3", "rollup-plugin-node-resolve": "^4.0.0", "rollup-plugin-replace": "^2.0.0", - "rollup-plugin-terser": "^3.0.0", - "rollup-stream": "^1.24.1", + "rollup-plugin-terser": "^4.0.4", "selenium-assistant": "^5.4.0", "semver": "^5.5.1", "serve-index": "^1.9.1", @@ -107,8 +104,6 @@ "sinon": "^6.3.4", "tempy": "^0.2.1", "url-search-params": "^1.1.0", - "vinyl-buffer": "^1.0.1", - "vinyl-source-stream": "^2.0.0", "webpack": "^4.19.1" } } diff --git a/packages/workbox-build/package-lock.json b/packages/workbox-build/package-lock.json index 31237fdb9..3b9d612be 100644 --- a/packages/workbox-build/package-lock.json +++ b/packages/workbox-build/package-lock.json @@ -1,6 +1,6 @@ { "name": "workbox-build", - "version": "4.0.0-beta.2", + "version": "4.0.0-rc.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/workbox-build/src/lib/copy-workbox-libraries.js b/packages/workbox-build/src/lib/copy-workbox-libraries.js index 4626699f4..d0415f37e 100644 --- a/packages/workbox-build/src/lib/copy-workbox-libraries.js +++ b/packages/workbox-build/src/lib/copy-workbox-libraries.js @@ -8,16 +8,11 @@ const fse = require('fs-extra'); const path = require('path'); - const errors = require('./errors'); -const useBuildType = require('./use-build-type'); + // Used to filter the libraries to copy based on our package.json dependencies. const WORKBOX_PREFIX = 'workbox-'; -const BUILD_TYPES = [ - 'dev', - 'prod', -]; /** * This copies over a set of runtime libraries used by Workbox into a @@ -53,23 +48,8 @@ module.exports = async (destDirectory) => { const librariesToCopy = Object.keys(thisPkg.dependencies).filter( (dependency) => dependency.startsWith(WORKBOX_PREFIX)); for (const library of librariesToCopy) { - const pkg = require(`${library}/package.json`); - const defaultPathToLibrary = require.resolve(`${library}/${pkg.main}`); - - for (const buildType of BUILD_TYPES) { - // Special-case logic for workbox-sw, which only has a single build type. - // This prevents a race condition with two identical copy promises; - // see https://github.com/GoogleChrome/workbox/issues/1180 - if (library === 'workbox-sw' && buildType === BUILD_TYPES[0]) { - continue; - } - - const srcPath = useBuildType(defaultPathToLibrary, buildType); - const destPath = path.join(workboxDirectoryPath, - path.basename(srcPath)); - copyPromises.push(fse.copy(srcPath, destPath)); - copyPromises.push(fse.copy(`${srcPath}.map`, `${destPath}.map`)); - } + copyPromises.push(fse.copy( + path.join('packages', library, 'build'), workboxDirectoryPath)); } try { diff --git a/packages/workbox-build/src/lib/use-build-type.js b/packages/workbox-build/src/lib/use-build-type.js deleted file mode 100644 index 764b5d4e2..000000000 --- a/packages/workbox-build/src/lib/use-build-type.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright 2018 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -// This is the build type that is expected to be present "by default". -const DEFAULT_BUILD_TYPE = 'prod'; - -/** - * Switches a string from using the "default" build type to an alternative - * build type. In practice, this is used to swap out "prod" for "dev" in the - * filename of a Workbox library. - * - * @param {string} source The path to a file, which will normally contain - * DEFAULT_BUILD_TYPE somewhere in it. - * @param {string} buildType The alternative build type value to swap in. - * @return {string} source, with the last occurrence of DEFAULT_BUILD_TYPE - * replaced with buildType. - * @private - */ -module.exports = (source, buildType) => { - // If we want the DEFAULT_BUILD_TYPE, then just return things as-is. - if (buildType === DEFAULT_BUILD_TYPE) { - return source; - } - // Otherwise, look for the last instance of DEFAULT_BUILD_TYPE, and replace it - // with the new buildType. This is easier via split/join than RegExp. - const parts = source.split(DEFAULT_BUILD_TYPE); - // Join the last two split parts with the new buildType. (If parts only has - // one item, this will be a no-op.) - const replaced = parts.slice(parts.length - 2).join(buildType); - // Take the remaining parts, if any exist, and join them with the replaced - // part using the DEFAULT_BUILD_TYPE, to restore any other matches as-is. - return [ - ...parts.slice(0, parts.length - 2), - replaced, - ].join(DEFAULT_BUILD_TYPE); -}; diff --git a/packages/workbox-cli/package-lock.json b/packages/workbox-cli/package-lock.json index a89b9946b..8326a79fa 100644 --- a/packages/workbox-cli/package-lock.json +++ b/packages/workbox-cli/package-lock.json @@ -1,6 +1,6 @@ { "name": "workbox-cli", - "version": "4.0.0-beta.2", + "version": "4.0.0-rc.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -786,7 +786,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -804,11 +805,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -821,15 +824,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -932,7 +938,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -942,6 +949,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -954,17 +962,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -981,6 +992,7 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -1053,7 +1065,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -1063,6 +1076,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -1138,7 +1152,8 @@ }, "safe-buffer": { "version": "5.1.1", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -1168,6 +1183,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -1185,6 +1201,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -1223,11 +1240,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.0.2", - "bundled": true + "bundled": true, + "optional": true } } }, diff --git a/packages/workbox-webpack-plugin/package-lock.json b/packages/workbox-webpack-plugin/package-lock.json index e3937bbbd..7361d10d6 100644 --- a/packages/workbox-webpack-plugin/package-lock.json +++ b/packages/workbox-webpack-plugin/package-lock.json @@ -1,6 +1,6 @@ { "name": "workbox-webpack-plugin", - "version": "4.0.0-beta.2", + "version": "4.0.0-rc.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/workbox-window/package.json b/packages/workbox-window/package.json index cfbf68b58..5ebebef33 100644 --- a/packages/workbox-window/package.json +++ b/packages/workbox-window/package.json @@ -22,9 +22,10 @@ "prepare": "npm run build" }, "workbox": { - "packageType": "window" + "packageType": "window", + "primaryBuild": "build/workbox-window.prod.mjs" }, - "main": "build/workbox-window.prod.mjs", + "main": "build/workbox-window.prod.umd.js", "module": "index.mjs", "dependencies": { "workbox-core": "^4.0.0-rc.0" diff --git a/test/workbox-build/node/entry-points/generate-sw.js b/test/workbox-build/node/entry-points/generate-sw.js index 8e050c391..51e94146c 100644 --- a/test/workbox-build/node/entry-points/generate-sw.js +++ b/test/workbox-build/node/entry-points/generate-sw.js @@ -154,7 +154,7 @@ describe(`[workbox-build] entry-points/generate-sw.js (End to End)`, function() expect(size).to.eql(2604); // Validate the copied library files. - const libraryFiles = glob.sync(`${WORKBOX_DIRECTORY_PREFIX}*/*.js*`, + const libraryFiles = glob.sync(`${WORKBOX_DIRECTORY_PREFIX}*/*.+(js|mjs)*`, {cwd: path.dirname(swDest)}); const modulePathPrefix = path.dirname(libraryFiles[0]); @@ -211,9 +211,16 @@ describe(`[workbox-build] entry-points/generate-sw.js (End to End)`, function() 'workbox-streams.prod.js.map', 'workbox-sw.js', 'workbox-sw.js.map', + 'workbox-window.dev.mjs', + 'workbox-window.dev.mjs.map', + 'workbox-window.dev.umd.js', + 'workbox-window.dev.umd.js.map', + 'workbox-window.prod.mjs', + 'workbox-window.prod.mjs.map', + 'workbox-window.prod.umd.js', + 'workbox-window.prod.umd.js.map', ]); - // The correct importScripts path should use the versioned name of the // parent workbox libraries directory. We don't know that version ahead // of time, so we ensure that there's a match based on what actually diff --git a/test/workbox-build/node/lib/copy-workbox-libraries.js b/test/workbox-build/node/lib/copy-workbox-libraries.js index aef759df8..9d2fcecc1 100644 --- a/test/workbox-build/node/lib/copy-workbox-libraries.js +++ b/test/workbox-build/node/lib/copy-workbox-libraries.js @@ -52,10 +52,8 @@ describe(`[workbox-build] lib/copy-workbox-libraries.js`, function() { const expectedPath = path.join(destDir, workboxDirectory); expect(expectedPath).to.eql(ensureDirStub.args[0][0]); - // This reflects the number of library files that were copied over: - // - both prod and dev builds (except for workbox-sw.js, which is a single build) - // - source maps for each - expect(copyStub.callCount).to.eql(54); + // The total number of package build directories that were copied: + expect(copyStub.callCount).to.eql(14); }); } }); diff --git a/test/workbox-build/node/lib/use-build-type.js b/test/workbox-build/node/lib/use-build-type.js deleted file mode 100644 index 92091a1a6..000000000 --- a/test/workbox-build/node/lib/use-build-type.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright 2018 Google LLC - - Use of this source code is governed by an MIT-style - license that can be found in the LICENSE file or at - https://opensource.org/licenses/MIT. -*/ - -const expect = require('chai').expect; - -const useBuildType = require('../../../../packages/workbox-build/src/lib/use-build-type'); - -describe(`[workbox-build] lib/use-build-type.js`, function() { - it(`should not update anything when buildType is 'prod'`, function() { - const result = useBuildType('/path/to/workbox.prod.js', 'prod'); - expect(result).to.eql('/path/to/workbox.prod.js'); - }); - - it(`should update when buildType is 'dev'`, function() { - const result = useBuildType('/path/to/workbox.prod.js', 'dev'); - expect(result).to.eql('/path/to/workbox.dev.js'); - }); - - it(`should only update the last match when buildType is 'dev'`, function() { - const result = useBuildType('/path/to/production/and.prod.check/workbox.prod.js', 'dev'); - expect(result).to.eql('/path/to/production/and.prod.check/workbox.dev.js'); - }); - - it(`should not update anything if there is no match for the default build type`, function() { - const result = useBuildType('/does/not/match', 'dev'); - expect(result).to.eql('/does/not/match'); - }); -}); diff --git a/test/workbox-webpack-plugin/node/generate-sw.js b/test/workbox-webpack-plugin/node/generate-sw.js index 8d57ca890..c9f5ca453 100644 --- a/test/workbox-webpack-plugin/node/generate-sw.js +++ b/test/workbox-webpack-plugin/node/generate-sw.js @@ -77,6 +77,14 @@ describe(`[workbox-webpack-plugin] GenerateSW (End to End)`, function() { 'workbox-streams.prod.js.map', 'workbox-sw.js', 'workbox-sw.js.map', + 'workbox-window.dev.mjs', + 'workbox-window.dev.mjs.map', + 'workbox-window.dev.umd.js', + 'workbox-window.dev.umd.js.map', + 'workbox-window.prod.mjs', + 'workbox-window.prod.mjs.map', + 'workbox-window.prod.umd.js', + 'workbox-window.prod.umd.js.map', ]; describe(`[workbox-webpack-plugin] runtime errors`, function() { @@ -365,7 +373,7 @@ describe(`[workbox-webpack-plugin] GenerateSW (End to End)`, function() { expect(statsJson.warnings).to.have.lengthOf(0); // Validate the copied library files. - const libraryFiles = glob.sync(`${WORKBOX_DIRECTORY_PREFIX}*/*.js*`, + const libraryFiles = glob.sync(`${WORKBOX_DIRECTORY_PREFIX}*/*.+(js|mjs)*`, {cwd: outputDir}); const modulePathPrefix = path.dirname(libraryFiles[0]); @@ -442,7 +450,7 @@ describe(`[workbox-webpack-plugin] GenerateSW (End to End)`, function() { expect(statsJson.warnings).to.have.lengthOf(0); // Validate the copied library files. - const libraryFiles = glob.sync(`${WORKBOX_DIRECTORY_PREFIX}*/*.js*`, + const libraryFiles = glob.sync(`${WORKBOX_DIRECTORY_PREFIX}*/*.+(js|mjs)*`, {cwd: outputDir}); const modulePathPrefix = path.dirname(libraryFiles[0]); @@ -1589,7 +1597,7 @@ describe(`[workbox-webpack-plugin] GenerateSW (End to End)`, function() { const swFile = path.join(outputDir, 'service-worker.js'); // Validate the copied library files. - const libraryFiles = glob.sync(`${WORKBOX_DIRECTORY_PREFIX}*/*.js*`, + const libraryFiles = glob.sync(`${WORKBOX_DIRECTORY_PREFIX}*/*.+(js|mjs)*`, {cwd: path.join(outputDir, importsDirectory)}); const modulePathPrefix = path.dirname(libraryFiles[0]); diff --git a/test/workbox-webpack-plugin/node/inject-manifest.js b/test/workbox-webpack-plugin/node/inject-manifest.js index 1dfd37d37..a25e11421 100644 --- a/test/workbox-webpack-plugin/node/inject-manifest.js +++ b/test/workbox-webpack-plugin/node/inject-manifest.js @@ -78,6 +78,14 @@ describe(`[workbox-webpack-plugin] InjectManifest (End to End)`, function() { 'workbox-streams.prod.js.map', 'workbox-sw.js', 'workbox-sw.js.map', + 'workbox-window.dev.mjs', + 'workbox-window.dev.mjs.map', + 'workbox-window.dev.umd.js', + 'workbox-window.dev.umd.js.map', + 'workbox-window.prod.mjs', + 'workbox-window.prod.mjs.map', + 'workbox-window.prod.umd.js', + 'workbox-window.prod.umd.js.map', ]; describe(`[workbox-webpack-plugin] runtime errors`, function() { @@ -380,7 +388,7 @@ describe(`[workbox-webpack-plugin] InjectManifest (End to End)`, function() { expect(statsJson.warnings).to.have.lengthOf(0); // Validate the copied library files. - const libraryFiles = glob.sync(`${WORKBOX_DIRECTORY_PREFIX}*/*.js*`, + const libraryFiles = glob.sync(`${WORKBOX_DIRECTORY_PREFIX}*/*.+(js|mjs)*`, {cwd: outputDir}); const modulePathPrefix = path.dirname(libraryFiles[0]); @@ -460,7 +468,7 @@ describe(`[workbox-webpack-plugin] InjectManifest (End to End)`, function() { expect(statsJson.warnings).to.have.lengthOf(0); // Validate the copied library files. - const libraryFiles = glob.sync(`${WORKBOX_DIRECTORY_PREFIX}*/*.js*`, + const libraryFiles = glob.sync(`${WORKBOX_DIRECTORY_PREFIX}*/*.+(js|mjs)*`, {cwd: outputDir}); const modulePathPrefix = path.dirname(libraryFiles[0]); @@ -1757,7 +1765,7 @@ describe(`[workbox-webpack-plugin] InjectManifest (End to End)`, function() { const swFile = path.join(outputDir, path.basename(SW_SRC)); // Validate the copied library files. - const libraryFiles = glob.sync(`${WORKBOX_DIRECTORY_PREFIX}*/*.js*`, + const libraryFiles = glob.sync(`${WORKBOX_DIRECTORY_PREFIX}*/*.+(js|mjs)*`, {cwd: path.join(outputDir, importsDirectory)}); const modulePathPrefix = path.dirname(libraryFiles[0]);