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

Remove inline sourcemap if largeFile is activated #267

Open
DSoko2 opened this issue Jan 4, 2017 · 9 comments
Open

Remove inline sourcemap if largeFile is activated #267

DSoko2 opened this issue Jan 4, 2017 · 9 comments

Comments

@DSoko2
Copy link

DSoko2 commented Jan 4, 2017

Using the following gulp pipeline, I'm facing the issue that the resulting bundle still contains the inline sourcemap, which was generated by rollupjs (more precise rollup-stream). At the same time the external sourcemap file is generated, written to directory and linked in the app.js-file correctly. If I deactivate the largeFile option, the result is the same, but the inline sourcemap becomes removed from my app.js-file, which is the behavour I would expect. Unfortunately, I cannot deactivate the largeFile option for my project, because the regex that is used by convert-source-map otherwise causes the build to crash due to a "Maximum call stack size exceeded" error.

My pipeline:

	return rollup({
		entry: paths.src.mainAotJsFile,
		sourceMap: true,
		context: 'window',
		treeshake: true,
		format: 'cjs',
		plugins: rollupPlugins
	})
		.pipe(source('app.js'))
		.pipe(buffer())
		.pipe(sourcemaps.init({largeFile: false, loadMaps: true}))
		.pipe(sourcemaps.write('.'))
		.pipe(gulp.dest(paths.dist.bundledDir));

I already had a short look into the code of gulp-sourcemaps and into the code of convert-source-map. Unfortunately, the seen behavior is a valid implementation, because the function that removes the inline sourcemap usually is based on the regex that tends to cause a "Maximum call stack size exceeded" error with large files :/

I would be very happy, if we could find a smart solution for this problem :)

@nmccready
Copy link
Collaborator

Try version 2.2.2 or 1.9.2 . If you use largeFile: true the comment will definitely removed the previous sourcemap. However there was code that was reverted for keeping preEixisting inline soucemaps in version 1.9.1, and 2.2.1 (which have been unpublished). That code has been removed. See if things have gotten better. To avoid the memory error you def want largeFile true.

@DSoko2
Copy link
Author

DSoko2 commented Jan 13, 2017

@nmccready thank you for the advice! I had a try with version 2.2.2 and the current version 2.4.0. Unfortunately, for both the original sourcemap was not removed, if largeFile was enabled. If this option was disabled (and I didn't get the call stack error), the sourcemap was removed as expected.

In the current codebase at least in init/index.internals.js#L91 the removal of the sourcemap is disabled for largeFile enabled. Where exactly is the part that should remove the sourcemap for enabled largeFile? Perhaps that can help me to find the cause for my issue...

@phated
Copy link
Contributor

phated commented Mar 22, 2017

@DSoko2 can you provide a repository that reproduces this? I'd like to run some experiments.

@DSoko2
Copy link
Author

DSoko2 commented Mar 23, 2017

@phated I appreciate your plan! Unfortunatelly, the project where I am facing this issue is closed source due to our company restrictions. I will try my very best to provide you an easy example ASAP, but I am currently very busy. Hope to get it done during the weekend, if you should have helped yourself out meanwhile, please drop me a short note.

@phated
Copy link
Contributor

phated commented Mar 24, 2017

I'd still like a reproduction repository, but while digging into convert-source-map for some other work I'm doing, I found that the largeFile argument no longer exists in that module and they actually broke some other stuff. I'll follow up here when I hear back from them.

@nmccready
Copy link
Collaborator

nmccready commented Mar 25, 2017 via email

@phated
Copy link
Contributor

phated commented Mar 25, 2017

@nmccready it looks like someone "improved" the RegExp to be less greedy (my terminology might be incorrect here) so that it realizes it doesn't match early and avoids blowing the stack but they removed the lastIndex stuff at the same time. Hopefully I hear back from them sooner than later.

@phated
Copy link
Contributor

phated commented Mar 28, 2017

@DSoko2 can you update your dependencies (to get the latest version of convert-source-map in your dependency tree) and try your build? I submitted a patch to convert-source-map over the weekend and it solved some of our failing test problems but not sure if it affects your issue.

@DSoko2
Copy link
Author

DSoko2 commented Mar 30, 2017

@phated I had a try with the current versions. Unfortunately, I'm facing the same results as described in my initial post...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

3 participants