-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular-devkit/build-angular): ensure esbuild builder sourcemap …
…sources are relative to workspace This change adjusts the virtual output directory of the configuration for the experimental esbuild-based browser application builder to be based on the workspace root. This allows esbuild to generate sourcemap source paths that are relative to the workspace root and that do not contain path information from outside the workspace root.
- Loading branch information
Showing
5 changed files
with
36 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,45 @@ | ||
import * as fs from 'fs'; | ||
|
||
import { isAbsolute } from 'path'; | ||
import { getGlobalVariable } from '../../utils/env'; | ||
import { ng } from '../../utils/process'; | ||
import { updateJsonFile } from '../../utils/project'; | ||
|
||
export default async function () { | ||
// General secondary application project | ||
await ng('generate', 'application', 'secondary-project', '--skip-install'); | ||
// Setup esbuild builder if requested on the commandline | ||
const useEsbuildBuilder = !!getGlobalVariable('argv')['esbuild']; | ||
if (useEsbuildBuilder) { | ||
await updateJsonFile('angular.json', (json) => { | ||
json['projects']['secondary-project']['architect']['build']['builder'] = | ||
'@angular-devkit/build-angular:browser-esbuild'; | ||
}); | ||
} | ||
|
||
await ng('build', 'secondary-project', '--configuration=development'); | ||
|
||
await ng('build', '--output-hashing=none', '--source-map', '--configuration=development'); | ||
const content = fs.readFileSync('./dist/secondary-project/main.js.map', 'utf8'); | ||
const { sources } = JSON.parse(content); | ||
const { sources } = JSON.parse(content) as { sources: string[] }; | ||
let mainFileFound = false; | ||
for (const source of sources) { | ||
if (isAbsolute(source)) { | ||
throw new Error(`Expected ${source} to be relative.`); | ||
} | ||
|
||
if (source.endsWith('main.ts')) { | ||
mainFileFound = true; | ||
if ( | ||
source !== 'projects/secondary-project/src/main.ts' && | ||
source !== './projects/secondary-project/src/main.ts' | ||
) { | ||
throw new Error(`Expected main file ${source} to be relative to the workspace root.`); | ||
} | ||
} | ||
} | ||
|
||
if (!mainFileFound) { | ||
throw new Error('Could not find the main file in the application sourcemap sources array.'); | ||
} | ||
} |