question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Copy polyfills source maps

See original GitHub issue

Feature request

I would like to request a feature to copy source maps from polyfills to next build. Currently, the source maps are skipped but js file still contains a reference to it.

This request is very related to https://github.com/zeit/next.js/issues/7579 but I decided to report it separately since it probably requires a different bunch of work. Feel free to close if you find it duplicate.

Is your feature request related to a problem? Please describe.

We use source map loader in our app which allows us to include third-party source maps in our build. It is extremely helpful especially in conjunction with Sentry. It helps us track down bugs easily and eventually if it is not a bug on our side then report it to correct package maintainers.

I prepared MWE for you when you run the app and open chrome console you will see something like:

Can't resolve './unfetch.js.map' in '/mnt/c/Users/joozty/Documents/next-source-maps/node_modules/next/dist/build/polyfills'

sm

it happens because unfetch.js file copied here contains a reference to a source map which is not copied. (It’s probably the same for other polyfills too.)

Describe the solution you’d like

I would like to have these source maps included. It’s not a big deal and this warning can be ignored but as I mentioned earlier it’s a nice feature for having bug free JS ecosystem. 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Jooztycommented, Aug 3, 2020

For anybody affected by this issue. You may disable source map preloader for these specific modules/files like this:

    config.module.rules.push(
      {
        test: /.*\.js$/,
        // disable these modules because they generate a lot of warnings about
        // non existing source maps
        // we cannot filter these warnings via config.stats.warningsFilter
        // because Next.js doesn't allow it
        // https://github.com/vercel/next.js/pull/7550#issuecomment-512861158
        // https://github.com/vercel/next.js/issues/12861
        exclude: [
          /@next\/react-dev-overlay/,
          /@next\/react-refresh-utils\/runtime.js$/,
          /@next\/react-refresh-utils\/internal\/helpers.js$/,
          /next\/dist\/build\/polyfills\/unfetch.js$/,
          /next\/dist\/build\/polyfills\/unfetch.js$/,
        ],
        use: ['source-map-loader'],
        enforce: 'pre',
      }
    )
1reaction
maxigimenezcommented, May 19, 2020

@timneutkens I would love to take this one, one approach could be copying the .map file onto the build, what do you think?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Copy polyfills source maps · Issue #12861 · vercel/next.js
I would like to request a feature to copy source maps from polyfills to next build. Currently, the source maps are skipped but...
Read more >
Create single JS including SourceMaps from Angular 9
The fundamental issue is that Angular CLI creates source maps per JS file, ie. 1 for main.js, 1 for polyfill.js, 1 for runtime.js...
Read more >
Babel CLI & Polyfill Tutorial - CodingCompiler
Compile Files; Compile with Source Maps; Compile Directories; Ignore files; Copy files; Piping Files; Using Plugins; Using Presets ...
Read more >
Javascript Debugging Made Easier with Sourcemaps
Sourcemaps bacically are a way to map the combined/minified file back to the original file. As part of the minification process you generate ......
Read more >
Using the compiler | The AssemblyScript Book
For easier debugging during development, a source map can be emitted alongside the ... dependency polyfills support for import maps where not yet...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found