-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Selectively exclude paths from sourcemap generation #19365
Comments
Perhaps duplicate of #19187 I haven't properly tested, but does this work in user land? #19187 (comment) |
I saw that one but it seems not clear to me what the author there wants and they are not proposing an API either, while I think my request is clear in itself. I will try your plugin example as it looks like a good workaround, but it seems like a suboptimal solution as it removes sourcemaps after they have been already generated, while ideally they should not generate in first place. |
I'm not sure what "already generated" means and its performance cost. I have to dig deeper, but potentially most expensive operation of source map collapse (aka remapping) should become trivial/cheap when the last plugin returns |
I don't understand rollup in such detail, but do you mean if any plugin in the chain returns |
To elaborate on my last comment, source map collapse (e.g. rollup code) traces mapping from the last one back to original source, so for the following plugin transform chain example, rollup's source map collapse should become trivial. But when any other plugin generates plugin transform chain{
plugins: [
{
name: "someone's-plugin1",
transform(code) {
const result = babel.transform(code, {
sourceMaps: true, // <-- unavoidable
plugins: [/* ... some transform ... */]
})
return {
code: result.code,
map: result.map,
}
}
},
{
name: "someone's-plugin2",
transform(code) {
const ms = new MagicString(code);
// ... some transform ...
return {
code: ms.toString(),
map: ms.generateMap({ hires: 'boundary' }) // <-- unavoidable
}
}
},
{
name: "my-strip-mappings",
transform(code) {
return {
code,
map: { mappings: '' }
}
}
},
]
} |
Description
build.sourcemap
currently only allows to enable or disable all sourcemap generation, but sometimes it would be useful to selectively choose for which paths to generate source maps for, to reduce overall asset output size.Suggested solution
In webpack, one can specify
include
andexclude
regexp patterns, but I would propose a more flexible API where a new option accepts a function which tests whether a sourcemap should be generated for each asset path:Semi-related is Rollup's sourcemapIgnoreList API, but unfortunately, it can not be used to exclude paths from sourcemap generation as per rollup/rollup#5069.
Alternative
No alternatives currently because neither rollup nor vite offer options to exclude paths from sourcemaps.
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: