This repository has been archived by the owner on May 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(webpack): use a vendor bundle to minimize code that needs re-…
…bundling and source map generation
- Loading branch information
1 parent
691d645
commit 141cb23
Showing
5 changed files
with
32 additions
and
134 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,34 +1,15 @@ | ||
import { join } from 'path'; | ||
import * as CommonChunksPlugin from 'webpack/lib/optimize/CommonsChunkPlugin'; | ||
|
||
export const NODE_MODULES = join(process.cwd(), 'node_modules'); | ||
export const RXJS = join(NODE_MODULES, 'rxjs'); | ||
export const ZONEJS = join(NODE_MODULES, 'zone.js'); | ||
export const ANGULAR = join(NODE_MODULES, '@angular'); | ||
export const IONIC = join(NODE_MODULES, 'ionic-angular'); | ||
import * as Constants from '../util/constants'; | ||
import { getStringPropertyValue } from '../util/helpers'; | ||
|
||
export function getIonicDependenciesCommonChunksPlugin() { | ||
export function getCommonChunksPlugin() { | ||
return new CommonChunksPlugin({ | ||
name: 'known-vendors', | ||
minChunks: checkIfModuleIsIonicDependency | ||
name: 'vendor', | ||
minChunks: checkIfInNodeModules | ||
}); | ||
} | ||
|
||
export function getNonIonicDependenciesCommonChunksPlugin() { | ||
return new CommonChunksPlugin({ | ||
name: 'unknown-vendors', | ||
minChunks: checkIfModuleIsNodeModuleButNotIonicDepenedency | ||
}); | ||
} | ||
|
||
function isIonicDependency(modulePath: string) { | ||
return modulePath.startsWith(RXJS) || modulePath.startsWith(ZONEJS) || modulePath.startsWith(ANGULAR) || modulePath.startsWith(IONIC); | ||
} | ||
|
||
export function checkIfModuleIsIonicDependency(module: any) { | ||
return !!(module.userRequest && isIonicDependency(module.userRequest)); | ||
} | ||
|
||
export function checkIfModuleIsNodeModuleButNotIonicDepenedency(module: any) { | ||
return !!(module.userRequest && module.userRequest.startsWith(NODE_MODULES) && !isIonicDependency(module.userRequest)); | ||
function checkIfInNodeModules(webpackModule: any) { | ||
return webpackModule && webpackModule.userRequest && webpackModule.userRequest.startsWith(getStringPropertyValue(Constants.ENV_VAR_NODE_MODULES_DIR)); | ||
} |
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