-
Notifications
You must be signed in to change notification settings - Fork 27k
Open
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilercompiler: linkertype: bug/fix
Milestone
Description
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
- git clone https://github.com/alan-agius4/LibExportTest2
- npm i
- ng build my-lib
- ng s
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 . This is because Webpack will remove
angular/packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file_loader.ts
Lines 175 to 182 in a92a89b
const impliedMapPath = this.fs.resolve(sourcePath + '.map'); if (this.fs.exists(impliedMapPath)) { return { map: this.readRawSourceMap(impliedMapPath), mapPath: impliedMapPath, origin: ContentOrigin.FileSystem, }; } //# sourceMappingURLfrom 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.
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilercompiler: linkertype: bug/fix