mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 02:54:11 +08:00
Merge remote-tracking branch 'origin/master' into release/8.2.0
This commit is contained in:
@ -109,4 +109,14 @@ describe('base configuration', () => {
|
|||||||
force: true,
|
force: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('supports --env.profile', () => {
|
||||||
|
init({
|
||||||
|
platform: 'ios',
|
||||||
|
profile: true,
|
||||||
|
});
|
||||||
|
const config = base(new Config());
|
||||||
|
|
||||||
|
expect(config.get('profile')).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nativescript/webpack",
|
"name": "@nativescript/webpack",
|
||||||
"version": "5.0.4",
|
"version": "5.0.5-rc.0",
|
||||||
"private": false,
|
"private": false,
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
import { redBright, green, greenBright } from 'chalk';
|
import { redBright, green, greenBright, yellow } from 'chalk';
|
||||||
import { program } from 'commander';
|
import { program } from 'commander';
|
||||||
import dedent from 'ts-dedent';
|
import dedent from 'ts-dedent';
|
||||||
import webpack from 'webpack';
|
import webpack from 'webpack';
|
||||||
@ -115,6 +115,28 @@ program
|
|||||||
errorDetails: env.verbose,
|
errorDetails: env.verbose,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// if webpack profile is enabled we write the stats to a JSON file
|
||||||
|
if (configuration.profile || env.profile) {
|
||||||
|
console.log(
|
||||||
|
[
|
||||||
|
'',
|
||||||
|
'|',
|
||||||
|
`| The build profile has been written to ${yellow(
|
||||||
|
'webpack.stats.json'
|
||||||
|
)}`,
|
||||||
|
`| You can analyse the stats at ${green(
|
||||||
|
'https://webpack.github.io/analyse/'
|
||||||
|
)}`,
|
||||||
|
'|',
|
||||||
|
'',
|
||||||
|
].join('\n')
|
||||||
|
);
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(process.cwd(), 'webpack.stats.json'),
|
||||||
|
JSON.stringify(stats.toJson())
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -222,6 +222,11 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// enable profiling with --env.profile
|
||||||
|
config.when(env.profile, (config) => {
|
||||||
|
config.profile(true);
|
||||||
|
});
|
||||||
|
|
||||||
// worker-loader should be declared before ts-loader
|
// worker-loader should be declared before ts-loader
|
||||||
config.module
|
config.module
|
||||||
.rule('workers')
|
.rule('workers')
|
||||||
|
@ -43,6 +43,9 @@ export interface IWebpackEnv {
|
|||||||
// enable verbose output
|
// enable verbose output
|
||||||
verbose?: boolean;
|
verbose?: boolean;
|
||||||
|
|
||||||
|
// enable webpack profiling
|
||||||
|
profile?: boolean;
|
||||||
|
|
||||||
// misc
|
// misc
|
||||||
replace?: string[] | string;
|
replace?: string[] | string;
|
||||||
watchNodeModules?: boolean;
|
watchNodeModules?: boolean;
|
||||||
|
@ -75,16 +75,22 @@ async function parseXML(content: string): Promise<ParseResult> {
|
|||||||
const resolvePaths = [
|
const resolvePaths = [
|
||||||
localNamespacePath,
|
localNamespacePath,
|
||||||
localModulePath,
|
localModulePath,
|
||||||
`${localModulePath}.xml`,
|
|
||||||
moduleName,
|
moduleName,
|
||||||
namespace,
|
namespace,
|
||||||
`${moduleName}.xml`,
|
|
||||||
`~/${moduleName}`,
|
`~/${moduleName}`,
|
||||||
`~/${namespace}`,
|
`~/${namespace}`,
|
||||||
|
];
|
||||||
|
|
||||||
|
// fallbacks for codeless namespaces
|
||||||
|
const fallbackResolvePaths = [
|
||||||
|
`${localModulePath}.xml`,
|
||||||
|
`${moduleName}.xml`,
|
||||||
`~/${moduleName}.xml`,
|
`~/${moduleName}.xml`,
|
||||||
];
|
];
|
||||||
DEBUG && console.log({ resolvePaths });
|
|
||||||
|
DEBUG && console.log({ resolvePaths, fallbackResolvePaths });
|
||||||
let resolvedPath;
|
let resolvedPath;
|
||||||
|
let isFallbackPath = false;
|
||||||
|
|
||||||
for (const p of resolvePaths) {
|
for (const p of resolvePaths) {
|
||||||
resolvedPath = await resolveAsync(this.context, p).catch(noop);
|
resolvedPath = await resolveAsync(this.context, p).catch(noop);
|
||||||
@ -95,7 +101,23 @@ async function parseXML(content: string): Promise<ParseResult> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG && console.log({ resolvedPath });
|
if (!resolvedPath) {
|
||||||
|
for (const p of fallbackResolvePaths) {
|
||||||
|
resolvedPath = await resolveAsync(this.context, p).catch(noop);
|
||||||
|
|
||||||
|
// break on first match
|
||||||
|
if (resolvedPath) {
|
||||||
|
isFallbackPath = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG &&
|
||||||
|
console.log({
|
||||||
|
resolvedPath,
|
||||||
|
isFallbackPath,
|
||||||
|
});
|
||||||
|
|
||||||
// bail if we haven't resolved a path
|
// bail if we haven't resolved a path
|
||||||
if (!resolvedPath) {
|
if (!resolvedPath) {
|
||||||
@ -104,10 +126,15 @@ async function parseXML(content: string): Promise<ParseResult> {
|
|||||||
|
|
||||||
const { dir, name } = parse(resolvedPath);
|
const { dir, name } = parse(resolvedPath);
|
||||||
|
|
||||||
// register resolved path + short name
|
DEBUG && console.log({ namespace, moduleName });
|
||||||
namespaces.push({ name: namespace, path: resolvedPath });
|
|
||||||
namespaces.push({ name: moduleName, path: resolvedPath });
|
// check if we are not in a fallback path, in which case we shouldn't register it as a namespace
|
||||||
this.addDependency(resolvedPath);
|
if (!isFallbackPath) {
|
||||||
|
// register resolved path + short name
|
||||||
|
namespaces.push({ name: namespace, path: resolvedPath });
|
||||||
|
namespaces.push({ name: moduleName, path: resolvedPath });
|
||||||
|
this.addDependency(resolvedPath);
|
||||||
|
}
|
||||||
|
|
||||||
const noExtFilename = join(dir, name);
|
const noExtFilename = join(dir, name);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user