chore(build): use inline sources in sourcemaps; don't package sources separately #6362
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.
The basics
npm run format
andnpm run lint
The details
Resolves
tsc
compile failures for developers whose build pipeline is misconfigured in a way that causes it to ingest.ts
source files fromnode_modules/blockly/core/
—somehow without also ingestingcore/any_aliases.ts
—resulting in compile errors due toAnyDuringMigration
. (See e.g. item #2 of #6358.)Proposed Changes
Don't package the source
.ts
files; instead, include sources inline in the.js.map
sourcemaps.Behaviour Before Change
.ts
files are copied fromcore/
,blocks/
andgenerators/
todist/
.Sourcemap (
.js.map
) files contain a two-bytesourceRoot
property.Behaviour After Change
.ts
files are not packaged.Sourcemap files contain a large
sourcesContent
property (~2MB for `blockly_compressed.js.map), containing all of the original source.Reason for Changes
@btw17 points out that it is [generally not advised to package
.ts
sources along with compiled code in NPM packages]https://stackoverflow.com/a/57534667/4969945), and empirically it does appear to be causing problem for some of our developers.Test Coverage
Manually verified that sourcemaps with inline sources work correctly in compiled and uncompiled mode.
Additional Information
I sent email to @samelhusseini to get clarity about why sources were originally included in the Blockly NPM package. I think it worth waiting for a response before merging this PR.