Skip to content

Commit 08cce96

Browse files
committed
fix(@angular-devkit/build-angular): show error for missing modules
Fix angular#14421
1 parent e333450 commit 08cce96

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts

+2
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
353353
hints: false,
354354
},
355355
module: {
356+
// Show an error for missing exports instead of a warning.
357+
strictExportPresence: true,
356358
rules: [
357359
{
358360
test: /\.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)$/,

packages/angular_devkit/build_angular/test/browser/errors_spec_large.ts

+19
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,23 @@ describe('Browser Builder errors', () => {
6262
expect(logs.join()).toContain('Function expressions are not supported in');
6363
await run.stop();
6464
});
65+
66+
it('shows missing export errors', async () => {
67+
host.writeMultipleFiles({
68+
'src/not-main.js': `
69+
import { missingExport } from 'rxjs';
70+
console.log(missingExport);
71+
`,
72+
});
73+
const overrides = { main: 'src/not-main.js' };
74+
const logger = new logging.Logger('');
75+
const logs: string[] = [];
76+
logger.subscribe(e => logs.push(e.message));
77+
78+
const run = await architect.scheduleTarget(targetSpec, overrides, { logger });
79+
const output = await run.result;
80+
expect(output.success).toBe(false);
81+
expect(logs.join()).toContain(`export 'missingExport' was not found in 'rxjs'`);
82+
await run.stop();
83+
});
6584
});

0 commit comments

Comments
 (0)