Menu

#2712 source-map build dependency breaks when fetch() is polyfilled

closed
nobody
2021-01-29
2020-12-30
Anonymous
No

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)

Related

Tickets: #2716

Discussion

  • Anonymous

    Anonymous - 2020-12-30

    Originally posted by: mfbx9da4

    I saw https://github.com/GoogleChrome/workbox/issues/2559 it's probably related?

     
  • Anonymous

    Anonymous - 2021-01-07

    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-map v0.8.0-beta.0 apparently resolves the issue, even if there's a fetch() polyfill. Based on the discussion in that issue I linked to, it doesn't sound like there's going to be a v0.8.0 stable anytime soon, so I think we can resolve this by updating to v0.8.0-beta.0 in the next release of Workbox.

     
  • Anonymous

    Anonymous - 2021-01-08

    Originally posted by: mfbx9da4

    Thanks @jeffposnick, this will be a huge help to the nextjs community.

     
  • Anonymous

    Anonymous - 2021-01-08

    Ticket changed by: jeffposnick

    • status: open --> closed
     
  • Anonymous

    Anonymous - 2021-01-29

    Originally posted by: jeffposnick

    This is included in the v6.1.0 release.

     

Log in to post a comment.