Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

importScriptsViaChunks checks for .js extension #2164

Merged
merged 2 commits into from
Aug 2, 2019

Conversation

jeffposnick
Copy link
Contributor

R: @philipwalton

Fixes #2161

I think this is a reasonable restriction, and allowing developers to customize things to allow for non-.js extensions seems like overkill.

(importScripts() will never play nicely with ES modules, so .mjs is a non-issue.)

@workbox-pr-bot
Copy link
Collaborator

PR-Bot Size Plugin

Changed File Sizes

No file sizes have changed.

New Files

No new files have been added.

All File Sizes

View Table
File Before After Change GZipped
packages/workbox-background-sync/build/workbox-background-sync.prod.js 3.86 KB 3.86 KB 0% 1.60 KB
packages/workbox-broadcast-update/build/workbox-broadcast-update.prod.js 1.92 KB 1.92 KB 0% 959 B
packages/workbox-build/build/_types.js 41 B 41 B 0% 61 B
packages/workbox-build/build/index.js 3.30 KB 3.30 KB 0% 1.31 KB
packages/workbox-cacheable-response/build/workbox-cacheable-response.prod.js 594 B 594 B 0% 354 B
packages/workbox-cli/build/app.js 4.16 KB 4.16 KB 0% 1.64 KB
packages/workbox-cli/build/bin.js 940 B 940 B 0% 502 B
packages/workbox-core/build/workbox-core.prod.js 5.94 KB 5.94 KB 0% 2.46 KB
packages/workbox-expiration/build/workbox-expiration.prod.js 2.94 KB 2.94 KB 0% 1.27 KB
packages/workbox-google-analytics/build/workbox-offline-ga.prod.js 1.95 KB 1.95 KB 0% 912 B
packages/workbox-navigation-preload/build/workbox-navigation-preload.prod.js 660 B 660 B 0% 323 B
packages/workbox-precaching/build/workbox-precaching.prod.js 4.89 KB 4.89 KB 0% 1.90 KB
packages/workbox-range-requests/build/workbox-range-requests.prod.js 1.57 KB 1.57 KB 0% 797 B
packages/workbox-routing/build/workbox-routing.prod.js 3.09 KB 3.09 KB 0% 1.36 KB
packages/workbox-strategies/build/workbox-strategies.prod.js 4.10 KB 4.10 KB 0% 1.13 KB
packages/workbox-streams/build/workbox-streams.prod.js 1.46 KB 1.46 KB 0% 721 B
packages/workbox-sw/build/workbox-sw.js 1.34 KB 1.34 KB 0% 748 B
packages/workbox-webpack-plugin/build/generate-sw.js 3.71 KB 3.71 KB 0% 1.40 KB
packages/workbox-webpack-plugin/build/index.js 349 B 349 B 0% 255 B
packages/workbox-webpack-plugin/build/inject-manifest.js 4.68 KB 4.68 KB 0% 1.59 KB
packages/workbox-window/build/workbox-window.dev.umd.js 41.34 KB 41.34 KB 0% 9.09 KB
packages/workbox-window/build/workbox-window.prod.umd.js 4.65 KB 4.65 KB 0% 1.91 KB

Workbox Aggregate Size Plugin

3.5KB gzip'ed (23% of limit)
7.79KB uncompressed

Copy link
Member

@philipwalton philipwalton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one question that definitely shouldn't block merging.

@@ -17,7 +19,10 @@ module.exports = (compilation, chunkNames) => {
const chunk = chunks.find((chunk) => chunk.names.includes(chunkName));
if (chunk) {
for (const file of chunk.files) {
scriptFiles.add(resolveWebpackURL(publicPath, file));
// See https://github.com/GoogleChrome/workbox/issues/2161
if (upath.extname(file) === '.js') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt non-js extensions ever happen with webpack chunks, but I wonder if we want to be a bit more forgiving here and accept things like .mjs. What do you think?

Copy link
Contributor Author

@jeffposnick jeffposnick Aug 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment in the PR description 😄

(importScripts() will never play nicely with ES modules, so .mjs is a non-issue.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gah, sorry, missed that!

@jeffposnick jeffposnick merged commit 4e770a6 into master Aug 2, 2019
@jeffposnick jeffposnick deleted the import-chunks-js-check branch August 2, 2019 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

workbox-webpack-plugin: importScriptsViaChunks also imports the sourcemap
3 participants