Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 2ce3780

Browse files
authored
refactor(templates): specify tsconfig path for @ngtools/webpack loader (#267)
- the tsconfig path is needed when worker scripts are transpiled
1 parent 83047a3 commit 2ce3780

File tree

4 files changed

+33
-21
lines changed

4 files changed

+33
-21
lines changed

prepublish/angular/imports.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
module.exports = `const { AotPlugin } = require("@ngtools/webpack");`;
1+
module.exports = `const { AotPlugin } = require("@ngtools/webpack");
2+
3+
const ngToolsWebpackOptions = { tsConfigPath: "tsconfig.aot.json" };`;

prepublish/angular/plugins.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
module.exports = `
22
// Angular AOT compiler
3-
new AotPlugin({
4-
tsConfigPath: "tsconfig.aot.json",
5-
entryModule: resolve(__dirname, "app/app.module#AppModule"),
6-
typeChecking: false
7-
}),
3+
new AotPlugin(
4+
Object.assign({
5+
entryModule: resolve(__dirname, "app/app.module#AppModule"),
6+
typeChecking: false
7+
}, ngToolsWebpackOptions)
8+
),
89
910
// Resolve .ios.css and .android.css component stylesheets, and .ios.html and .android component views
1011
new nsWebpack.UrlResolvePlugin({

prepublish/angular/rules.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
module.exports = `
22
// Compile TypeScript files with ahead-of-time compiler.
33
{
4-
test: /\\.ts$/,
5-
loaders: [
6-
"nativescript-dev-webpack/tns-aot-loader",
7-
"@ngtools/webpack",
4+
test: /\.ts$/,
5+
use: [
6+
{ loader: "nativescript-dev-webpack/tns-aot-loader" },
7+
{
8+
loader: "@ngtools/webpack",
9+
options: ngToolsWebpackOptions,
10+
},
811
]
9-
}
12+
},
1013
`;

templates/webpack.angular.js

+16-10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
99

1010
const { AotPlugin } = require("@ngtools/webpack");
1111

12+
const ngToolsWebpackOptions = { tsConfigPath: "tsconfig.aot.json" };
13+
1214
const mainSheet = `app.css`;
1315

1416
module.exports = env => {
@@ -131,12 +133,15 @@ function getRules() {
131133

132134
// Compile TypeScript files with ahead-of-time compiler.
133135
{
134-
test: /\.ts$/,
135-
loaders: [
136-
"nativescript-dev-webpack/tns-aot-loader",
137-
"@ngtools/webpack",
136+
test: /.ts$/,
137+
use: [
138+
{ loader: "nativescript-dev-webpack/tns-aot-loader" },
139+
{
140+
loader: "@ngtools/webpack",
141+
options: ngToolsWebpackOptions,
142+
},
138143
]
139-
}
144+
},
140145

141146
];
142147
}
@@ -181,11 +186,12 @@ function getPlugins(platform, env) {
181186
}),
182187

183188
// Angular AOT compiler
184-
new AotPlugin({
185-
tsConfigPath: "tsconfig.aot.json",
186-
entryModule: resolve(__dirname, "app/app.module#AppModule"),
187-
typeChecking: false
188-
}),
189+
new AotPlugin(
190+
Object.assign({
191+
entryModule: resolve(__dirname, "app/app.module#AppModule"),
192+
typeChecking: false
193+
}, ngToolsWebpackOptions)
194+
),
189195

190196
// Resolve .ios.css and .android.css component stylesheets, and .ios.html and .android component views
191197
new nsWebpack.UrlResolvePlugin({

0 commit comments

Comments
 (0)