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

feat: support generating inlined sourcemaps when transforming js file… #4033

Merged
merged 4 commits into from
Mar 5, 2024

Conversation

jye-sf
Copy link
Contributor

@jye-sf jye-sf commented Mar 5, 2024

…s in the LWC compiler

Details

Supports passing the string 'inline' for the compiler's outputConfig's sourcemap property. This in turn is passed down to the Babel compiler and delegates sourcemap generation to Babel.

Does this pull request introduce a breaking change?

  • ✅ No, it does not introduce a breaking change.

Does this pull request introduce an observable change?

  • ⚠️ Yes, it does include an observable change.

This is a new API surface for developers with direct access to configure the LWC compiler. Additional work is needed to expose this property through existing compilation pipelines where the end developer might not have access to configure the compiler.

GUS work item

@jye-sf jye-sf requested a review from a team as a code owner March 5, 2024 00:02
/** If `true` the plugin will produce source maps. */
sourcemap?: boolean;
/** If `true` the plugin will produce source maps. If `'inline'`, the plugin will produce inlined source maps and append them to the end of the generated file. */
sourcemap?: boolean | 'inline';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might actually need to be passed to rollup and not to the LWC compiler to give to Babel; Rollup will throw away the inline sourcemaps. This is also true of non-inline sourcemaps, so it's possible this has never worked and no one's brought it up.

Setting this property in our perf-benchmarks-components project does nothing to the output even though LWC is properly passing the value down to the Babel transform.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, no sourcemaps will be generated if rollup itself isn't set to generate sourcemaps; it'll delete any existing inline sourcemaps it finds. If Rollup is set up to generate sourcemaps, there are other plugins that can help it load files with existing sourcemaps. This seems like a very small edge case for us though. If the sourcemaps generated by rollup are correct (need to verify), we should be fine relying on it instead of Babel.

@jye-sf jye-sf merged commit 8c934c5 into master Mar 5, 2024
9 checks passed
@jye-sf jye-sf deleted the jye/sourcemap-inline branch March 5, 2024 18:33
@nolanlawson
Copy link
Collaborator

:shipit:

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

Successfully merging this pull request may close these issues.

3 participants