UNPKG

3.18 kBJavaScriptView Raw
1import chalk from "chalk";
2import { dirname, join, relative, resolve } from "path";
3export function logDebugOutput(modulePaths, type, configuration, alias, showOutput) {
4 if (showOutput) {
5 console.log(" Build configuration");
6 console.log(" - entry:");
7 for (const e of modulePaths.entry) {
8 console.log(" %s", chalk.greenBright(relative(process.cwd(), e)));
9 }
10 console.log(" - type: %s", type);
11 console.log(" - outDir: %s", chalk.gray(configuration.outputDir));
12 console.log(" - outName: %s", chalk.gray(configuration.outputName));
13 console.log(" - ctx: %s", chalk.gray(configuration.context));
14 console.log(" - cache-loader cache: %s", chalk.gray(JSON.parse(process.env.cacheLoaderDir)));
15 console.log(" - terser cache: %s", chalk.gray(JSON.parse(process.env.terserDir)));
16 console.log(" - tsconfig: %s", chalk.gray(resolve(configuration.context, join(modulePaths.cliPath, "./tsconfig.cli.json"))));
17 console.log(" - aliases:");
18 const unchanged = [];
19 for (const key of Object.keys(alias)) {
20 if (alias[key] == null) {
21 continue;
22 }
23 try {
24 const resolved = dirname(require.resolve(key + "/package.json", { paths: [configuration.entry] }));
25 const cwdRelative = relative(process.cwd(), alias[key]);
26 if (relative(process.cwd(), resolved) === cwdRelative) {
27 unchanged.push(key);
28 }
29 else {
30 console.log(" %s -> %s", chalk.greenBright(key), chalk.cyan(cwdRelative));
31 }
32 }
33 catch (err) { }
34 }
35 if (unchanged.length > 0) {
36 console.log(" - aliases resolving to default paths:");
37 console.log(" " + unchanged.join(", "));
38 }
39 if (configuration.bundleOptions.momentLocales &&
40 configuration.bundleOptions.momentLocales.length > 0) {
41 console.log(" - moment locales:");
42 for (const locale of configuration.bundleOptions.momentLocales) {
43 console.log(" %s", chalk.greenBright(locale));
44 }
45 }
46 if (configuration.bundleOptions.momentTimezones) {
47 const years = `${configuration.bundleOptions.momentTimezones.startYear || ""}-${configuration
48 .bundleOptions.momentTimezones.endYear || ""}`;
49 console.log(" - moment timezones: %s%s", years.length === 1 ? "" : years, configuration.bundleOptions.momentTimezones.matchZones ? ", matching zones" : "");
50 }
51 console.log(" - aliases:");
52 for (const key in alias) {
53 if (alias[key] != null) {
54 console.log(" %s -> %s", key, relative(process.cwd(), alias[key]));
55 }
56 }
57 }
58 if (process.env.WEBPACK_PROFILE === "true") {
59 console.log(" profiling build!");
60 }
61 if (process.env.WEBPACK_BUNDLE_ANALYZE === "true") {
62 console.log(" analyzing build!");
63 }
64}
65//# sourceMappingURL=debug.js.map
\No newline at end of file