Skip to content

Commit f1a25c0

Browse files
committed
Added webpack as build system, trying to split out to vendors but oddly not loading. Webpack I think is eating the Decorators
1 parent 4baf9cd commit f1a25c0

File tree

7 files changed

+134
-106
lines changed

7 files changed

+134
-106
lines changed

addon/ng2/blueprints/ng2/files/__path__/index.html

+19-21
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<link rel="{{rel}}" {{#if sizes}}sizes="{{sizes}}" {{/if}}href="{{href}}">
1818
{{/each}}
1919

20-
{{#if environment.production}}
20+
<!-- {{#if environment.production}}
2121
<script type="text/javascript">
2222
if ('serviceWorker' in navigator) {
2323
navigator.serviceWorker.register('/worker.js').catch(function(err) {
@@ -26,16 +26,28 @@
2626
}
2727
</script>
2828
{{/if}}
29-
<% } %>
29+
<% } %> -->
3030
</head>
3131
<body>
3232
<<%= htmlComponentName %>-app>Loading...</<%= htmlComponentName %>-app>
3333

34-
<% if (isMobile) { %>
34+
<!-- <% if (isMobile) { %>
35+
36+
{{#if environment.production}}
37+
<script src="/app-concat.js" async></script>
38+
{{else}}
39+
{{#each scripts.polyfills}}
40+
<script src="{{.}}"></script>
41+
{{/each}}
42+
<script>
43+
System.import('system-config.js').then(function () {
44+
System.import('main');
45+
}).catch(console.error.bind(console));
46+
</script>
47+
{{/if}}
48+
49+
<% } else { %>
3550
36-
{{#if environment.production}}
37-
<script src="/app-concat.js" async></script>
38-
{{else}}
3951
{{#each scripts.polyfills}}
4052
<script src="{{.}}"></script>
4153
{{/each}}
@@ -44,22 +56,8 @@
4456
System.import('main');
4557
}).catch(console.error.bind(console));
4658
</script>
47-
{{/if}}
48-
49-
<% } else { %>
50-
51-
{{#each scripts.polyfills}}
52-
<script src="{{.}}"></script>
53-
{{/each}}
54-
<script>
55-
System.import('system-config.js').then(function () {
56-
System.import('main');
57-
}).catch(console.error.bind(console));
58-
</script>
59-
60-
<% } %>
61-
6259
60+
<% } %> -->
6361

6462
</body>
6563
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Prefer CoreJS over the polyfills above
2+
import 'reflect-metadata';
3+
require('zone.js/dist/zone');
4+
5+
// Typescript emit helpers polyfill
6+
import 'ts-helpers';

addon/ng2/blueprints/ng2/files/__path__/tsconfig.json

+4-10
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,14 @@
44
"declaration": false,
55
"emitDecoratorMetadata": true,
66
"experimentalDecorators": true,
7-
"module": "commonjs",
7+
"module": "es2015",
88
"moduleResolution": "node",
9-
"noEmitOnError": true,
9+
"noEmitOnError": false,
1010
"noImplicitAny": false,
1111
"outDir": "../dist/",
1212
"rootDir": ".",
1313
"sourceMap": true,
14-
"target": "es5",
14+
"target": "es2015",
1515
"inlineSources": true
16-
},
17-
18-
"files": [
19-
"main.ts",<% if (isMobile) { %>
20-
"main-app-shell.ts",<% } %>
21-
"typings.d.ts"
22-
]
16+
}
2317
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import '@angular/core';
2+
import '@angular/common';
3+
import '@angular/compiler';
4+
import '@angular/http';
5+
import '@angular/router';
6+
import '@angular/platform-browser';
7+
import '@angular/platform-browser-dynamic';
8+
9+
<% if(isMobile) { %>
10+
'@angular/app-shell';
11+
<% } %>
12+
13+
import 'rxjs/add/operator/map';
14+
import 'rxjs/add/operator/mergeMap';

addon/ng2/commands/build.ts

+17-74
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
const Command = require('ember-cli/lib/models/command');
22
const win = require('ember-cli/lib/utilities/windows-admin');
3-
const path = require('path');
4-
5-
const Build = require('../tasks/build');
6-
const BuildWatch = require('../tasks/build-watch');
73

4+
// const Build = require('../tasks/build');
5+
// const BuildWatch = require('../tasks/build-watch');
86

7+
// Webpack Configuration
98
const webpack = require('webpack');
10-
9+
const webpackConfig = require('../tasks/webpack-build-config');
10+
const webpackCompiler = webpack(webpackConfig);
1111

1212
module.exports = Command.extend({
1313
name: 'build',
@@ -23,76 +23,19 @@ module.exports = Command.extend({
2323
],
2424

2525
run: function(commandOptions) {
26-
// var BuildTask = this.taskFor(commandOptions);
27-
// var buildTask = new BuildTask({
28-
// ui: this.ui,
29-
// analytics: this.analytics,
30-
// project: this.project
31-
// });
32-
// var ShowAssetSizesTask = this.tasks.ShowAssetSizes;
33-
// var showTask = new ShowAssetSizesTask({
34-
// ui: this.ui
35-
// });
36-
//
37-
// return win.checkWindowsElevation(this.ui).then(function () {
38-
// return buildTask.run(commandOptions)
39-
// .then(function () {
40-
// if (!commandOptions.suppressSizes && commandOptions.environment === 'production') {
41-
// return showTask.run({
42-
// outputPath: commandOptions.outputPath
43-
// });
44-
// }
45-
// });
46-
// });
47-
48-
49-
return new Promise((resolve) => {
50-
webpack({
51-
resolve: {
52-
extensions: ['', '.css', '.scss', '.ts', '.js']
53-
},
54-
55-
plugins: [
56-
// new LiveReloadPlugin({
57-
// appendScriptTag: true
58-
// })
59-
],
60-
61-
entry: path.resolve(process.cwd(), './src/main.ts'),
62-
output: {
63-
path: "./dist",
64-
publicPath: 'dist/',
65-
filename: "bundle.js"
66-
},
67-
ts: {
68-
configFileName: './src/tsconfig.json'
69-
},
70-
71-
// devtool: 'source-map',
72-
73-
module: {
74-
loaders: [
75-
{
76-
test: /\.ts$/,
77-
loader: 'ts-loader'
78-
},
79-
{
80-
test: /\.css$/,
81-
loader: 'style-loader'
82-
}
83-
]
84-
},
85-
86-
devServer: {
87-
historyApiFallback: true
88-
}
89-
}, function (err, stats) {
90-
resolve();
91-
console.log(err);
92-
console.log(stats);
93-
console.log('--------');
26+
return new Promise((resolve, reject) => {
27+
webpackCompiler.run((err, stats) => {
28+
debugger;
29+
if (err || stats.compilation.errors.length) {
30+
reject(stats.compilation.errors);
31+
console.log(err);
32+
}
33+
34+
resolve();
35+
console.log(stats);
36+
console.log('--------');
37+
});
9438
});
95-
});
9639
},
9740

9841
taskFor: function(options) {
+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
const webpack = require('webpack');
2+
const HtmlWebpackPlugin = require('html-webpack-plugin');
3+
const path = require('path');
4+
5+
// Resolve to the generated applications
6+
function ngAppResolve(resolvePath: string): string {
7+
return path.resolve(process.cwd(), resolvePath);
8+
}
9+
10+
// Webpack Configuration Object
11+
// Used in build.ts
12+
module.exports = {
13+
cache: false,
14+
// Resolve loaders from the CLI node_modules rather than the projects
15+
context: path.resolve(__dirname, './'),
16+
entry: {
17+
main: ngAppResolve('./src/main.ts'),
18+
vendor: ngAppResolve('./src/vendor.ts'),
19+
polyfills: ngAppResolve('./src/polyfills.ts')
20+
},
21+
22+
output: {
23+
path: "./dist",
24+
filename: "[name].bundle.js"
25+
},
26+
27+
module: {
28+
loaders: [
29+
{
30+
test: /\.ts$/,
31+
loader: 'ts-loader'
32+
},
33+
{
34+
test: /\.json$/,
35+
loader: 'json-loader'
36+
}
37+
]
38+
},
39+
40+
plugins: [
41+
// Automatically manages the addition of bundle scripts to your index.html template.
42+
// Also allows index.html to be used in src/ and watched
43+
new HtmlWebpackPlugin({
44+
template: ngAppResolve('./src/index.html'),
45+
chunksSortMode: 'dependency'
46+
}),
47+
new webpack.optimize.CommonsChunkPlugin({
48+
name: ['polyfills', 'vendor'].reverse()
49+
})
50+
],
51+
52+
ts: {
53+
configFileName: ngAppResolve('./src/tsconfig.json'),
54+
silent: true
55+
},
56+
57+
resolve: {
58+
extensions: ['', '.css', '.scss', '.ts', '.js']
59+
},
60+
61+
devServer: {
62+
historyApiFallback: true
63+
}
64+
65+
node: {
66+
global: 'window',
67+
crypto: 'empty',
68+
module: false,
69+
clearImmediate: false,
70+
setImmediate: false
71+
}
72+
};

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"fs-extra": "^0.30.0",
4646
"glob": "^7.0.3",
4747
"handlebars": "^4.0.5",
48+
"json-loader": "^0.5.4",
4849
"leek": "0.0.21",
4950
"lodash": "^4.11.1",
5051
"opn": "4.0.1",
@@ -55,7 +56,7 @@
5556
"symlink-or-copy": "^1.0.3",
5657
"systemjs-builder": "0.15.17",
5758
"ts-loader": "^0.8.2",
58-
"typescript": "^1.8.10",
59+
"typescript": "^1.9.0-dev.20160605-1.0",
5960
"typings": "^0.8.1",
6061
"webpack": "^2.1.0-beta.8"
6162
},

0 commit comments

Comments
 (0)