Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): script chunk in angular.json retu…
Browse files Browse the repository at this point in the history
…rn false then calling isInitial

This commit add the webpack chunk with it related chunkgroup or entrypoint
  • Loading branch information
Tsuki authored and kyliau committed Jan 14, 2019
1 parent 79a46d0 commit ac740cb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Expand Up @@ -83,7 +83,7 @@ export class ScriptsWebpackPlugin {

const entrypoint = new EntryPoint(this.options.name);
entrypoint.pushChunk(chunk);

chunk.addGroup(entrypoint);
compilation.entrypoints.set(this.options.name, entrypoint);
compilation.chunks.push(chunk);
compilation.assets[filename] = source;
Expand Down
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import { DefaultTimeout, runTargetSpec } from '@angular-devkit/architect/testing';
import { DefaultTimeout, TestLogger, runTargetSpec } from '@angular-devkit/architect/testing';
import { PathFragment, join, normalize, virtualFs } from '@angular-devkit/core';
import { tap } from 'rxjs/operators';
import { browserTargetSpec, host } from '../utils';
Expand Down Expand Up @@ -133,4 +133,22 @@ describe('Browser Builder scripts array', () => {
}),
).toPromise().then(done, done.fail);
});

it('chunk in entry', (done) => {
host.writeMultipleFiles(scripts);

const overrides = { scripts: getScriptsOption() };
const logger = new TestLogger('build-script-entry');

runTargetSpec(host, browserTargetSpec, overrides, DefaultTimeout, logger).pipe(
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
tap(() => {
const validate = ` [entry] [rendered]`;
expect(logger.includes(`(lazy-script) 69 bytes${validate}`)).toBe(true);
expect(logger.includes(`(renamed-script) 78 bytes${validate}`)).toBe(true);
expect(logger.includes(`(renamed-lazy-script) 88 bytes${validate}`)).toBe(true);
logger.clear();
}),
).toPromise().then(done, done.fail);
});
});

0 comments on commit ac740cb

Please sign in to comment.