Bug Report
Affected Package
@angular/compiler-cli/linker
Is this a regression?
No.
Description
When using the sourceMapping linker option and Babel generates AST nodes that reference the external template files, babel will not emit any sourcemap.
Minimal Reproduction
Exception or Error
Sourcemaps for the library are not emitted.
Your Environment
Angular Version:
Angular CLI: 12.1.1
Node: 14.17.1
Package Manager: npm 6.14.13
OS: darwin x64
Angular: 12.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1201.1
@angular-devkit/build-angular 12.1.1
@angular-devkit/core 12.1.1
@angular-devkit/schematics 12.1.1
@schematics/angular 12.1.1
ng-packagr 12.1.0
rxjs 6.6.7
typescript 4.3.5
Anything else relevant?
CLI issue angular/angular-cli#21271
It also appears that when this option is enabled the sourcemap is read directly from disk instead of using the sourcemap that is already in memory and accessible via the Babel API.
Couple of things I noticed while debugging this.
- The sourcemap happens to load because of the current fallback logic
|
const impliedMapPath = this.fs.resolve(sourcePath + '.map'); |
|
if (this.fs.exists(impliedMapPath)) { |
|
return { |
|
map: this.readRawSourceMap(impliedMapPath), |
|
mapPath: impliedMapPath, |
|
origin: ContentOrigin.FileSystem, |
|
}; |
|
} |
. This is because Webpack will remove //# sourceMappingURL from the source code when the a sourcemap is loaded.
- This also potential highlights a problem if the file/sourcemap is processed prior to the linker plugin, in which cases the sourcemap on disk would be out of sync. Therefore, IMHO the sourcemap provided via Babel API should be used instead of using what's on disk.
- In case one uses inline sourcemaps this logic will break, because there wouldn't be any sourcemapping information that the linker can read.
Reactions are currently unavailable
Bug Report
Affected Package
@angular/compiler-cli/linker
Is this a regression?
No.
Description
When using the sourceMapping linker option and Babel generates AST nodes that reference the external template files, babel will not emit any sourcemap.
Minimal Reproduction
Exception or Error
Sourcemaps for the library are not emitted.
Your Environment
Angular Version:
Anything else relevant?
CLI issue angular/angular-cli#21271
It also appears that when this option is enabled the sourcemap is read directly from disk instead of using the sourcemap that is already in memory and accessible via the Babel API.
Couple of things I noticed while debugging this.
angular/packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file_loader.ts
Lines 175 to 182 in a92a89b