chore(sourcemaps): update global script handling#3094
Conversation
|
Hey @rwaskiewicz |
| return { code: results.outputText }; | ||
| } | ||
|
|
||
| return { code: results.outputText, map: sourceMapMerge(sourceMap, codeMap) }; |
There was a problem hiding this comment.
sourceMap merging is now redundant - the magic string sourcemap === the sourcemap from transpileModule
There was a problem hiding this comment.
Good call! Updated in 4ca0542 which also fixes the off by one error 🎉
add a check to verify that a global script exists in the moduleMap on the compiler context before accessing fields on it to prevent compiler time errors. this is one of the items we discussed as a team in the GH comments of #3005, and is being implemented here reworked how sourcemaps are generated. this commit restores the original code generation where the platform, source code, and default export are concatenated, which allows us to reserve generating a magic string until/if we're using source maps remove includeContent field from the generation of the sourcemap, which does not appear to be needed, strictly speaking
include the source content and remove the merge of sourcemaps to resolve off by one error
4ca0542 to
c8d029b
Compare
Please do not merge, this is targeting a parent branch for ease of review
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?
For global script sourcemap generation, there are a few minor cleanups the team wanted to perform
GitHub Issue Number: N/A
What is the new behavior?
add a check to verify that a global script exists in the moduleMap on
the compiler context before accessing fields on it to prevent compiler
time errors. this is one of the items we discussed as a team in the GH
comments of #3005, and is being implemented here
reworked how sourcemaps are generated. this commit restores the original
code generation where the platform, source code, and default export are
concatenated, which allows us to reserve generating a magic string
until/if we're using source maps
Does this introduce a breaking change?
Testing
I spun up a basic Stencil component library with
npm init stencil. Runnpm iin the created project.I added two files to
src/:Update your
stencil.config.ts, setting:Checkout the this branch, which allows for sourcemaps to be used. Build stencil with
npm ci && npm run build && npm packand install the tarball in your component libraryFinally start the dev server with
npm start.Observe breakpoints in the global script there.
Note that there is a known issue where breakpoints are 'off by one', where the first eligible line my not be able to receive/stop on a breakpoint. I've added something to the Stencil team backlog to investigate furtherFixed in 4ca0542Other information