-
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 (#3117)
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 `ng build`. To disable it, use `--no-vendor-chunk` flag. Partially address #1980 BREAKING CHANGE: `ng build/serve` now generates `vendor.bundle.js` by default.
- Loading branch information
1 parent
859d905
commit bf9c8f1
Showing
10 changed files
with
61 additions
and
17 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') | ||
.then(() => expectFileToExist('dist/vendor.bundle.js')) | ||
.then(() => ng('build', '--no-vendor-chunk')) | ||
.then(() => expectToFail(() => expectFileToExist('dist/vendor.bundle.js'))); | ||
} |
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