Skip to content
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

Using source map doubles memory usage #596

Open
ninja- opened this issue Sep 23, 2020 · 7 comments
Open

Using source map doubles memory usage #596

ninja- opened this issue Sep 23, 2020 · 7 comments
Labels
enhancement New feature or request

Comments

@ninja-
Copy link

ninja- commented Sep 23, 2020

Running app after compiling with -s option uses ~ 320MB on start, while without the flag it's 150-200MB.
Running pure typescript compiled version, even with require('source-map-support'), does not have this problem

@ninja-
Copy link
Author

ninja- commented Sep 23, 2020

I did a test, replaced the custom source map require in index.js with regular require('source-map-support')
It makes the map lazy load at least, but on the first Error printed memory usage jumps from 120MB to 360MB :/ 280MB after some GC

@ninja-
Copy link
Author

ninja- commented Sep 23, 2020

Using

nosources-source-map as devtool seems like a much better choice, it provides line numbers and original files but without using all the source code that you're not going to use anyway without chrome debugger.
It doesn't seem to help that much with mem usage though...but map is now 30% previous size

@ninja-
Copy link
Author

ninja- commented Sep 24, 2020

I tried to use nodejs native integration --enable-source-maps instead, and it seems to work better.
But still, when it tries to read the sourcemap there is big memory usage jump - but at least it later garbage collects the map...
It would probably be best if ncc split compiled app to 10 files, then having sourcemaps 10% the size probably wouldn't be such a problem.

@styfle
Copy link
Member

styfle commented Jun 2, 2021

Now that --enable-source-maps is stable and supported back to Node.js 12, we could probably avoid the legacy polyfill used to support older versions of node and instead instruct the user to run node --enable-source-maps dist/index.js if they want source map support at runtime.

@styfle styfle added the enhancement New feature or request label Jun 2, 2021
@ninja-
Copy link
Author

ninja- commented Jun 2, 2021

yes native source map seems fine, but the key is to split index.js into chunks otherwise the sourcemap would get super big and take a ton of memory when loaded

@styfle
Copy link
Member

styfle commented Jun 2, 2021

The purpose of ncc is to bundle chunks of js into a single file. So splitting doesn't make sense, you could just avoid using ncc and keep the original files.

@ninja-
Copy link
Author

ninja- commented Jun 2, 2021

I disagree with that, having index.js automatically split into 10 chunks and required in main index.js would serve the same purpose as currently but would fix the issues with source maps.
Could at least be a config option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants