source-map build dependency breaks when fetch() is polyfilled
Brought to you by:
tomkozak
Originally created by: mfbx9da4
Library Affected:
workbox-webpack-plugin
Issue or Feature Request Description:
When combining source maps with webpack and workbox I get the following error at build time.
> next build
info - Creating an optimized production build
Failed to compile.
You must provide the URL of lib/mappings.wasm by calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using SourceMapConsumer
> Build error occurred
Error: > Build failed because of webpack errors
at /Users/DavidAdler/code/with-typescript-app/node_modules/next/dist/build/index.js:15:918
at async /Users/DavidAdler/code/with-typescript-app/node_modules/next/dist/build/tracer.js:1:525
My nextjs webpack config looks like so
const { InjectManifest } = require('workbox-webpack-plugin')
const withSourceMaps = require('@zeit/next-source-maps')
module.exports = withSourceMaps({
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.plugins.push(
new InjectManifest({
swSrc: './sw.js',
})
)
return config
},
})
A minimal failing example can be found here
To recreate run npm run build (after cloning and npm install)
Originally posted by: mfbx9da4
I saw https://github.com/GoogleChrome/workbox/issues/2559 it's probably related?
Originally posted by: jeffposnick
Hello!
So it turns out this is due to https://github.com/mozilla/source-map/issues/349
I'm assuming that Next.js polyfills
fetch()in some way?source-mapv0.8.0-beta.0apparently resolves the issue, even if there's afetch()polyfill. Based on the discussion in that issue I linked to, it doesn't sound like there's going to be av0.8.0stable anytime soon, so I think we can resolve this by updating tov0.8.0-beta.0in the next release of Workbox.Originally posted by: mfbx9da4
Thanks @jeffposnick, this will be a huge help to the nextjs community.
Ticket changed by: jeffposnick
Originally posted by: jeffposnick
This is included in the v6.1.0 release.