Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @license
* Copyright Google LLC 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 { logging } from '@angular-devkit/core';
import { buildWebpackBrowser } from '../../index';
import { BASE_OPTIONS, BROWSER_BUILDER_INFO, describeBuilder } from '../setup';

describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
describe('Behavior: "Style Unsupported"', () => {
it('errors when importing a css file as an ECMA module (Webpack specific behaviour)', async () => {
await harness.writeFiles({
'src/test-style.css': '.test-a {color: red}',
'src/main.ts': `import './test-style.css'`,
});

harness.useTarget('build', {
...BASE_OPTIONS,
styles: [],
});

const { result, logs } = await harness.executeOnce();

expect(result?.success).toBeFalse();
expect(logs).toContain(
jasmine.objectContaining<logging.LogEntry>({
message: jasmine.stringMatching('./src/test-style.css:1:0 - Error'),
}),
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,6 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
describe('Option: "allowedCommonJsDependencies"', () => {
describe('given option is not set', () => {
for (const aot of [true, false]) {
it(`should not show warning for styles import in ${aot ? 'AOT' : 'JIT'} Mode`, async () => {
await harness.writeFile('./test.css', `body { color: red; };`);
await harness.appendToFile('src/app/app.component.ts', `import '../../test.css';`);

harness.useTarget('build', {
...BASE_OPTIONS,
allowedCommonJsDependencies: [],
aot,
});

const { result, logs } = await harness.executeOnce();

expect(result?.success).toBe(true);
expect(logs).not.toContain(
jasmine.objectContaining<logging.LogEntry>({
message: jasmine.stringMatching(/CommonJS or AMD dependencies/),
}),
);
});

it(`should show warning when depending on a Common JS bundle in ${
aot ? 'AOT' : 'JIT'
} Mode`, async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ export function getStylesConfig(wco: WebpackConfigOptions): Configuration {
{
use: componentStyleLoaders,
type: 'asset/source',
resourceQuery: /\?ngResource/,
},
],
},
Expand Down