Skip to content

Commit

Permalink
feat(AoT): Support AoT compilation
Browse files Browse the repository at this point in the history
This is a first attempt at supporting Ahead of Time compilation.

Closes #55

Signed-off-by: Will Soto <[email protected]>
  • Loading branch information
willsoto committed Feb 22, 2017
1 parent 48e6a9a commit bc1452c
Show file tree
Hide file tree
Showing 6 changed files with 365 additions and 318 deletions.
24 changes: 11 additions & 13 deletions config/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ module.exports = {
loaders: [{
enforce: 'pre',
test: /\.ts$/,
loader: 'tslint-loader',
exclude: /node_modules/,
query: {
emitErrors: false,
failOnHint: false
}
}, {
test: /\.ts$/,
loader: 'ts-loader',
loader: [{
loader: 'tslint-loader',
options: {
emitErrors: false,
failOnHint: false
}
}],
exclude: /node_modules/
}, {
test: /\.json$/,
loader: 'json-loader',
test: /\.ts$/,
use: [{
loader: 'awesome-typescript-loader'
}],
exclude: /node_modules/
}]
},
Expand All @@ -41,8 +41,6 @@ module.exports = {
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
// https://github.com/webpack/webpack/issues/2644
// new webpack.optimize.DedupePlugin(),
new webpack.DefinePlugin({
ENV: JSON.stringify(IS_PROD ? 'production' : 'development')
})
Expand Down
30 changes: 23 additions & 7 deletions config/webpack.dist.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const webpack = require('webpack');
const AotPlugin = require('@ngtools/webpack').AotPlugin;

const helpers = require('./helpers');

module.exports = {
Expand Down Expand Up @@ -36,19 +39,32 @@ module.exports = {
loaders: [{
enforce: 'pre',
test: /\.ts$/,
loader: 'tslint-loader',
use: [{
loader: 'tslint-loader',
options: {
emitErrors: true,
failOnHint: true
}
}],
exclude: /node_modules/,
query: {
emitErrors: true,
failOnHint: true
}
}, {
test: /\.ts$/,
loader: 'ts-loader',
use: [{
loader: '@ngtools/webpack'
}],
exclude: /node_modules/
}]
},
resolve: {
extensions: ['.ts', '.js']
}
},
plugins: [
new AotPlugin({
tsConfigPath: helpers.root('tsconfig.json'),
entryModule: helpers.root('src', 'chartist.component#ChartistModule')
}),
new webpack.DefinePlugin({
ENV: JSON.stringify('production')
})
]
};
33 changes: 14 additions & 19 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,37 @@ module.exports = function(config) {
loaders: [{
enforce: 'pre',
test: /\.ts$/,
loader: 'tslint-loader',
use: [{
loader: 'tslint-loader',
options: {
emitErrors: false,
failOnHint: false
}
}],
include: [
helpers.root('src'),
helpers.root('test')
]
}, {
test: /\.ts$/,
loader: 'ts-loader',
include: [
helpers.root('src'),
helpers.root('test')
]
}, {
test: /\.json$/,
loader: 'json-loader',
use: [{
loader: 'awesome-typescript-loader'
}],
include: [
helpers.root('src'),
helpers.root('test')
]
}, {
enforce: 'post',
test: /\.ts$/,
loader: 'istanbul-instrumenter-loader',
use: [{
loader: 'istanbul-instrumenter-loader'
}],
include: [
helpers.root('src')
]
}]
},
plugins: [
new webpack.LoaderOptionsPlugin({
tslint: {
emitErrors: false,
failOnHint: false
}
})
]
}
},
webpackMiddleware: {
noInfo: true,
Expand Down
53 changes: 28 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,46 +48,49 @@
},
"homepage": "https://github.com/willsoto/angular2-chartist#readme",
"devDependencies": {
"@angular/common": "^2.4.2",
"@angular/compiler": "^2.4.2",
"@angular/core": "^2.4.2",
"@angular/forms": "^2.4.2",
"@angular/platform-browser": "^2.4.2",
"@angular/platform-browser-dynamic": "^2.4.2",
"@angular/common": "^2.4.8",
"@angular/compiler": "^2.4.8",
"@angular/compiler-cli": "^2.4.8",
"@angular/core": "^2.4.8",
"@angular/forms": "^2.4.8",
"@angular/platform-browser": "^2.4.8",
"@angular/platform-browser-dynamic": "^2.4.8",
"@angular/router": "^3.4.8",
"@ngtools/webpack": "^1.2.10",
"@types/chartist": "^0.9.34",
"@types/jasmine": "^2.5.40",
"@types/jasmine": "^2.5.43",
"@types/rx": "^4.1.1",
"awesome-typescript-loader": "^3.0.4",
"chartist": "^0.10.1",
"codelyzer": "^2.0.0-beta.4",
"coveralls": "^2.11.15",
"es6-shim": "^0.35.2",
"eslint": "^3.13.0",
"codelyzer": "^2.0.1",
"coveralls": "^2.11.16",
"es6-shim": "^0.35.3",
"eslint": "^3.16.0",
"git-scripts": "^0.2.1",
"istanbul-instrumenter-loader": "^1.2.0",
"istanbul-instrumenter-loader": "^2.0.0",
"jasmine-core": "^2.5.2",
"json-loader": "^0.5.4",
"karma": "^1.3.0",
"karma": "^1.5.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.1.0",
"karma-mocha-reporter": "^2.2.1",
"karma-mocha-reporter": "^2.2.2",
"karma-phantomjs-launcher": "^1.0.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.1",
"karma-webpack": "^2.0.2",
"phantomjs-prebuilt": "^2.1.14",
"reflect-metadata": "0.1.9",
"rimraf": "^2.5.4",
"rxjs": "5.0.3",
"reflect-metadata": "0.1.10",
"rimraf": "^2.6.0",
"rxjs": "5.2.0",
"standard-version": "^4.0.0",
"ts-loader": "^2.0.0",
"tslint": "4.4.2",
"tslint-loader": "^3.3.0",
"typedoc": "^0.5.3",
"typescript": "^2.1.4",
"tslint-loader": "^3.4.2",
"typedoc": "^0.5.7",
"typescript": "^2.1.6",
"uglify-js": "^2.7.5",
"validate-commit": "^2.3.2",
"webpack": "beta",
"webpack-dev-server": "beta",
"zone.js": "^0.7.4"
"webpack": "^2.2.1",
"webpack-dev-server": "^2.4.1",
"zone.js": "^0.7.7"
},
"peerDependencies": {
"@angular/core": ">=2.0.0",
Expand Down
9 changes: 2 additions & 7 deletions src/chartist.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface ChartEvent {
selector: 'x-chartist',
template: '<ng-content></ng-content>'
})
class ChartistComponent implements OnInit, OnChanges, OnDestroy {
export class ChartistComponent implements OnInit, OnChanges, OnDestroy {
@Input() data: (Promise<Chartist.IChartistData> | Chartist.IChartistData);
@Input() type: (Promise<ChartType> | ChartType);
@Input() options: (Promise<Chartist.IChartOptions> | Chartist.IChartOptions);
Expand Down Expand Up @@ -122,12 +122,7 @@ class ChartistComponent implements OnInit, OnChanges, OnDestroy {
ChartistComponent
]
})
class ChartistModule {}

export {
ChartistComponent,
ChartistModule
};
export class ChartistModule {}

// for angular-cli
export default {
Expand Down
Loading

0 comments on commit bc1452c

Please sign in to comment.