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

Commit 790e386

Browse files
authored
Merge branch 'master' into dependencies
2 parents 4e622ae + fc4e415 commit 790e386

16 files changed

+110
-49
lines changed

Diff for: CHANGELOG.md

+26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
<a name="0.24.1"></a>
2+
## [0.24.1](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.24.0...0.24.1) (2019-06-06)
3+
4+
5+
### Bug Fixes
6+
7+
* move the type check to a child process in order to make it faster in bigger apps and unify the hmr and no-hmr experience. ([#926](https://github.com/NativeScript/nativescript-dev-webpack/issues/926)) ([1398179](https://github.com/NativeScript/nativescript-dev-webpack/commit/1398179))
8+
* stop generating .d.ts on TS compilation ([#919](https://github.com/NativeScript/nativescript-dev-webpack/issues/919)) ([ccbf8de](https://github.com/NativeScript/nativescript-dev-webpack/commit/ccbf8de))
9+
10+
11+
12+
<a name="0.24.0"></a>
13+
# [0.24.0](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.22.0...0.24.0) (2019-05-30)
14+
15+
16+
### Bug Fixes
17+
18+
* import the workaroundResolve funciton based on the Angular version (it was moved from compiler_host to utils in Angular 8) ([#904](https://github.com/NativeScript/nativescript-dev-webpack/pull/904)) ([56224a8](https://github.com/NativeScript/nativescript-dev-webpack/commit/56224a898b46fc8542f8b5928c52e9e4cb6022e2))
19+
20+
21+
### Features
22+
23+
* update deps to Angular 8.0.0 deps ([#904](https://github.com/NativeScript/nativescript-dev-webpack/pull/904)) ([d6afb74](https://github.com/NativeScript/nativescript-dev-webpack/commit/d6afb7436585d41c4188a2373d376f2b51bc541e))
24+
25+
26+
127
<a name="0.22.0"></a>
228
# [0.22.0](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.21.0...0.22.0) (2019-05-15)
329

Diff for: demo/AngularApp/app/activity.android.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import {setActivityCallbacks, AndroidActivityCallbacks} from "tns-core-modules/ui/frame";
1+
import { setActivityCallbacks, AndroidActivityCallbacks } from "tns-core-modules/ui/frame";
22

33
@JavaProxy("org.myApp.MainActivity")
4-
class Activity extends android.support.v7.app.AppCompatActivity {
4+
class Activity extends androidx.appcompat.app.AppCompatActivity {
55
public isNativeScriptActivity: boolean;
66
private _callbacks: AndroidActivityCallbacks;
77

88
protected onCreate(savedInstanceState: any): void { // android.os.Bundle
99
// Set isNativeScriptActivity in onCreate (as done in the original NativeScript activity code).
1010
// The JS constructor might not be called because the activity is created from Android.
1111
this.isNativeScriptActivity = true;
12-
12+
1313
if (!this._callbacks) {
1414
setActivityCallbacks(this);
1515
}

Diff for: demo/AngularApp/app/application.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
declare const android: any;
2+
declare const androidx: any;

Diff for: demo/AngularApp/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module.exports = env => {
6262
const entryPath = `.${sep}${entryModule}`;
6363
const entries = { bundle: entryPath, application: "./application.android" };
6464
if (platform === "ios") {
65-
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js";
65+
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules";
6666
};
6767

6868
const ngCompilerTransformers = [];

Diff for: demo/JavaScriptApp/app/activity.android.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const frame = require("ui/frame");
22

3-
const superProto = android.support.v7.app.AppCompatActivity.prototype;
4-
android.support.v7.app.AppCompatActivity.extend("org.myApp.MainActivity", {
3+
const superProto = androidx.appcompat.app.AppCompatActivity.prototype;
4+
androidx.appcompat.app.AppCompatActivity.extend("org.myApp.MainActivity", {
55
onCreate: function(savedInstanceState) {
66
// Set isNativeScriptActivity in onCreate.
77
// The JS constructor might not be called because the activity is created from Android.

Diff for: demo/JavaScriptApp/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module.exports = env => {
5656
const entryPath = `.${sep}${entryModule}.js`;
5757
const entries = { bundle: entryPath, application: "./application.android" };
5858
if (platform === "ios") {
59-
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js";
59+
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules";
6060
};
6161

6262
let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);

Diff for: demo/TypeScriptApp/app/activity.android.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {setActivityCallbacks, AndroidActivityCallbacks} from "ui/frame";
22

33
@JavaProxy("org.myApp.MainActivity")
4-
class Activity extends android.support.v7.app.AppCompatActivity {
4+
class Activity extends androidx.appcompat.app.AppCompatActivity {
55
public isNativeScriptActivity: boolean;
66
private _callbacks: AndroidActivityCallbacks;
77
protected onCreate(savedInstanceState: any): void { // android.os.Bundle

Diff for: demo/TypeScriptApp/app/application.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
declare const android: any;
2+
declare const androidx: any;

Diff for: demo/TypeScriptApp/nsconfig.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"useLegacyWorkflow": false
3+
}

Diff for: demo/TypeScriptApp/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module.exports = env => {
6060
const tsConfigPath = resolve(projectRoot, "tsconfig.tns.json");
6161

6262
if (platform === "ios") {
63-
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js";
63+
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules";
6464
};
6565

6666
let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);

Diff for: plugins/GenerateNativeScriptEntryPointsPlugin.js

+27-23
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { RawSource } = require("webpack-sources");
22
const { getPackageJson } = require("../projectHelpers");
33
const { SNAPSHOT_ENTRY_NAME } = require("./NativeScriptSnapshotPlugin");
4-
4+
const path = require("path");
55

66
exports.GenerateNativeScriptEntryPointsPlugin = (function () {
77
const GenerationFailedError = "Unable to generate entry files.";
@@ -49,38 +49,42 @@ exports.GenerateNativeScriptEntryPointsPlugin = (function () {
4949
return;
5050
}
5151

52-
const requireDeps =
53-
entryPoint.chunks.map(chunk => {
54-
let requireChunkFiles = "";
55-
if (chunk.name === entryPointName) {
56-
entryChunk = chunk;
57-
} else {
58-
chunk.files.forEach(fileName => {
59-
if (!this.isHMRFile(fileName)) {
60-
requireChunkFiles += `require("./${fileName}");`;
61-
}
62-
});
63-
}
64-
65-
return requireChunkFiles;
66-
}).join("");
52+
const requiredFiles = [];
53+
entryPoint.chunks.forEach(chunk => {
54+
if (chunk.name === entryPointName) {
55+
entryChunk = chunk;
56+
} else {
57+
chunk.files.forEach(fileName => {
58+
if (!this.isHMRFile(fileName)) {
59+
requiredFiles.push(fileName);
60+
}
61+
});
62+
}
63+
});
6764

6865
if (!entryChunk) {
6966
throw new Error(`${GenerationFailedError} Entry chunk not found for entry "${entryPointName}".`);
7067
}
7168

72-
entryChunk.files.forEach(fileName => {
73-
if (!compilation.assets[fileName]) {
74-
throw new Error(`${GenerationFailedError} File "${fileName}" not found for entry "${entryPointName}".`);
69+
entryChunk.files.forEach(filePath => {
70+
if (!compilation.assets[filePath]) {
71+
throw new Error(`${GenerationFailedError} File "${filePath}" not found for entry "${entryPointName}".`);
7572
}
7673

77-
if (!this.isHMRFile(fileName)) {
78-
const currentEntryFileContent = compilation.assets[fileName].source();
79-
compilation.assets[fileName] = new RawSource(`${requireDeps}${currentEntryFileContent}`);
74+
if (!this.isHMRFile(filePath)) {
75+
const currFileDirRelativePath = path.dirname(filePath);
76+
const pathToRootFromCurrFile = path.relative(currFileDirRelativePath, ".");
77+
78+
const requireDeps = requiredFiles.map(depPath => {
79+
const depRelativePath = path.join(pathToRootFromCurrFile, depPath);
80+
81+
return `require("./${depRelativePath}");`;
82+
}).join("");
83+
const currentEntryFileContent = compilation.assets[filePath].source();
84+
compilation.assets[filePath] = new RawSource(`${requireDeps}${currentEntryFileContent}`);
8085
}
8186
});
8287
}
83-
8488
GenerateNativeScriptEntryPointsPlugin.prototype.addAsset = function (compilation, name, content) {
8589
if (this.files[name] !== content) {
8690
this.files[name] = content;

Diff for: templates/webpack.angular.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ module.exports = env => {
6060
const entryModule = `${nsWebpack.getEntryModule(appFullPath, platform)}.ts`;
6161
const entryPath = `.${sep}${entryModule}`;
6262
const entries = { bundle: entryPath };
63-
if (platform === "ios") {
64-
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js";
63+
const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some(e => e.indexOf("tns-core-modules") > -1);
64+
if (platform === "ios" && !areCoreModulesExternal) {
65+
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules";
6566
};
6667

6768
const ngCompilerTransformers = [];

Diff for: templates/webpack.config.spec.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ describe('webpack.config.js', () => {
115115
expect(isCalled).toBe(true, 'Webpack.config.js must use the getConvertedExternals method');
116116
});
117117

118+
if (platform === "ios") {
119+
it('has inspector_modules entry when tns-core-modules are not externals', () => {
120+
const input = getInput({ platform, externals: ['nativescript-vue'] });
121+
const config = webpackConfig(input);
122+
expect(config.entry["tns_modules/tns-core-modules/inspector_modules"]).toEqual("inspector_modules");
123+
});
124+
125+
it('does not have inspector_modules entry when tns-core-modules are externals', () => {
126+
const input = getInput({ platform, externals: ['tns-core-modules'] });
127+
const config = webpackConfig(input);
128+
expect(config.entry["tns_modules/tns-core-modules/inspector_modules"]).toBeUndefined();
129+
});
130+
}
131+
118132
[
119133
{
120134
input: ['nativescript-vue'],
@@ -343,4 +357,4 @@ describe('webpack.config.js', () => {
343357
});
344358
});
345359
});
346-
});
360+
});

Diff for: templates/webpack.javascript.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ module.exports = env => {
5454
const entryModule = nsWebpack.getEntryModule(appFullPath, platform);
5555
const entryPath = `.${sep}${entryModule}.js`;
5656
const entries = { bundle: entryPath };
57-
if (platform === "ios") {
58-
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js";
57+
const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some(e => e.indexOf("tns-core-modules") > -1);
58+
if (platform === "ios" && !areCoreModulesExternal) {
59+
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules";
5960
};
6061

6162
let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);

Diff for: templates/webpack.typescript.js

+16-10
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ module.exports = env => {
5858

5959
const tsConfigPath = resolve(projectRoot, "tsconfig.tns.json");
6060

61-
if (platform === "ios") {
62-
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js";
61+
const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some(e => e.indexOf("tns-core-modules") > -1);
62+
if (platform === "ios" && !areCoreModulesExternal) {
63+
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules";
6364
};
6465

6566
let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);
@@ -211,10 +212,13 @@ module.exports = env => {
211212
loader: "ts-loader",
212213
options: {
213214
configFile: tsConfigPath,
214-
transpileOnly: !!hmr,
215+
// https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#faster-builds
216+
// https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#hot-module-replacement
217+
transpileOnly: true,
215218
allowTsInNodeModules: true,
216219
compilerOptions: {
217-
sourceMap: isAnySourceMapEnabled
220+
sourceMap: isAnySourceMapEnabled,
221+
declaration: false
218222
}
219223
},
220224
}
@@ -245,6 +249,14 @@ module.exports = env => {
245249
}),
246250
// Does IPC communication with the {N} CLI to notify events when running in watch mode.
247251
new nsWebpack.WatchStateLoggerPlugin(),
252+
// https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#faster-builds
253+
// https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#hot-module-replacement
254+
new ForkTsCheckerWebpackPlugin({
255+
tsconfig: tsConfigPath,
256+
async: false,
257+
useTypescriptIncrementalApi: true,
258+
memoryLimit: 4096
259+
})
248260
],
249261
};
250262

@@ -284,12 +296,6 @@ module.exports = env => {
284296

285297
if (hmr) {
286298
config.plugins.push(new webpack.HotModuleReplacementPlugin());
287-
288-
// With HMR ts-loader should run in `transpileOnly` mode,
289-
// so assure type-checking with fork-ts-checker-webpack-plugin
290-
config.plugins.push(new ForkTsCheckerWebpackPlugin({
291-
tsconfig: tsConfigPath
292-
}));
293299
}
294300

295301

Diff for: templates/webpack.vue.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ module.exports = env => {
6161
const entryModule = nsWebpack.getEntryModule(appFullPath, platform);
6262
const entryPath = `.${sep}${entryModule}`;
6363
const entries = { bundle: entryPath };
64-
if (platform === "ios") {
65-
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js";
64+
const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some(e => e.indexOf("tns-core-modules") > -1);
65+
if (platform === "ios" && !areCoreModulesExternal) {
66+
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules";
6667
};
6768
console.log(`Bundling application for entryPath ${entryPath}...`);
6869

@@ -209,6 +210,9 @@ module.exports = env => {
209210
options: {
210211
appendTsSuffixTo: [/\.vue$/],
211212
allowTsInNodeModules: true,
213+
compilerOptions: {
214+
declaration: false
215+
}
212216
},
213217
},
214218
{

0 commit comments

Comments
 (0)