Skip to content

Commit

Permalink
Fix a bug with remapping when dist is run a second time (#37653)
Browse files Browse the repository at this point in the history
This is fun. When babel performs internal remapping (when there is an input sourcemap), it just fails to output a valid sourcemap if the output has multiple source files (I actually recently fixed this...). When esbuild generates a sourcemap, it'll link to the map file with a `sourceMappingUrl` comment. Babel will try see that comment, and interpret the sourcemap as an input. And we hit the bug if the output has multiple sources.

This works fine on the initial build, because the map file hasn't been written to disk yet. But on a re-dist, the map file will exist, and babel will read it. This will cause a bug in our `@ampproject/remapping`, because we see a transformation that outputs an invalid map (and we throw an error).
  • Loading branch information
jridgewell committed Feb 11, 2022
1 parent 00241ce commit 9609fe3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion build-system/tasks/helpers.js
Expand Up @@ -346,7 +346,7 @@ async function esbuildCompile(srcDir, srcFilename, destDir, options) {
result = await esbuild.build({
entryPoints: [entryPoint],
bundle: true,
sourcemap: true,
sourcemap: 'external',
sourceRoot: path.dirname(destFile),
sourcesContent: !!argv.full_sourcemaps,
outfile: destFile,
Expand Down

0 comments on commit 9609fe3

Please sign in to comment.