Skip to content

Commit 74f2ee6

Browse files
filipesilvaKeen Yee Liau
authored andcommitted
fix(@angular-devkit/build-angular): show error for missing modules
Fix #14421
1 parent d02e80c commit 74f2ee6

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
359359
hints: false,
360360
},
361361
module: {
362+
// Show an error for missing exports instead of a warning.
363+
strictExportPresence: true,
362364
rules: [
363365
{
364366
test: /\.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)$/,

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

Lines changed: 19 additions & 0 deletions
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)