-
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.
feature(compiler): add support for AoT to the CLI. (#2333)
Also adding a new package, webpack, which is a plugin and loader for webpack that adds support for AoT. It is behind a `--aot` flag in the CLI that is supported by build and serve.
- Loading branch information
Showing
58 changed files
with
1,258 additions
and
172 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
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,63 @@ | ||
import * as path from 'path'; | ||
import * as webpack from 'webpack'; | ||
import {findLazyModules} from './find-lazy-modules'; | ||
import {NgcWebpackPlugin} from '@ngtools/webpack'; | ||
|
||
const atl = require('awesome-typescript-loader'); | ||
|
||
const g: any = global; | ||
const webpackLoader: string = g['angularCliIsLocal'] | ||
? g.angularCliPackages['@ngtools/webpack'].main | ||
: '@ngtools/webpack'; | ||
|
||
|
||
export const getWebpackNonAotConfigPartial = function(projectRoot: string, appConfig: any) { | ||
const appRoot = path.resolve(projectRoot, appConfig.root); | ||
const lazyModules = findLazyModules(appRoot); | ||
|
||
return { | ||
module: { | ||
loaders: [ | ||
{ | ||
test: /\.ts$/, | ||
loaders: [{ | ||
loader: 'awesome-typescript-loader', | ||
query: { | ||
useForkChecker: true, | ||
tsconfig: path.resolve(appRoot, appConfig.tsconfig) | ||
} | ||
}, { | ||
loader: 'angular2-template-loader' | ||
}], | ||
exclude: [/\.(spec|e2e)\.ts$/] | ||
} | ||
], | ||
}, | ||
plugins: [ | ||
new webpack.ContextReplacementPlugin(/.*/, appRoot, lazyModules), | ||
new atl.ForkCheckerPlugin(), | ||
] | ||
}; | ||
}; | ||
|
||
export const getWebpackAotConfigPartial = function(projectRoot: string, appConfig: any) { | ||
return { | ||
module: { | ||
loaders: [ | ||
{ | ||
test: /\.ts$/, | ||
loader: webpackLoader, | ||
exclude: [/\.(spec|e2e)\.ts$/] | ||
} | ||
] | ||
}, | ||
plugins: [ | ||
new NgcWebpackPlugin({ | ||
project: path.resolve(projectRoot, appConfig.root, appConfig.tsconfig), | ||
baseDir: path.resolve(projectRoot, ''), | ||
entryModule: path.join(projectRoot, appConfig.root, 'app/app.module#AppModule'), | ||
genDir: path.join(projectRoot, appConfig.outDir, 'ngfactory') | ||
}), | ||
] | ||
}; | ||
}; |
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
Oops, something went wrong.