This repository has been archived by the owner on Apr 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@angular-devkit/build-angular): add sourcemaps for external libr…
…aries Added a new flag `vendorSourceMap` to enable consumers to have sourcemaps for vendor packages.
- Loading branch information
1 parent
65992bc
commit 496456b
Showing
12 changed files
with
142 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
52 changes: 52 additions & 0 deletions
52
packages/angular_devkit/build_angular/test/browser/vendor-source-map_spec_large.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { join, normalize, virtualFs } from '@angular-devkit/core'; | ||
import * as path from 'path'; | ||
import { tap } from 'rxjs/operators'; | ||
import { Timeout, browserTargetSpec, host, runTargetSpec } from '../utils'; | ||
|
||
describe('Browser Builder external source map', () => { | ||
const outputPath = normalize('dist'); | ||
|
||
beforeEach(done => host.initialize().toPromise().then(done, done.fail)); | ||
afterEach(done => host.restore().toPromise().then(done, done.fail)); | ||
|
||
it('works', (done) => { | ||
const overrides = { sourceMap: true, vendorSourceMap: true }; | ||
|
||
runTargetSpec(host, browserTargetSpec, overrides).pipe( | ||
tap((buildEvent) => expect(buildEvent.success).toBe(true)), | ||
tap(() => { | ||
const fileName = join(outputPath, 'vendor.js.map'); | ||
expect(host.scopedSync().exists(fileName)).toBe(true); | ||
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName))); | ||
// this is due the fact that some vendors like `tslib` sourcemaps to js files | ||
const sourcePath = JSON.parse(content).sources[0]; | ||
expect(path.extname(sourcePath)).toBe('.ts', `${sourcePath} extention should be '.ts'`); | ||
}), | ||
).toPromise().then(done, done.fail); | ||
}, Timeout.Basic); | ||
|
||
it('does not map sourcemaps from external library when disabled', (done) => { | ||
const overrides = { sourceMap: true, vendorSourceMap: false }; | ||
|
||
runTargetSpec(host, browserTargetSpec, overrides).pipe( | ||
tap((buildEvent) => expect(buildEvent.success).toBe(true)), | ||
tap(() => { | ||
const fileName = join(outputPath, 'vendor.js.map'); | ||
expect(host.scopedSync().exists(fileName)).toBe(true); | ||
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName))); | ||
// this is due the fact that some vendors like `tslib` sourcemaps to js files | ||
const sourcePath = JSON.parse(content).sources[0]; | ||
expect(path.extname(sourcePath)).toBe('.js', `${sourcePath} extention should be '.js'`); | ||
}), | ||
).toPromise().then(done, done.fail); | ||
}, Timeout.Basic); | ||
|
||
}); |