chore(sourcemaps): minification with sourcemaps#3093
Merged
rwaskiewicz merged 3 commits intorwaskiewicz-rebase-again-sourcemapsfrom Oct 6, 2021
Merged
chore(sourcemaps): minification with sourcemaps#3093rwaskiewicz merged 3 commits intorwaskiewicz-rebase-again-sourcemapsfrom
rwaskiewicz merged 3 commits intorwaskiewicz-rebase-again-sourcemapsfrom
Conversation
this commit introduces a new type, OptimizeJsResult, to be used to name the shape of the object that is returned by various methods that are used to minify a user's JavaScript. using this type in the return signature of methods + in the declaration of objects allows us to eliminate unnessary type assertions on the individual fields of said objects.
part of this effort. this is done in an effort to make the dissemination of code within Stenicl slightly better. of course, we incur the cost of maintaining these comments.
sourcemaps in some regard are at odds with attempting to minize and compress our JavaScript files. Ideally there's no fidelity lost when compressing JS, but in some cases, we get inconsistent behaviors across browsers when we have both 'sourcemap' and 'compress' enabled in our terser configuration. after diffing through the terser source/docs, I think our best route forward for now is to simply disable the compress step. I took a sample Stencil app and did a `diff` of the output where in one scenario we didn't set compress to undefined, and one where we did set it to undefined. other than the sourcemaps themselves, the differences were rather minimal, and I believe this shouldn't have a large impact on the output
splitinfinities
approved these changes
Oct 6, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build) was run locally and any changes were pushednpm test) were run locally and passednpm run test.karma.prod) were run locally and passednpm run prettier) was run locally and passedPull request type
Please check the type of change your PR introduces:
What is the current behavior?
Sourcemaps with minification produce inconsistent results across browsers. In particular, I was looking at Firefox
GitHub Issue Number: N/A
What is the new behavior?
this commit introduces a new type, OptimizeJsResult, to be used to name
the shape of the object that is returned by various methods that are
used to minify a user's JavaScript. using this type in the return
signature of methods + in the declaration of objects allows us to
eliminate unnessary type assertions on the individual fields of said
objects.
part of this effort.
account for minification with sourcemaps
sourcemaps in some regard are at odds with attempting to minize and
compress our JavaScript files. Ideally there's no fidelity lost when
compressing JS, but in some cases, we get inconsistent behaviors across
browsers when we have both 'sourcemap' and 'compress' enabled in our
terser configuration.
after diffing through the terser source/docs, I think our best route
forward for now is to simply disable the compress step. I took a sample
Stencil app and did a
diffof the output where in one scenario wedidn't set compress to undefined, and one where we did set it to
undefined. other than the sourcemaps themselves, the differences were
rather minimal, and I believe this shouldn't have a large impact on the
output
Does this introduce a breaking change?
Testing
I spun up a basic Stencil component library with
npm init stencil. Runnpm iin the created project.Navigate to
src/utils/utils.tsand update the file as such:Update your
stencil.config.ts, setting:Checkout the
rwaskiewicz-rebase-again-sourcemapsbranch, which allows for sourcemaps to be used. Build stencil withnpm ci && npm run build && npm packand install the tarball in your component libraryFinally start the dev server with
npm start.Observe the following breakpoint behaviors in Firefox, Safari, Edge and Chrom (clockwise starting in the left hand corner).
Note that above we:
scopesproperly supplied,stris not consistently reported in the debuggerPull down this branch,
npm run build && npm packit, then install the tarball in your component library.npm startagain, and observe nicer breakpoint behavior remediating the issues aboveOther information