Next.js Discord

Discord Forum

Can `nextRuntime: edge` output source maps?

Unanswered
Doberman Pinscher posted this in #help-forum
Open in Discord
Avatar
Doberman PinscherOP
Hey 👋

I'm working on a Next.js integration for https://sonda.dev/. Sonda is a visualizer and analyzer for JS and CSS bundles that makes heavy use of source maps.

The integration itself is almost done and works fine in a fresh Next.js project. It appears that webpack is run 3 times to generate bundles for client, nodejs and edge. However, the report for edge runtime is empty because none of the files generated during this run have source maps.

My question is: Can this build ever produce files that have source maps (with different Next.js configuration, plugins, etc.), or can I simplify ignore this run and only generate reports for client and node.js env?

Here's the simplified code:

export default function SondaNextPlugin( options = {} ) {
  return function withSondaAnalyzer( nextConfig = {} ) {
    return Object.assign( {}, nextConfig, {

      // Enable source maps for client builds
      productionBrowserSourceMaps: true,

      webpack( config, context ) {
        if ( context.isServer ) {
          // Enable source maps for server builds
          config.devtool = 'source-map';
        }

        // context.nextRuntime can be `undefined`, `edge`, `nodejs`
      }
    } );
  }
}

0 Replies