Skip to content

Commit 2120dfb

Browse files
committed
update demos to latest deps
1 parent d345ab2 commit 2120dfb

11 files changed

+6635
-10385
lines changed

demo-ng/package-lock.json

Lines changed: 3648 additions & 7090 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-ng/package.json

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"nativescript": {
77
"id": "com.tangrainc.dropdownsample.ng",
88
"tns-android": {
9-
"version": "4.1.3"
9+
"version": "5.2.1"
1010
},
1111
"tns-ios": {
12-
"version": "4.1.1"
12+
"version": "5.2.0"
1313
}
1414
},
1515
"scripts": {
@@ -25,45 +25,33 @@
2525
"build-ios-bundle": "npm run ns-bundle --ios --build-app"
2626
},
2727
"dependencies": {
28-
"@angular/animations": "~6.0.6",
29-
"@angular/common": "~6.0.6",
30-
"@angular/compiler": "~6.0.6",
31-
"@angular/core": "~6.0.6",
32-
"@angular/forms": "~6.0.6",
33-
"@angular/http": "~6.0.6",
34-
"@angular/platform-browser": "~6.0.6",
35-
"@angular/platform-browser-dynamic": "~6.0.6",
36-
"@angular/router": "~6.0.6",
37-
"nativescript-angular": "^6.0.6",
28+
"@angular/animations": "~7.2.0",
29+
"@angular/common": "~7.2.0",
30+
"@angular/compiler": "~7.2.0",
31+
"@angular/core": "~7.2.0",
32+
"@angular/forms": "~7.2.0",
33+
"@angular/http": "~7.2.0",
34+
"@angular/platform-browser": "~7.2.0",
35+
"@angular/platform-browser-dynamic": "~7.2.0",
36+
"@angular/router": "~7.2.0",
37+
"nativescript-angular": "^7.2.2",
3838
"nativescript-drop-down": "file:../bin/dist",
3939
"reflect-metadata": "~0.1.8",
40-
"rxjs": "~6.0.0 || >=6.1.0",
41-
"tns-core-modules": "^4.1.0",
42-
"zone.js": "^0.8.26"
40+
"rxjs": "^6.3.3",
41+
"tns-core-modules": "^5.2.2",
42+
"zone.js": "^0.8.4"
4343
},
4444
"devDependencies": {
45-
"@angular-devkit/core": "~0.6.3",
46-
"@angular/compiler-cli": "~6.0.6",
47-
"@ngtools/webpack": "~6.0.3",
45+
"@angular/compiler-cli": "~7.2.0",
46+
"@ngtools/webpack": "~7.2.0",
4847
"babel-traverse": "6.24.1",
4948
"babel-types": "6.24.1",
5049
"babylon": "6.17.0",
51-
"clean-webpack-plugin": "~0.1.19",
52-
"copy-webpack-plugin": "~4.5.1",
53-
"css-loader": "~0.28.11",
5450
"extract-text-webpack-plugin": "~3.0.2",
5551
"lazy": "1.0.11",
5652
"nativescript-css-loader": "~0.26.0",
5753
"nativescript-dev-typescript": "^0.7.1",
58-
"nativescript-dev-webpack": "^0.12.0",
59-
"nativescript-worker-loader": "~0.9.0",
60-
"raw-loader": "~0.5.1",
61-
"resolve-url-loader": "~2.3.0",
62-
"typescript": "~2.7.2",
63-
"uglifyjs-webpack-plugin": "~1.2.5",
64-
"webpack": "~4.6.0",
65-
"webpack-bundle-analyzer": "~2.13.0",
66-
"webpack-cli": "~2.1.3",
67-
"webpack-sources": "~1.1.0"
54+
"nativescript-dev-webpack": "^0.20.2",
55+
"typescript": "~3.1.1"
6856
}
6957
}

demo-ng/tsconfig.tns.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig",
3+
"compilerOptions": {
4+
"module": "es2015",
5+
"moduleResolution": "node"
6+
}
7+
}

demo-ng/webpack.config.js

Lines changed: 72 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
const { join, relative, resolve, sep } = require("path");
1+
const { join, relative, resolve, sep, dirname } = require("path");
22

33
const webpack = require("webpack");
44
const nsWebpack = require("nativescript-dev-webpack");
55
const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
6+
const { nsReplaceBootstrap } = require("nativescript-dev-webpack/transformers/ns-replace-bootstrap");
7+
const { nsReplaceLazyLoader } = require("nativescript-dev-webpack/transformers/ns-replace-lazy-loader");
8+
const { nsSupportHmrNg } = require("nativescript-dev-webpack/transformers/ns-support-hmr-ng");
9+
const { getMainModulePath } = require("nativescript-dev-webpack/utils/ast-utils");
610
const CleanWebpackPlugin = require("clean-webpack-plugin");
711
const CopyWebpackPlugin = require("copy-webpack-plugin");
812
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
913
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
1014
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
15+
const { AngularCompilerPlugin } = require("@ngtools/webpack");
1116

1217
module.exports = env => {
1318
// Add your custom Activities, Services and other Android app components here.
@@ -21,9 +26,7 @@ module.exports = env => {
2126
throw new Error("You need to provide a target platform!");
2227
}
2328

24-
const platforms = ["ios", "android"];
2529
const projectRoot = __dirname;
26-
nsWebpack.loadAdditionalPlugins({ projectDir: projectRoot });
2730

2831
// Default destination inside platforms/<platform>/...
2932
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));
@@ -33,27 +36,62 @@ module.exports = env => {
3336
// The 'appPath' and 'appResourcesPath' values are fetched from
3437
// the nsconfig.json configuration file
3538
// when bundling with `tns run android|ios --bundle`.
36-
appPath = "app",
37-
appResourcesPath = "app/App_Resources",
39+
appPath = "src",
40+
appResourcesPath = "App_Resources",
3841

3942
// You can provide the following flags when running 'tns run android|ios'
4043
aot, // --env.aot
4144
snapshot, // --env.snapshot
4245
uglify, // --env.uglify
4346
report, // --env.report
47+
sourceMap, // --env.sourceMap
48+
hmr, // --env.hmr,
4449
} = env;
4550

51+
const externals = nsWebpack.getConvertedExternals(env.externals);
4652
const appFullPath = resolve(projectRoot, appPath);
4753
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
48-
49-
const entryModule = aot ?
50-
nsWebpack.getAotEntryModule(appFullPath) :
51-
`${nsWebpack.getEntryModule(appFullPath)}.ts`;
54+
const tsConfigName = "tsconfig.tns.json";
55+
const entryModule = `${nsWebpack.getEntryModule(appFullPath)}.ts`;
5256
const entryPath = `.${sep}${entryModule}`;
57+
const ngCompilerTransformers = [];
58+
const additionalLazyModuleResources = [];
59+
if (aot) {
60+
ngCompilerTransformers.push(nsReplaceBootstrap);
61+
}
62+
63+
if (hmr) {
64+
ngCompilerTransformers.push(nsSupportHmrNg);
65+
}
66+
67+
// when "@angular/core" is external, it's not included in the bundles. In this way, it will be used
68+
// directly from node_modules and the Angular modules loader won't be able to resolve the lazy routes
69+
// fixes https://github.com/NativeScript/nativescript-cli/issues/4024
70+
if (env.externals && env.externals.indexOf("@angular/core") > -1) {
71+
const appModuleRelativePath = getMainModulePath(resolve(appFullPath, entryModule), tsConfigName);
72+
if (appModuleRelativePath) {
73+
const appModuleFolderPath = dirname(resolve(appFullPath, appModuleRelativePath));
74+
// include the lazy loader inside app module
75+
ngCompilerTransformers.push(nsReplaceLazyLoader);
76+
// include the new lazy loader path in the allowed ones
77+
additionalLazyModuleResources.push(appModuleFolderPath);
78+
}
79+
}
80+
81+
const ngCompilerPlugin = new AngularCompilerPlugin({
82+
hostReplacementPaths: nsWebpack.getResolver([platform, "tns"]),
83+
platformTransformers: ngCompilerTransformers.map(t => t(() => ngCompilerPlugin, resolve(appFullPath, entryModule))),
84+
mainPath: resolve(appPath, entryModule),
85+
tsConfigPath: join(__dirname, tsConfigName),
86+
skipCodeGeneration: !aot,
87+
sourceMap: !!sourceMap,
88+
additionalLazyModuleResources: additionalLazyModuleResources
89+
});
5390

5491
const config = {
5592
mode: uglify ? "production" : "development",
5693
context: appFullPath,
94+
externals,
5795
watchOptions: {
5896
ignored: [
5997
appResourcesFullPath,
@@ -97,7 +135,7 @@ module.exports = env => {
97135
"fs": "empty",
98136
"__dirname": false,
99137
},
100-
devtool: "none",
138+
devtool: sourceMap ? "inline-source-map" : "none",
101139
optimization: {
102140
splitChunks: {
103141
cacheGroups: {
@@ -107,7 +145,7 @@ module.exports = env => {
107145
test: (module, chunks) => {
108146
const moduleName = module.nameForCondition ? module.nameForCondition() : '';
109147
return /[\\/]node_modules[\\/]/.test(moduleName) ||
110-
appComponents.some(comp => comp === moduleName);
148+
appComponents.some(comp => comp === moduleName);
111149
},
112150
enforce: true,
113151
},
@@ -116,9 +154,9 @@ module.exports = env => {
116154
minimize: !!uglify,
117155
minimizer: [
118156
new UglifyJsPlugin({
157+
parallel: true,
158+
cache: true,
119159
uglifyOptions: {
120-
parallel: true,
121-
cache: true,
122160
output: {
123161
comments: false,
124162
},
@@ -146,7 +184,7 @@ module.exports = env => {
146184
{
147185
loader: "nativescript-dev-webpack/bundle-config-loader",
148186
options: {
149-
registerPages: false,
187+
angular: true,
150188
loadCss: !snapshot, // load the application css if in debug mode
151189
}
152190
},
@@ -158,14 +196,15 @@ module.exports = env => {
158196
// tns-core-modules reads the app.css and its imports using css-loader
159197
{
160198
test: /[\/|\\]app\.css$/,
161-
use: {
162-
loader: "css-loader",
163-
options: { minimize: false, url: false },
164-
}
199+
use: [
200+
"nativescript-dev-webpack/style-hot-loader",
201+
{ loader: "css-loader", options: { minimize: false, url: false } }
202+
]
165203
},
166204
{
167205
test: /[\/|\\]app\.scss$/,
168206
use: [
207+
"nativescript-dev-webpack/style-hot-loader",
169208
{ loader: "css-loader", options: { minimize: false, url: false } },
170209
"sass-loader"
171210
]
@@ -175,10 +214,11 @@ module.exports = env => {
175214
{ test: /\.css$/, exclude: /[\/|\\]app\.css$/, use: "raw-loader" },
176215
{ test: /\.scss$/, exclude: /[\/|\\]app\.scss$/, use: ["raw-loader", "resolve-url-loader", "sass-loader"] },
177216

178-
// Compile TypeScript files with ahead-of-time compiler.
179217
{
180-
test: /.ts$/, use: [
218+
test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
219+
use: [
181220
"nativescript-dev-webpack/moduleid-compat-loader",
221+
"nativescript-dev-webpack/lazy-ngmodule-hot-loader",
182222
"@ngtools/webpack",
183223
]
184224
},
@@ -195,9 +235,10 @@ module.exports = env => {
195235
// Define useful constants like TNS_WEBPACK
196236
new webpack.DefinePlugin({
197237
"global.TNS_WEBPACK": "true",
238+
"process": undefined,
198239
}),
199240
// Remove all files from the out dir.
200-
new CleanWebpackPlugin([ `${dist}/**/*` ]),
241+
new CleanWebpackPlugin([`${dist}/**/*`]),
201242
// Copy native app resources to out dir.
202243
new CopyWebpackPlugin([
203244
{
@@ -208,9 +249,9 @@ module.exports = env => {
208249
]),
209250
// Copy assets to out dir. Add your own globs as needed.
210251
new CopyWebpackPlugin([
211-
{ from: "fonts/**" },
212-
{ from: "**/*.jpg" },
213-
{ from: "**/*.png" },
252+
{ from: { glob: "fonts/**" } },
253+
{ from: { glob: "**/*.jpg" } },
254+
{ from: { glob: "**/*.png" } },
214255
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
215256
// Generate a bundle starter script and activate it in package.json
216257
new nsWebpack.GenerateBundleStarterPlugin([
@@ -220,21 +261,13 @@ module.exports = env => {
220261
// For instructions on how to set up workers with webpack
221262
// check out https://github.com/nativescript/worker-loader
222263
new NativeScriptWorkerPlugin(),
223-
// AngularCompilerPlugin with augmented NativeScript filesystem to handle platform specific resource resolution.
224-
new nsWebpack.NativeScriptAngularCompilerPlugin({
225-
entryModule: resolve(appPath, "app.module#AppModule"),
226-
tsConfigPath: join(__dirname, "tsconfig.esm.json"),
227-
skipCodeGeneration: !aot,
228-
platformOptions: {
229-
platform,
230-
platforms,
231-
},
232-
}),
264+
ngCompilerPlugin,
233265
// Does IPC communication with the {N} CLI to notify events when running in watch mode.
234266
new nsWebpack.WatchStateLoggerPlugin(),
235267
],
236268
};
237269

270+
238271
if (report) {
239272
// Generate report files for bundles content
240273
config.plugins.push(new BundleAnalyzerPlugin({
@@ -249,6 +282,7 @@ module.exports = env => {
249282
if (snapshot) {
250283
config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({
251284
chunk: "vendor",
285+
angular: true,
252286
requireModules: [
253287
"reflect-metadata",
254288
"@angular/platform-browser",
@@ -263,5 +297,9 @@ module.exports = env => {
263297
}));
264298
}
265299

300+
if (hmr) {
301+
config.plugins.push(new webpack.HotModuleReplacementPlugin());
302+
}
303+
266304
return config;
267305
};

demo/app/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "./bundle-config";
22

3-
import application = require("application");
3+
import * as application from "application";
44

55
application.start({ moduleName: "main-page" });

demo/app/main-page.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EventData, Observable } from "data/observable";
2-
import { GestureTypes } from "ui/gestures";
3-
import pages = require("ui/page");
2+
import * as pages from "ui/page";
3+
44
import { DropDown, SelectedIndexChangedEventData, ValueList } from "nativescript-drop-down";
55

66
let viewModel: Observable;

demo/app/vendor.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@ application.loadAppCss();
77

88
require("./vendor-platform");
99

10-
require("nativescript-drop-down"); // Added for snapshots
11-
1210
require("bundle-entry-points");

0 commit comments

Comments
 (0)