Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6df5c93

Browse files
author
vakrilov
committedNov 29, 2016
AoT + nativescript target
1 parent 655cbcc commit 6df5c93

11 files changed

+460
-27
lines changed
 
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
MIT License http://www.opensource.org/licenses/mit-license.php
3+
Author Tobias Koppers @sokra
4+
*/
5+
var ConcatSource = require("webpack-sources").ConcatSource;
6+
var Template = require("webpack/lib/Template");
7+
8+
function JsonpChunkTemplatePlugin() { }
9+
module.exports = JsonpChunkTemplatePlugin;
10+
11+
JsonpChunkTemplatePlugin.prototype.apply = function (chunkTemplate) {
12+
13+
//JSONP version
14+
chunkTemplate.plugin("render", function (modules, chunk) {
15+
var jsonpFunction = this.outputOptions.jsonpFunction;
16+
var source = new ConcatSource();
17+
source.add(jsonpFunction + "(" + JSON.stringify(chunk.ids) + ",");
18+
source.add(modules);
19+
var entries = [chunk.entryModule].filter(Boolean).map(function (m) {
20+
return m.id;
21+
});
22+
if (entries.length > 0) {
23+
source.add("," + JSON.stringify(entries));
24+
}
25+
source.add(")");
26+
return source;
27+
});
28+
chunkTemplate.plugin("hash", function (hash) {
29+
hash.update("JsonpChunkTemplatePlugin");
30+
hash.update("3");
31+
hash.update(this.outputOptions.jsonpFunction + "");
32+
hash.update(this.outputOptions.library + "");
33+
});
34+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
MIT License http://www.opensource.org/licenses/mit-license.php
3+
Author Tobias Koppers @sokra
4+
*/
5+
var ConcatSource = require("webpack-sources").ConcatSource;
6+
var Template = require("webpack/lib/Template");
7+
8+
function NsJsonpHotUpdateChunkTemplatePlugin() {}
9+
module.exports = NsJsonpHotUpdateChunkTemplatePlugin;
10+
11+
//JSONP version
12+
NsJsonpHotUpdateChunkTemplatePlugin.prototype.apply = function(hotUpdateChunkTemplate) {
13+
hotUpdateChunkTemplate.plugin("render", function(modulesSource, modules, removedModules, hash, id) {
14+
var jsonpFunction = this.outputOptions.hotUpdateFunction;
15+
var source = new ConcatSource();
16+
source.add(jsonpFunction + "(" + JSON.stringify(id) + ",");
17+
source.add(modulesSource);
18+
source.add(")");
19+
return source;
20+
});
21+
hotUpdateChunkTemplate.plugin("hash", function(hash) {
22+
hash.update("JsonpHotUpdateChunkTemplatePlugin");
23+
hash.update("3");
24+
hash.update(this.outputOptions.hotUpdateFunction + "");
25+
hash.update(this.outputOptions.library + "");
26+
});
27+
};
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
/*
2+
MIT License http://www.opensource.org/licenses/mit-license.php
3+
Author Tobias Koppers @sokra
4+
*/
5+
var Template = require("webpack/lib/Template");
6+
7+
function JsonpMainTemplatePlugin() { }
8+
module.exports = JsonpMainTemplatePlugin;
9+
10+
JsonpMainTemplatePlugin.prototype.constructor = JsonpMainTemplatePlugin;
11+
JsonpMainTemplatePlugin.prototype.apply = function (mainTemplate) {
12+
mainTemplate.plugin("local-vars", function (source, chunk) {
13+
if (chunk.chunks.length > 0) {
14+
return this.asString([
15+
source,
16+
"// objects to store loaded and loading chunks",
17+
"var installedChunks = {",
18+
this.indent(
19+
chunk.ids.map(function (id) {
20+
return id + ": 0";
21+
}).join(",\n")
22+
),
23+
"};"
24+
]);
25+
}
26+
return source;
27+
});
28+
29+
mainTemplate.plugin("require-ensure", function (_, chunk, hash) {
30+
var chunkFilename = this.outputOptions.chunkFilename;
31+
var chunkMaps = chunk.getChunkMaps();
32+
var insertMoreModules = [
33+
"var moreModules = chunk.modules, chunkIds = chunk.ids;",
34+
"for(var moduleId in moreModules) {",
35+
this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")),
36+
"}"
37+
];
38+
39+
var request = this.applyPluginsWaterfall("asset-path", JSON.stringify("./" + chunkFilename), {
40+
hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
41+
hashWithLength: function (length) {
42+
return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
43+
}.bind(this),
44+
chunk: {
45+
id: "\" + chunkId + \"",
46+
hash: "\" + " + JSON.stringify(chunkMaps.hash) + "[chunkId] + \"",
47+
hashWithLength: function (length) {
48+
var shortChunkHashMap = {};
49+
Object.keys(chunkMaps.hash).forEach(function (chunkId) {
50+
if (typeof chunkMaps.hash[chunkId] === "string")
51+
shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
52+
});
53+
return "\" + " + JSON.stringify(shortChunkHashMap) + "[chunkId] + \"";
54+
},
55+
name: "\" + (" + JSON.stringify(chunkMaps.name) + "[chunkId]||chunkId) + \""
56+
}
57+
});
58+
59+
return this.asString([
60+
"// \"0\" is the signal for \"already loaded\"",
61+
"if(installedChunks[chunkId] !== 0) {",
62+
this.indent([
63+
"var chunk = require(" + request + ");"
64+
]),
65+
"}",
66+
"return Promise.resolve();"
67+
]);
68+
});
69+
mainTemplate.plugin("require-extensions", function (source, chunk) {
70+
if (chunk.chunks.length === 0) return source;
71+
return this.asString([
72+
source,
73+
"",
74+
"// on error function for async loading",
75+
this.requireFn + ".oe = function(err) { console.error(err); throw err; };"
76+
]);
77+
});
78+
mainTemplate.plugin("bootstrap", function (source, chunk, hash) {
79+
if (chunk.chunks.length > 0) {
80+
var jsonpFunction = this.outputOptions.jsonpFunction;
81+
return this.asString([
82+
source,
83+
"",
84+
"// install a JSONP callback for chunk loading",
85+
"var parentJsonpFunction = global[" + JSON.stringify(jsonpFunction) + "];",
86+
"global[" + JSON.stringify(jsonpFunction) + "] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {",
87+
this.indent([
88+
"// add \"moreModules\" to the modules object,",
89+
"// then flag all \"chunkIds\" as loaded and fire callback",
90+
"var moduleId, chunkId, i = 0, resolves = [], result;",
91+
"for(;i < chunkIds.length; i++) {",
92+
this.indent([
93+
"chunkId = chunkIds[i];",
94+
"if(installedChunks[chunkId])",
95+
this.indent("resolves.push(installedChunks[chunkId][0]);"),
96+
"installedChunks[chunkId] = 0;"
97+
]),
98+
"}",
99+
"for(moduleId in moreModules) {",
100+
this.indent([
101+
"if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {",
102+
this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")),
103+
"}"
104+
]),
105+
"}",
106+
"if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);",
107+
"while(resolves.length)",
108+
this.indent("resolves.shift()();"),
109+
this.entryPointInChildren(chunk) ? [
110+
"if(executeModules) {",
111+
this.indent([
112+
"for(i=0; i < executeModules.length; i++) {",
113+
this.indent("result = " + this.requireFn + "(" + this.requireFn + ".s = executeModules[i]);"),
114+
"}"
115+
]),
116+
"}",
117+
"return result;",
118+
] : ""
119+
]),
120+
"};"
121+
]);
122+
}
123+
return source;
124+
});
125+
mainTemplate.plugin("hot-bootstrap", function (source, chunk, hash) {
126+
var hotUpdateChunkFilename = this.outputOptions.hotUpdateChunkFilename;
127+
var hotUpdateMainFilename = this.outputOptions.hotUpdateMainFilename;
128+
var hotUpdateFunction = this.outputOptions.hotUpdateFunction;
129+
var currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), {
130+
hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
131+
hashWithLength: function (length) {
132+
return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
133+
}.bind(this),
134+
chunk: {
135+
id: "\" + chunkId + \""
136+
}
137+
});
138+
var currentHotUpdateMainFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), {
139+
hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
140+
hashWithLength: function (length) {
141+
return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
142+
}.bind(this)
143+
});
144+
145+
return source + "\n" +
146+
"function hotDisposeChunk(chunkId) {\n" +
147+
"\tdelete installedChunks[chunkId];\n" +
148+
"}\n" +
149+
"var parentHotUpdateCallback = this[" + JSON.stringify(hotUpdateFunction) + "];\n" +
150+
"this[" + JSON.stringify(hotUpdateFunction) + "] = " + Template.getFunctionContent(require("./JsonpMainTemplate.runtime.js"))
151+
.replace(/\/\/\$semicolon/g, ";")
152+
.replace(/\$require\$/g, this.requireFn)
153+
.replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
154+
.replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename)
155+
.replace(/\$hash\$/g, JSON.stringify(hash));
156+
});
157+
mainTemplate.plugin("hash", function (hash) {
158+
hash.update("jsonp");
159+
hash.update("4");
160+
hash.update(this.outputOptions.filename + "");
161+
hash.update(this.outputOptions.chunkFilename + "");
162+
hash.update(this.outputOptions.jsonpFunction + "");
163+
hash.update(this.outputOptions.hotUpdateFunction + "");
164+
});
165+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
MIT License http://www.opensource.org/licenses/mit-license.php
3+
Author Tobias Koppers @sokra
4+
*/
5+
var NsJsonpMainTemplatePlugin = require("./NsJsonpMainTemplatePlugin");
6+
var NsJsonpChunkTemplatePlugin = require("./NsJsonpChunkTemplatePlugin");
7+
var NsJsonpHotUpdateChunkTemplatePlugin = require("./NsJsonpHotUpdateChunkTemplatePlugin");
8+
9+
function JsonpTemplatePlugin() {}
10+
module.exports = JsonpTemplatePlugin;
11+
JsonpTemplatePlugin.prototype.apply = function(compiler) {
12+
compiler.plugin("this-compilation", function(compilation) {
13+
compilation.mainTemplate.apply(new NsJsonpMainTemplatePlugin());
14+
compilation.chunkTemplate.apply(new NsJsonpChunkTemplatePlugin());
15+
compilation.hotUpdateChunkTemplate.apply(new NsJsonpHotUpdateChunkTemplatePlugin());
16+
});
17+
};

‎nativescript-target/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = function nativescriptTarget(compiler) {
2+
var options = this;
3+
var webpackLib = "webpack/lib";
4+
5+
// Custom template plugin
6+
var NsJsonpTemplatePlugin = require("./NsJsonpTemplatePlugin");
7+
8+
var FunctionModulePlugin = require(webpackLib + "/FunctionModulePlugin");
9+
var NodeSourcePlugin = require(webpackLib + "/node/NodeSourcePlugin");
10+
var LoaderTargetPlugin = require(webpackLib + "/LoaderTargetPlugin");
11+
12+
compiler.apply(
13+
new NsJsonpTemplatePlugin(options.output),
14+
new FunctionModulePlugin(options.output),
15+
new NodeSourcePlugin(options.node),
16+
new LoaderTargetPlugin("web")
17+
);
18+
}

‎postinstall.js

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var appDir = path.join(projectDir, "app");
88
var packageJsonPath = path.join(projectDir, "package.json");
99
var packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
1010

11-
var isAngular = Object.keys(packageJson.dependencies).filter(function(dependency) {
11+
var isAngular = Object.keys(packageJson.dependencies).filter(function (dependency) {
1212
return /^@angular\b/.test(dependency);
1313
}).length > 0;
1414

@@ -17,18 +17,23 @@ if (isAngular) {
1717
isTypeScript = true;
1818
}
1919

20-
copyProjectTemplate("webpack.common.js.template", "webpack.common.js");
2120
copyProjectTemplate("webpack.android.js.template", "webpack.android.js");
2221
copyProjectTemplate("webpack.ios.js.template", "webpack.ios.js");
2322

2423
if (isAngular) {
25-
copyAppTemplate("vendor.ts.angular.template", tsOrJs("vendor"));
24+
copyProjectTemplate("webpack.common.js.angular.template", "webpack.common.js");
25+
copyProjectTemplate("tsconfig.aot.json.template", "tsconfig.aot.json");
2626
} else {
27-
copyAppTemplate("vendor.ts.nativescript.template", tsOrJs("vendor"));
27+
copyProjectTemplate("webpack.common.js.nativescript.template", "webpack.common.js");
2828
}
2929

3030
copyAppTemplate("vendor-platform.android.ts.template", tsOrJs("vendor-platform.android"));
3131
copyAppTemplate("vendor-platform.ios.ts.template", tsOrJs("vendor-platform.ios"));
32+
if (isAngular) {
33+
copyAppTemplate("vendor.ts.angular.template", tsOrJs("vendor"));
34+
} else {
35+
copyAppTemplate("vendor.ts.nativescript.template", tsOrJs("vendor"));
36+
}
3237

3338
addPlatformScript(packageJson, "clean-[PLATFORM]", "tns clean-app [PLATFORM]");
3439
addPlatformScript(packageJson, "prewebpack-[PLATFORM]", "npm run clean-[PLATFORM]");
@@ -38,16 +43,20 @@ addPlatformScript(packageJson, "start-[PLATFORM]-bundle", "tns run [PLATFORM] --
3843
addPlatformScript(packageJson, "prebuild-[PLATFORM]-bundle", "npm run webpack-[PLATFORM]");
3944
addPlatformScript(packageJson, "build-[PLATFORM]-bundle", "tns build [PLATFORM] --bundle --disable-npm-install");
4045

41-
configureDevDependencies(packageJson, function(add) {
42-
add("webpack", "~2.1.0-beta.25");
43-
add("webpack-sources", "~0.1.2");
46+
configureDevDependencies(packageJson, function (add) {
47+
add("webpack", "~2.1.0-beta.27");
4448
add("copy-webpack-plugin", "~3.0.1");
45-
add("awesome-typescript-loader", "~2.2.4");
46-
add("angular2-template-loader", "~0.6.0");
4749
add("raw-loader", "~0.5.1");
4850
add("css-loader", "~0.26.0");
4951
add("resolve-url-loader", "~1.6.0");
5052
add("extract-text-webpack-plugin", "~2.0.0-beta.4");
53+
54+
if (isAngular) {
55+
add("@angular/compiler-cli", "2.2.1");
56+
add("@ngtools/webpack", "1.1.6");
57+
} else {
58+
add("awesome-typescript-loader", "~2.2.4");
59+
}
5160
});
5261

5362
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 4));
@@ -58,7 +67,7 @@ function addPlatformScript(packageJson, nameTemplate, commandTemplate) {
5867
}
5968

6069
var scripts = packageJson.scripts;
61-
["android", "ios"].forEach(function(platform) {
70+
["android", "ios"].forEach(function (platform) {
6271
var name = nameTemplate.replace(/\[PLATFORM\]/g, platform);
6372
var command = commandTemplate.replace(/\[PLATFORM\]/g, platform);
6473
if (!scripts[name]) {
@@ -75,7 +84,7 @@ function configureDevDependencies(packageJson, adderCallback) {
7584
}
7685
var dependencies = packageJson.devDependencies;
7786

78-
adderCallback(function(name, version) {
87+
adderCallback(function (name, version) {
7988
if (!dependencies[name]) {
8089
dependencies[name] = version;
8190
console.info("Adding dev dependency: " + name + "@" + version);
@@ -88,7 +97,7 @@ function configureDevDependencies(packageJson, adderCallback) {
8897
if (pendingNpmInstall) {
8998
console.info("Installing new dependencies...");
9099
//Run `npm install` after everything else.
91-
setTimeout(function() {
100+
setTimeout(function () {
92101
var spawnArgs = [];
93102
if (/^win/.test(process.platform)) {
94103
spawnArgs = ["cmd.exe", ["/c", "npm", "install"]];
@@ -97,7 +106,7 @@ function configureDevDependencies(packageJson, adderCallback) {
97106
}
98107
spawnArgs.push({ cwd: projectDir, stdio: "inherit" });
99108
var npm = childProcess.spawn.apply(null, spawnArgs);
100-
npm.on("close", function(code) {
109+
npm.on("close", function (code) {
101110
process.exit(code);
102111
});
103112
}, 100);

‎tns-aot-loader.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function fixRelativeImports(fileName, source) {
2+
let result = source;
3+
4+
result = result.replace(/(\.\.\/)+platform\'/g, 'platform\'');
5+
result = result.replace(/(\.\.\/)+ui\/frame\'/g, 'ui/frame\'');
6+
result = result.replace(/(\.\.\/)+ui\/page\'/g, 'ui/page\'');
7+
8+
return result;
9+
}
10+
11+
12+
module.exports = function (source, map) {
13+
this.cacheable();
14+
var resultSource = fixRelativeImports(this.resource, source);
15+
this.callback(null, resultSource, map);
16+
};

‎tsconfig.aot.json.template

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "es2015",
5+
"moduleResolution": "node",
6+
"sourceMap": true,
7+
"emitDecoratorMetadata": true,
8+
"experimentalDecorators": true,
9+
"removeComments": false,
10+
"noImplicitAny": false,
11+
"suppressImplicitAnyIndexErrors": true,
12+
"types": []
13+
},
14+
15+
"angularCompilerOptions": {
16+
"skipMetadataEmit": true
17+
}
18+
}

‎vendor.ts.angular.template

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ require("./vendor-platform");
22

33
require('reflect-metadata');
44
require('@angular/platform-browser');
5-
require('@angular/platform-browser-dynamic');
65
require('@angular/core');
76
require('@angular/common');
87
require('@angular/forms');
98
require('@angular/http');
109
require('@angular/router');
1110

12-
require('nativescript-angular/platform');
11+
require('nativescript-angular/platform-static');
1312
require('nativescript-angular/forms');
1413
require('nativescript-angular/router');

‎webpack.common.js.angular.template

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
var webpack = require("webpack");
2+
var nsWebpack = require("nativescript-dev-webpack");
3+
var path = require("path");
4+
var CopyWebpackPlugin = require("copy-webpack-plugin");
5+
var ExtractTextPlugin = require("extract-text-webpack-plugin");
6+
var path = require("path");
7+
var AotPlugin = require('@ngtools/webpack').AotPlugin;
8+
9+
var nativescriptTarget = require('nativescript-dev-webpack/nativescript-target');
10+
11+
module.exports = function (platform, destinationApp) {
12+
if (!destinationApp) {
13+
//Default destination inside platforms/<platform>/...
14+
destinationApp = nsWebpack.getAppPath(platform);
15+
}
16+
var entry = {};
17+
//Discover entry module from package.json
18+
entry.bundle = "./" + nsWebpack.getEntryModule();
19+
//Vendor entry with third party libraries.
20+
entry.vendor = "./vendor";
21+
//app.css bundle
22+
entry["app.css"] = "./app.css";
23+
24+
return {
25+
context: path.resolve("./app"),
26+
target: nativescriptTarget,
27+
entry: entry,
28+
output: {
29+
pathinfo: true,
30+
path: path.resolve(destinationApp),
31+
libraryTarget: "commonjs2",
32+
filename: "[name].js",
33+
},
34+
resolve: {
35+
//Resolve platform-specific modules like module.android.js
36+
extensions: [
37+
".aot.ts",
38+
".ts",
39+
".js",
40+
".css",
41+
"." + platform + ".ts",
42+
"." + platform + ".js",
43+
"." + platform + ".css",
44+
],
45+
//Resolve {N} system modules from tns-core-modules
46+
modules: [
47+
"node_modules/tns-core-modules",
48+
"node_modules"
49+
]
50+
},
51+
node: {
52+
//Disable node shims that conflict with NativeScript
53+
"http": false,
54+
"timers": false,
55+
"setImmediate": false,
56+
},
57+
module: {
58+
loaders: [
59+
{
60+
test: /\.html$/,
61+
loader: "raw-loader"
62+
},
63+
// Root app.css file gets extracted with bundled dependencies
64+
{
65+
test: /app\.css$/,
66+
loader: ExtractTextPlugin.extract([
67+
"resolve-url-loader",
68+
"css-loader",
69+
"nativescript-dev-webpack/platform-css-loader",
70+
]),
71+
},
72+
// Other CSS files get bundled using the raw loader
73+
{
74+
test: /\.css$/,
75+
exclude: /app\.css$/,
76+
loaders: [
77+
"raw-loader",
78+
]
79+
},
80+
// Compile TypeScript files with ahead-of-time compiler.
81+
{
82+
test: /\.ts$/,
83+
loaders: [
84+
'@ngtools/webpack',
85+
'nativescript-dev-webpack/tns-aot-loader'
86+
]
87+
},
88+
// SASS support
89+
{
90+
test: /\.scss$/,
91+
loaders: [
92+
"raw-loader",
93+
"resolve-url-loader",
94+
"sass-loader"
95+
]
96+
},
97+
]
98+
},
99+
plugins: [
100+
new ExtractTextPlugin("app.css"),
101+
//Vendor libs go to the vendor.js chunk
102+
new webpack.optimize.CommonsChunkPlugin({
103+
name: ["vendor"]
104+
}),
105+
//Define useful constants like TNS_WEBPACK
106+
new webpack.DefinePlugin({
107+
global: "global",
108+
__dirname: "__dirname",
109+
"global.TNS_WEBPACK": "true",
110+
}),
111+
//Copy assets to out dir. Add your own globs as needed.
112+
new CopyWebpackPlugin([
113+
{ from: "app.css" },
114+
{ from: "css/**" },
115+
{ from: "**/*.jpg" },
116+
{ from: "**/*.png" },
117+
{ from: "**/*.xml" },
118+
], { ignore: ["App_Resources/**"] }),
119+
//Generate a bundle starter script and activate it in package.json
120+
new nsWebpack.GenerateBundleStarterPlugin([
121+
"./vendor",
122+
"./bundle",
123+
]),
124+
//Angular AOT compiler
125+
new AotPlugin({
126+
tsConfigPath: 'tsconfig.aot.json',
127+
entryModule: 'app/app.module#AppModule',
128+
typeChecking: false
129+
})
130+
],
131+
};
132+
};

‎webpack.common.js.template renamed to ‎webpack.common.js.nativescript.template

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ var path = require("path");
44
var CopyWebpackPlugin = require("copy-webpack-plugin");
55
var ExtractTextPlugin = require("extract-text-webpack-plugin");
66
var path = require("path");
7+
var nativescriptTarget = require('nativescript-dev-webpack/nativescript-target');
78

8-
module.exports = function(platform, destinationApp) {
9+
module.exports = function (platform, destinationApp) {
910
if (!destinationApp) {
1011
//Default destination inside platforms/<platform>/...
1112
destinationApp = nsWebpack.getAppPath(platform);
@@ -20,13 +21,13 @@ module.exports = function(platform, destinationApp) {
2021

2122
return {
2223
context: path.resolve("./app"),
24+
target: nativescriptTarget,
2325
entry: entry,
2426
output: {
2527
pathinfo: true,
2628
path: path.resolve(destinationApp),
2729
libraryTarget: "commonjs2",
2830
filename: "[name].js",
29-
jsonpFunction: "nativescriptJsonp"
3031
},
3132
resolve: {
3233
//Resolve platform-specific modules like module.android.js
@@ -77,8 +78,7 @@ module.exports = function(platform, destinationApp) {
7778
{
7879
test: /\.ts$/,
7980
loaders: [
80-
"awesome-typescript-loader",
81-
"angular2-template-loader"
81+
"awesome-typescript-loader"
8282
]
8383
},
8484
// SASS support
@@ -106,19 +106,17 @@ module.exports = function(platform, destinationApp) {
106106
}),
107107
//Copy assets to out dir. Add your own globs as needed.
108108
new CopyWebpackPlugin([
109-
{from: "app.css"},
110-
{from: "css/**"},
111-
{from: "**/*.jpg"},
112-
{from: "**/*.png"},
113-
{from: "**/*.xml"},
114-
], {ignore: ["App_Resources/**"]}),
109+
{ from: "app.css" },
110+
{ from: "css/**" },
111+
{ from: "**/*.jpg" },
112+
{ from: "**/*.png" },
113+
{ from: "**/*.xml" },
114+
], { ignore: ["App_Resources/**"] }),
115115
//Generate a bundle starter script and activate it in package.json
116116
new nsWebpack.GenerateBundleStarterPlugin([
117117
"./vendor",
118118
"./bundle",
119119
]),
120-
//Required for bundle chunks loading
121-
new nsWebpack.NativeScriptJsonpPlugin(),
122120
],
123121
};
124122
};

0 commit comments

Comments
 (0)
This repository has been archived.