-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build): auto generate vendor chunk
Add `--vendor-chunk` option to `ng build/serve`. Enabling vendor chunk can help with rebuild speeds. My tests on a medium project show a 34% improvement on rebuild. This option is enabled by default on `ng serve`, and disabled by default on `ng build`. Partially address #1980
- Loading branch information
1 parent
6f9d2c1
commit 00b64a6
Showing
9 changed files
with
57 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export function packageChunkSort(packages: string[]) { | ||
return function sort(left: any, right: any) { | ||
let leftIndex = packages.indexOf(left.names[0]); | ||
let rightindex = packages.indexOf(right.names[0]); | ||
|
||
if ( leftIndex < 0 || rightindex < 0) { | ||
// Unknown packages are loaded last | ||
return 1; | ||
} | ||
|
||
if (leftIndex > rightindex) { | ||
return 1; | ||
} | ||
|
||
return -1; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {ng} from '../../utils/process'; | ||
import {expectFileToExist} from '../../utils/fs'; | ||
import {expectToFail} from '../../utils/utils'; | ||
|
||
|
||
export default function() { | ||
return ng('build', '--vendor-chunk') | ||
.then(() => expectFileToExist('dist/vendor.bundle.js')) | ||
.then(() => ng('build')) | ||
.then(() => expectToFail(() => expectFileToExist('dist/vendor.bundle.js'))); | ||
} |