Ability to disable sourcemap generation in dev
for large files, i.e Astro 5's data layer
#19218
Closed
4 tasks done
Labels
Description
Astro 5's Content Layer leverages a data store snapshot, implemented as a virtual module called
astro:data-layer-content
.When editing a file in
astro dev
, the content of the data store changes and the virtual module is transformed & run as an inline module by Vite:A lot of the time is spent generating a sourcemap for this module (which takes the shape of a large
export default [...]
). In large sites, this module can be upwards of 20 megabytes.With a module that is 25.49 MB, a 54.23 MB sourcemap is created with
MagicString#generateMap({ hires: true })
and 132.99 MB of code is eventually evaluated.Sourcemaps in
ssrTransformScript
Patch
Output
Inlining sourcemap in
inlineSourceMap
Patch
Output
Evaluating code in
runInlinedModule
.Patch
Output
Combined
Output
Generating the sourcemap, inlining it and then executing the code takes ~2.75 seconds - which represents the majority of the ~3.5 seconds to reload a page in SSR.
Suggested solution
A configuration option to, if possible, avoid creating sourcemaps for specific files.
I am not well-versed in JavaScript sourcemaps so there may be caveats, or that it simply isn't possible even if a file is not importing any other modules, to this suggestion.
Whilst this module will always need to be evaluated, the slowdown in
runInlinedModule
seems to be attributed to the size of the inlined sourcemap.Alternative
Astro itself had a Vite plugin generating sourcemaps for this file when it wasn't required, but that has been fixed in withastro/astro#13001 so the only remaining generation is being done by Vite.
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: