Commit ad797a31 authored by laurent l's avatar laurent l

update nativescript 5.4.0

parent 8b6d2249
......@@ -16,7 +16,7 @@ export class AccountsController extends Controller {
protected _portals: Array<MBPortal>
protected _accounts: ObservableArray<Account>
protected _manager: Manager
protected _view
protected _view: any
public constructor(manager: Manager) {
super()
......
This diff is collapsed.
......@@ -9,10 +9,10 @@
"ios": "fr.afi.MyBibApp"
},
"tns-android": {
"version": "5.3.1"
"version": "5.4.0"
},
"tns-ios": {
"version": "5.3.1"
"version": "5.4.0"
}
},
"dependencies": {
......@@ -56,7 +56,7 @@
"nativescript-css-loader": "~0.26.0",
"nativescript-dev-sass": "^1.6.0",
"nativescript-dev-typescript": "^0.9.0",
"nativescript-dev-webpack": "^0.20.3",
"nativescript-dev-webpack": "0.24.0",
"nativescript-worker-loader": "~0.8.1",
"raw-loader": "~0.5.1",
"resolve-url-loader": "~2.1.0",
......
......@@ -5,10 +5,11 @@ const nsWebpack = require("nativescript-dev-webpack");
const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const hashSalt = Date.now().toString();
const TerserPlugin = require("terser-webpack-plugin");
const hashSalt = Date.now().toString();
module.exports = env => {
// Add your custom Activities, Services and other Android app components here.
......@@ -41,15 +42,27 @@ module.exports = env => {
uglify, // --env.uglify
report, // --env.report
sourceMap, // --env.sourceMap
hiddenSourceMap, // --env.hiddenSourceMap
hmr, // --env.hmr,
unitTesting, // --env.unitTesting
} = env;
const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
const externals = nsWebpack.getConvertedExternals(env.externals);
const appFullPath = resolve(projectRoot, appPath);
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
const entryModule = nsWebpack.getEntryModule(appFullPath);
const entryModule = nsWebpack.getEntryModule(appFullPath, platform);
const entryPath = `.${sep}${entryModule}.ts`;
const entries = { bundle: entryPath };
const tsConfigPath = resolve(projectRoot, "tsconfig.tns.json");
if (platform === "ios") {
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js";
};
let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);
const config = {
mode: uglify ? "production" : "development",
......@@ -63,12 +76,11 @@ module.exports = env => {
]
},
target: nativescriptTarget,
entry: {
bundle: entryPath,
},
entry: entries,
output: {
pathinfo: false,
path: dist,
sourceMapFilename,
libraryTarget: "commonjs2",
filename: "[name].js",
globalObject: "global",
......@@ -101,8 +113,9 @@ module.exports = env => {
"fs": "empty",
"__dirname": false,
},
devtool: sourceMap ? "inline-source-map" : "none",
optimization: {
devtool: hiddenSourceMap ? "hidden-source-map" : (sourceMap ? "inline-source-map" : "none"),
optimization: {
runtimeChunk: "single",
splitChunks: {
cacheGroups: {
vendor: {
......@@ -111,7 +124,7 @@ module.exports = env => {
test: (module, chunks) => {
const moduleName = module.nameForCondition ? module.nameForCondition() : '';
return /[\\/]node_modules[\\/]/.test(moduleName) ||
appComponents.some(comp => comp === moduleName);
appComponents.some(comp => comp === moduleName);
},
enforce: true,
......@@ -120,12 +133,14 @@ module.exports = env => {
},
minimize: !!uglify,
minimizer: [
new UglifyJsPlugin({
new TerserPlugin({
parallel: true,
cache: true,
uglifyOptions: {
sourceMap: isAnySourceMapEnabled,
terserOptions: {
output: {
comments: false,
semicolons: !isAnySourceMapEnabled
},
compress: {
// The Android SBG has problems parsing the output
......@@ -140,7 +155,7 @@ module.exports = env => {
module: {
rules: [
{
test: new RegExp(entryPath),
test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath),
use: [
// Require all Android app components
platform === "android" && {
......@@ -152,6 +167,9 @@ module.exports = env => {
loader: "nativescript-dev-webpack/bundle-config-loader",
options: {
loadCss: !snapshot, // load the application css if in debug mode
unitTesting,
appFullPath,
projectRoot,
}
},
].filter(loader => !!loader)
......@@ -172,17 +190,17 @@ module.exports = env => {
use: "nativescript-dev-webpack/markup-hot-loader"
},
{ test: /\.(html|xml)$/, use: "nativescript-dev-webpack/xml-namespace-loader"},
{ test: /\.(html|xml)$/, use: "nativescript-dev-webpack/xml-namespace-loader" },
{
test: /\.css$/,
use: { loader: "css-loader", options: { minimize: false, url: false } }
use: { loader: "css-loader", options: { url: false } }
},
{
test: /\.scss$/,
use: [
{ loader: "css-loader", options: { minimize: false, url: false } },
{ loader: "css-loader", options: { url: false } },
"sass-loader"
]
},
......@@ -192,8 +210,12 @@ module.exports = env => {
use: {
loader: "ts-loader",
options: {
configFile: "tsconfig.tns.json",
configFile: tsConfigPath,
transpileOnly: !!hmr,
allowTsInNodeModules: true,
compilerOptions: {
sourceMap: isAnySourceMapEnabled
}
},
}
},
......@@ -206,15 +228,7 @@ module.exports = env => {
"process": undefined,
}),
// Remove all files from the out dir.
new CleanWebpackPlugin([ `${dist}/**/*` ]),
// Copy native app resources to out dir.
new CopyWebpackPlugin([
{
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
context: projectRoot
},
]),
new CleanWebpackPlugin([`${dist}/**/*`]),
// Copy assets to out dir. Add your own globs as needed.
new CopyWebpackPlugin([
{ from: { glob: "fonts/**" } },
......@@ -222,10 +236,16 @@ module.exports = env => {
{ from: { glob: "**/*.png" } },
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
// Generate a bundle starter script and activate it in package.json
new nsWebpack.GenerateBundleStarterPlugin([
"./vendor",
"./bundle",
]),
new nsWebpack.GenerateBundleStarterPlugin(
// Don't include `runtime.js` when creating a snapshot. The plugin
// configures the WebPack runtime to be generated inside the snapshot
// module and no `runtime.js` module exist.
(snapshot ? [] : ["./runtime"])
.concat([
"./vendor",
"./bundle",
])
),
// For instructions on how to set up workers with webpack
// check out https://github.com/nativescript/worker-loader
new NativeScriptWorkerPlugin(),
......@@ -238,6 +258,18 @@ module.exports = env => {
],
};
// Copy the native app resources to the out dir
// only if doing a full build (tns run/build) and not previewing (tns preview)
if (!externals || externals.length === 0) {
config.plugins.push(new CopyWebpackPlugin([
{
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
context: projectRoot
},
]));
}
if (report) {
// Generate report files for bundles content
config.plugins.push(new BundleAnalyzerPlugin({
......@@ -262,6 +294,12 @@ module.exports = env => {
if (hmr) {
config.plugins.push(new webpack.HotModuleReplacementPlugin());
// With HMR ts-loader should run in `transpileOnly` mode,
// so assure type-checking with fork-ts-checker-webpack-plugin
config.plugins.push(new ForkTsCheckerWebpackPlugin({
tsconfig: tsConfigPath
}));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment