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

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

Closed
mfbx9da4 opened this issue Dec 30, 2020 · 4 comments · Fixed by #2716
Closed

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

mfbx9da4 opened this issue Dec 30, 2020 · 4 comments · Fixed by #2716
Labels
Bug An issue with our existing, production codebase. workbox-build

Comments

@mfbx9da4
Copy link

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)

@mfbx9da4
Copy link
Author

I saw #2559 it's probably related?

@jeffposnick
Copy link
Contributor

jeffposnick commented Jan 7, 2021

Hello!

So it turns out this is due to mozilla/source-map#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.

@jeffposnick jeffposnick added Bug An issue with our existing, production codebase. workbox-build labels Jan 7, 2021
@jeffposnick jeffposnick changed the title Webpack plugin InjectManifest nextjs source maps "You must provide the URL of lib/mappings.wasm by calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using SourceMapConsumer" source-map build dependency breaks when fetch() is polyfilled Jan 7, 2021
@mfbx9da4
Copy link
Author

mfbx9da4 commented Jan 8, 2021

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

@jeffposnick
Copy link
Contributor

This is included in the v6.1.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug An issue with our existing, production codebase. workbox-build
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants