Skip to content

Commit 38dfad4

Browse files
committed
fixup! fix(@angular/build): use component file path in inline stylesheet diagnostic locations
1 parent 4b03726 commit 38dfad4

2 files changed

Lines changed: 10 additions & 17 deletions

File tree

‎packages/angular/build/src/tools/esbuild/angular/component-stylesheets.ts‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -177,21 +177,16 @@ export class ComponentStylesheetBundler {
177177
});
178178

179179
const result = await bundlerContext.bundle();
180-
const watchFile = path.isAbsolute(filename)
181-
? filename
182-
: path.join(this.options.workspaceRoot, filename);
183-
for (const message of [...(result.errors ?? []), ...(result.warnings ?? [])]) {
184-
if (message.location?.file?.startsWith('angular:styles/component:')) {
185-
message.location.file = filename;
186-
if (result.errors) {
187-
bundlerContext.watchFiles.add(watchFile);
188-
}
180+
if (result.errors || result.warnings.length > 0) {
181+
if (this.incremental && result.errors) {
182+
bundlerContext.watchFiles.add(
183+
path.isAbsolute(filename) ? filename : path.join(this.options.workspaceRoot, filename),
184+
);
189185
}
190-
for (const note of message.notes ?? []) {
191-
if (note.location?.file?.startsWith('angular:styles/component:')) {
192-
note.location.file = filename;
193-
if (result.errors) {
194-
bundlerContext.watchFiles.add(watchFile);
186+
for (const message of [...(result.errors ?? []), ...result.warnings]) {
187+
for (const item of [message, ...(message.notes ?? [])]) {
188+
if (item.location?.file?.startsWith('angular:styles/component:')) {
189+
item.location.file = filename;
195190
}
196191
}
197192
}

‎packages/angular/build/src/tools/esbuild/angular/component-stylesheets_spec.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('ComponentStylesheetBundler', () => {
3838
cacheOptions: { enabled: false, path: '', basePath: tempRoot },
3939
},
4040
'css',
41-
false,
41+
true,
4242
);
4343

4444
const componentFile = join(tempRoot, 'src', 'lib', 'lib.component.ts');
@@ -52,7 +52,6 @@ describe('ComponentStylesheetBundler', () => {
5252
assert(result.errors, 'Expected bundleInline to report a resolution error');
5353
expect(result.errors.length).toBeGreaterThan(0);
5454
expect(result.errors[0].location?.file).toBe(componentFile);
55-
expect(result.errors[0].location?.file).not.toContain('angular:styles/component:');
5655
expect(result.referencedFiles).toContain(componentFile);
5756
} finally {
5857
await bundler.dispose();
@@ -81,7 +80,6 @@ describe('ComponentStylesheetBundler', () => {
8180

8281
expect(result.warnings.length).toBeGreaterThan(0);
8382
expect(result.warnings[0].location?.file).toBe(componentFile);
84-
expect(result.warnings[0].location?.file).not.toContain('angular:styles/component:');
8583
} finally {
8684
await bundler.dispose();
8785
}

0 commit comments

Comments
 (0)