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
5 changes: 4 additions & 1 deletion packages/@ngtools/webpack/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,11 @@ export class AotPlugin implements Tapable {

compiler.plugin('after-resolvers', (compiler: any) => {
// Virtual file system.
// Wait for the plugin to be done when requesting `.ts` files directly (entry points), or
// when the issuer is a `.ts` file.
compiler.resolvers.normal.plugin('before-resolve', (request: any, cb: () => void) => {
if (request.request.match(/\.ts$/)) {
if (request.request.endsWith('.ts')
|| (request.context.issuer && request.context.issuer.endsWith('.ts'))) {
this.done!.then(() => cb(), () => cb());
} else {
cb();
Expand Down
45 changes: 45 additions & 0 deletions tests/e2e/tests/build/aot/aot-rebuild.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {
killAllProcesses,
waitForAnyProcessOutputToMatch,
execAndWaitForOutputToMatch,
} from '../../../utils/process';
import { appendToFile } from '../../../utils/fs';
import { getGlobalVariable } from '../../../utils/env';
import { request } from '../../../utils/http';
import { wait } from '../../../utils/utils';

const validBundleRegEx = /webpack: bundle is now VALID|webpack: Compiled successfully./;

export default function () {
if (process.platform.startsWith('win')) {
return Promise.resolve();
}
// Skip this in ejected tests.
if (getGlobalVariable('argv').eject) {
return Promise.resolve();
}

return execAndWaitForOutputToMatch('ng', ['serve', '--aot'], validBundleRegEx)
// Wait before editing a file.
// Editing too soon seems to trigger a rebuild and throw polling/watch out of whack.
.then(() => wait(2000))
// Check AOT templates are up to date with current code.
.then(() => request('http://localhost:4200/main.bundle.js'))
.then((body) => {
if (body.match(/\$\$_E2E_GOLDEN_VALUE_1/)) {
throw new Error('Expected golden value 1 to not be present.');
}
})
.then(() => appendToFile('src/app/app.component.html', '<p> $$_E2E_GOLDEN_VALUE_1 </p>'))
.then(() => waitForAnyProcessOutputToMatch(validBundleRegEx, 20000))
.then(() => request('http://localhost:4200/main.bundle.js'))
.then((body) => {
if (!body.match(/\$\$_E2E_GOLDEN_VALUE_1/)) {
throw new Error('Expected golden value 1.');
}
})
.then(() => killAllProcesses(), (err: any) => {
killAllProcesses();
throw err;
});
}