-
Notifications
You must be signed in to change notification settings - Fork 289
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
ncc 0.33 outputs source map twice #827
Comments
Sounds like it could be related to #818 cc @fenix20113 Feel free to submit a PR with a test if you have a fix 👍 |
I'm not sure which issue you're referring to since you're mentioning the issue itself. In all cases I'll have a look if I can find a way to fix this and make a PR :) |
Oops, I must have pasted the wrong ID. That was supposed to be #818 😅 Thanks for looking into it 👍 |
Ah yes that's the PR I linked to in the initial post :) I made some investigation and here are my findings. Changes between 0.31.1 -> 0.32.0There was indeed a change in how webpack handled sourcemaps, and it was in fact a bugfix. It seems that in 0.31.1, webpack ignored that information and simply took the entry's filename Changes between 0.32.0 -> 0.33.0Most probably because of this fix, PR #818 was created and introduced this specific change : Which causes the sourcemap being set to the ncc("myinput.js", {}).then(async ({ code, map, assets }) => {
// both values are identical
map === assets['index.js.map'].source
}); It is however possible to set a ncc("myinput.js", {
filename: "somefile.js"
}).then(async ({ code, map, assets }) => {
// both values are identical
map === assets['somefile.js.map'].source
}); By setting the filename I was able to get the result I wanted to obtain initially Conclusion and possible actionsSo in the end there is nothing wrong per-se. Filename always defaults to Having a separate key for Another possibility is to automatically set the filename by the input filename if it's not already set. What do you think ? |
Hmm, I typically use the CLI, not the programatic API and I don't use source maps often, so I haven't seen this issue yet.
I think the reason why @guybedford @ijjk @javivelasco Any thoughts here? |
Yes I understand and completely agree with that reasoning for the CLI, but when using the programmatic API you're given a variable and have the role of writing that to a file, thus giving you a false sense of control on the name of that file, but if you are using sourcemaps you actually have to write it to |
Yes, I have the same issue: $ npm run build
> ncc build -sdm src/index.ts
ncc: Version 0.33.0
ncc: Compiling file index.js into CJS
ncc: Using typescript@4.5.3 (local user-provided)
Emitting /home/fengyu/projects/ncc-test/assets/test.txt for static use in module /home/fengyu/projects/ncc-test/src/index.ts
0kB dist/test.txt
1kB dist/index.js
4kB dist/index.js.map
4kB dist/index.js.map
40kB dist/sourcemap-register.js
45kB [1152ms] - ncc 0.33.0
|
Sourcemaps have become weirder and weirder from 0.31 to 0.32 and then 0.33.
0.31.1
Giving an entry file of
babel-packages.js
would emit a sourcemap and add the comment//# sourceMappingURL=babel-packages.js.map
at the end of the file.0.32.0
For the same input, emits a sourcemap and adds the comment
//# sourceMappingURL=index.js.map
no matter what the input file name is0.33.0
For the same input, emits two sourcemaps and adds the comment
//# sourceMappingURL=index.js.map
.One is emitted as an asset, one in the
map
argument. ( most probably related to that change : https://github.com/vercel/ncc/pull/818/files#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556R504-R507 )This is problematic because I might have more than one bundle and if they all have
index.js.map
that's not gonna work :/Here is the script I'm using :
https://github.com/swissquote/crafty/blob/master/utils/compile.js#L19-L49
And the output with 0.33.0
As you can see the two lines
Writing dist/compiled/index.js.map 1.21 MB
andWriting dist/compiled/babel-packages.js.map 1.21 MB
have the same size and are in fact identical.The initial change was introduced somewhere between 0.31.1 to 0.32.0 : 0.31.1...0.32.0
My bet would be something in between Webpack 5.44.0 and 5.62.1
The text was updated successfully, but these errors were encountered: