@modern-js/upgrade-generator 3.1.29 → 3.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +44 -122
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -115349,6 +115349,8 @@ var require_chainId = __commonJS({
115349
115349
  YAML: "yaml",
115350
115350
  /** Rule for wasm */
115351
115351
  WASM: "wasm",
115352
+ /** Rule for node */
115353
+ NODE: "node",
115352
115354
  /** Rule for bff */
115353
115355
  JS_BFF_API: "js-bff-api"
115354
115356
  },
@@ -115387,6 +115389,8 @@ var require_chainId = __commonJS({
115387
115389
  TOML: "toml",
115388
115390
  /** html-loader */
115389
115391
  HTML: "html",
115392
+ /** node-loader */
115393
+ NODE: "html",
115390
115394
  /** babel-loader */
115391
115395
  BABEL: "babel",
115392
115396
  /** esbuild-loader */
@@ -115405,6 +115409,8 @@ var require_chainId = __commonJS({
115405
115409
  CSS_MODULES_TS: "css-modules-typescript",
115406
115410
  /** mini-css-extract-plugin.loader */
115407
115411
  MINI_CSS_EXTRACT: "mini-css-extract",
115412
+ /** resolve-url-loader */
115413
+ RESOLVE_URL_LOADER_FOR_SASS: "resolve-url-loader",
115408
115414
  /** builder-plugin-image-compress.loader */
115409
115415
  IMAGE_COMPRESS: "image-compress",
115410
115416
  /** builder-plugin-image-compress svgo-loader */
@@ -115452,6 +115458,10 @@ var require_chainId = __commonJS({
115452
115458
  HTML_NONCE: "html-nonce",
115453
115459
  /** HtmlCrossOriginPlugin */
115454
115460
  HTML_CROSS_ORIGIN: "html-cross-origin",
115461
+ /** htmlPreconnectPlugin */
115462
+ HTML_PRECONNECT: "html-preconnect-plugin",
115463
+ /** htmlDnsPrefetchPlugin */
115464
+ HTML_DNS_PREFETCH: "html-dns-prefetch-plugin",
115455
115465
  /** MiniCssExtractPlugin */
115456
115466
  MINI_CSS_EXTRACT: "mini-css-extract",
115457
115467
  /** VueLoaderPlugin */
@@ -115615,7 +115625,7 @@ var require_constants = __commonJS({
115615
115625
  var API_DIR = "api";
115616
115626
  var SERVER_DIR = "server";
115617
115627
  var SHARED_DIR = "shared";
115618
- var CONFIG_CACHE_DIR = "./node_modules/.cache/node-bundle-require";
115628
+ var CONFIG_CACHE_DIR = "./node_modules/.cache/bundle-require";
115619
115629
  var CONFIG_FILE_EXTENSIONS = [
115620
115630
  ".js",
115621
115631
  ".ts",
@@ -115647,7 +115657,6 @@ var require_constants = __commonJS({
115647
115657
  };
115648
115658
  var INTERNAL_MODULE_TOOLS_PLUGINS = {
115649
115659
  "@modern-js/module-tools": "@modern-js/module-tools",
115650
- "@modern-js/doc-tools": "@modern-js/doc-tools",
115651
115660
  "@modern-js/runtime": "@modern-js/runtime/cli",
115652
115661
  "@modern-js/plugin-testing": "@modern-js/plugin-testing/cli",
115653
115662
  "@modern-js/plugin-storybook": "@modern-js/plugin-storybook/cli",
@@ -115923,13 +115932,15 @@ var require_config2 = __commonJS({
115923
115932
  return isSingleEntry;
115924
115933
  }
115925
115934
  });
115935
+ var _constants = require_constants();
115926
115936
  var _type = require_type();
115927
115937
  var isSSR = (config) => {
115938
+ var _server, _server1;
115928
115939
  const { server } = config;
115929
- if (server === null || server === void 0 ? void 0 : server.ssr) {
115940
+ if ((_server = server) === null || _server === void 0 ? void 0 : _server.ssr) {
115930
115941
  return true;
115931
115942
  }
115932
- if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && !(0, _type.isEmpty)(server.ssrByEntries)) {
115943
+ if (((_server1 = server) === null || _server1 === void 0 ? void 0 : _server1.ssrByEntries) && !(0, _type.isEmpty)(server.ssrByEntries)) {
115933
115944
  for (const name of Object.keys(server.ssrByEntries)) {
115934
115945
  if (server.ssrByEntries[name]) {
115935
115946
  return true;
@@ -115939,30 +115950,32 @@ var require_config2 = __commonJS({
115939
115950
  return false;
115940
115951
  };
115941
115952
  var isUseSSRBundle = (config) => {
115953
+ var _output;
115942
115954
  const { output: output2 } = config;
115943
- if (output2 === null || output2 === void 0 ? void 0 : output2.ssg) {
115955
+ if ((_output = output2) === null || _output === void 0 ? void 0 : _output.ssg) {
115944
115956
  return true;
115945
115957
  }
115946
115958
  return isSSR(config);
115947
115959
  };
115948
115960
  var isServiceWorker = (config) => {
115949
- var _deploy_worker;
115961
+ var _deploy_worker, _deploy, _output;
115950
115962
  const { output: output2, deploy } = config;
115951
- if ((deploy === null || deploy === void 0 ? void 0 : (_deploy_worker = deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr) && ((output2 === null || output2 === void 0 ? void 0 : output2.ssg) || isSSR(config))) {
115963
+ if (((_deploy = deploy) === null || _deploy === void 0 ? void 0 : (_deploy_worker = _deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr) && (((_output = output2) === null || _output === void 0 ? void 0 : _output.ssg) || isSSR(config))) {
115952
115964
  return true;
115953
115965
  }
115954
115966
  return false;
115955
115967
  };
115956
115968
  var isRouterV5 = (config) => {
115957
- var _config_runtime, _config_runtime1, _config_runtime_router;
115958
- return typeof ((_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.router) !== "boolean" && (config === null || config === void 0 ? void 0 : (_config_runtime1 = config.runtime) === null || _config_runtime1 === void 0 ? void 0 : (_config_runtime_router = _config_runtime1.router) === null || _config_runtime_router === void 0 ? void 0 : _config_runtime_router.mode) === "react-router-5";
115969
+ var _config_runtime, _config_runtime_router, _config_runtime1, _config;
115970
+ return typeof ((_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.router) !== "boolean" && ((_config = config) === null || _config === void 0 ? void 0 : (_config_runtime1 = _config.runtime) === null || _config_runtime1 === void 0 ? void 0 : (_config_runtime_router = _config_runtime1.router) === null || _config_runtime_router === void 0 ? void 0 : _config_runtime_router.mode) === "react-router-5";
115959
115971
  };
115960
115972
  var isSSGEntry = (config, entryName, entrypoints) => {
115973
+ var _config_source, _ssgConfig, _ssgConfig1;
115961
115974
  const ssgConfig = config.output.ssg;
115962
- const useSSG = isSingleEntry(entrypoints) ? Boolean(ssgConfig) : ssgConfig === true || typeof (ssgConfig === null || ssgConfig === void 0 ? void 0 : ssgConfig[0]) === "function" || Boolean(ssgConfig === null || ssgConfig === void 0 ? void 0 : ssgConfig[entryName]);
115975
+ const useSSG = isSingleEntry(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) ? Boolean(ssgConfig) : ssgConfig === true || typeof ((_ssgConfig = ssgConfig) === null || _ssgConfig === void 0 ? void 0 : _ssgConfig[0]) === "function" || Boolean((_ssgConfig1 = ssgConfig) === null || _ssgConfig1 === void 0 ? void 0 : _ssgConfig1[entryName]);
115963
115976
  return useSSG;
115964
115977
  };
115965
- var isSingleEntry = (entrypoints) => entrypoints.length === 1 && entrypoints[0].entryName === "main";
115978
+ var isSingleEntry = (entrypoints, mainEntryName = _constants.MAIN_ENTRY_NAME) => entrypoints.length === 1 && entrypoints[0].entryName === mainEntryName;
115966
115979
  }
115967
115980
  });
115968
115981
 
@@ -116509,6 +116522,9 @@ var require_logger2 = __commonJS({
116509
116522
  });
116510
116523
  }
116511
116524
  _export(exports, {
116525
+ isErrorStackMessage: function() {
116526
+ return isErrorStackMessage;
116527
+ },
116512
116528
  Logger: function() {
116513
116529
  return Logger;
116514
116530
  },
@@ -116559,6 +116575,9 @@ var require_logger2 = __commonJS({
116559
116575
  displayLabel: true,
116560
116576
  uppercaseLabel: false
116561
116577
  };
116578
+ var errorStackRegExp = /^\s*at\s.*:\d+:\d+[\s)]*$/;
116579
+ var anonymousErrorStackRegExp = /^\s*at\s.*\(<anonymous>\)$/;
116580
+ var isErrorStackMessage = (message) => errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message);
116562
116581
  var Logger = class {
116563
116582
  _log(type, message, ...args) {
116564
116583
  if (message === void 0 || message === null) {
@@ -116584,6 +116603,9 @@ ${_chalk.default.grey(rest.join("\n"))}`;
116584
116603
  } else {
116585
116604
  text = message.message;
116586
116605
  }
116606
+ } else if (logType.level === "error" && typeof message === "string") {
116607
+ const lines = message.split("\n");
116608
+ text = lines.map((line) => isErrorStackMessage(line) ? _chalk.default.gray(line) : line).join("\n");
116587
116609
  } else {
116588
116610
  text = `${message}`;
116589
116611
  }
@@ -116706,7 +116728,7 @@ var require_alias = __commonJS({
116706
116728
  };
116707
116729
  var mergeAlias = (alias) => (0, _applyOptionsChain.applyOptionsChain)({}, alias);
116708
116730
  var getAliasConfig = (aliasOption, option) => {
116709
- var _tsconfig_compilerOptions, _tsconfig_compilerOptions1;
116731
+ var _tsconfig_compilerOptions, _tsconfig, _tsconfig_compilerOptions1, _tsconfig1;
116710
116732
  const isTsProject = _fs.default.existsSync(option.tsconfigPath);
116711
116733
  const alias = mergeAlias(aliasOption);
116712
116734
  if (!isTsProject) {
@@ -116718,10 +116740,10 @@ var require_alias = __commonJS({
116718
116740
  };
116719
116741
  }
116720
116742
  const tsconfig = (0, _get.readTsConfigByFile)(option.tsconfigPath);
116721
- const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
116743
+ const baseUrl = (_tsconfig = tsconfig) === null || _tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = _tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
116722
116744
  return {
116723
116745
  absoluteBaseUrl: baseUrl ? _path.default.join(option.appDirectory, baseUrl) : option.appDirectory,
116724
- paths: __spreadValues(__spreadValues({}, alias), tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions1 = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions1 === void 0 ? void 0 : _tsconfig_compilerOptions1.paths),
116746
+ paths: __spreadValues(__spreadValues({}, alias), (_tsconfig1 = tsconfig) === null || _tsconfig1 === void 0 ? void 0 : (_tsconfig_compilerOptions1 = _tsconfig1.compilerOptions) === null || _tsconfig_compilerOptions1 === void 0 ? void 0 : _tsconfig_compilerOptions1.paths),
116725
116747
  isTsPath: true,
116726
116748
  isTsProject
116727
116749
  };
@@ -116765,15 +116787,6 @@ var require_path = __commonJS({
116765
116787
  getTemplatePath: function() {
116766
116788
  return getTemplatePath;
116767
116789
  },
116768
- compilePathMatcherRegExp: function() {
116769
- return compilePathMatcherRegExp;
116770
- },
116771
- _joinPathParts: function() {
116772
- return _joinPathParts;
116773
- },
116774
- upwardPaths: function() {
116775
- return upwardPaths;
116776
- },
116777
116790
  getRealTemporaryDirectory: function() {
116778
116791
  return getRealTemporaryDirectory;
116779
116792
  },
@@ -116811,20 +116824,6 @@ var require_path = __commonJS({
116811
116824
  parts.push((0, _compiled.nanoid)());
116812
116825
  return _path.default.resolve(...parts);
116813
116826
  };
116814
- function compilePathMatcherRegExp(match) {
116815
- if (typeof match !== "string") {
116816
- return match;
116817
- }
116818
- const escaped = _compiled.lodash.escapeRegExp(match);
116819
- return new RegExp(`(?<=\\W|^)${escaped}(?=\\W|$)`);
116820
- }
116821
- var _joinPathParts = (_part, i, parts) => (0, _compiled.lodash)(parts).filter((part) => ![
116822
- "/",
116823
- "\\"
116824
- ].includes(part)).tap((parts2) => parts2.unshift("")).slice(0, i + 2).join("/");
116825
- function upwardPaths(start) {
116826
- return (0, _compiled.lodash)(start).split(/[/\\]/).filter(Boolean).map(_joinPathParts).reverse().push("/").value();
116827
- }
116828
116827
  function getRealTemporaryDirectory() {
116829
116828
  let ret = null;
116830
116829
  try {
@@ -117076,84 +117075,6 @@ var require_monorepo = __commonJS({
117076
117075
  }
117077
117076
  });
117078
117077
 
117079
- // ../../../toolkit/utils/dist/cjs/cli/pathSerializer.js
117080
- var require_pathSerializer = __commonJS({
117081
- "../../../toolkit/utils/dist/cjs/cli/pathSerializer.js"(exports) {
117082
- "use strict";
117083
- Object.defineProperty(exports, "__esModule", {
117084
- value: true
117085
- });
117086
- function _export(target, all) {
117087
- for (var name in all)
117088
- Object.defineProperty(target, name, {
117089
- enumerable: true,
117090
- get: all[name]
117091
- });
117092
- }
117093
- _export(exports, {
117094
- matchUpwardPathsAsUnknown: function() {
117095
- return matchUpwardPathsAsUnknown;
117096
- },
117097
- applyPathMatcher: function() {
117098
- return applyPathMatcher;
117099
- },
117100
- applyMatcherReplacement: function() {
117101
- return applyMatcherReplacement;
117102
- },
117103
- createDefaultPathMatchers: function() {
117104
- return createDefaultPathMatchers;
117105
- }
117106
- });
117107
- var _interop_require_default = require_interop_require_default();
117108
- var _os = /* @__PURE__ */ _interop_require_default._(require("os"));
117109
- var _lodash = /* @__PURE__ */ _interop_require_default._(require_lodash3());
117110
- var _path = require_path();
117111
- var matchUpwardPathsAsUnknown = (p) => (0, _lodash.default)((0, _path.upwardPaths)((0, _path.normalizeToPosixPath)(p))).map((match) => ({
117112
- match,
117113
- mark: "unknown"
117114
- })).slice(1, -1).value();
117115
- function applyPathMatcher(matcher, str, options = {}) {
117116
- const regex2 = (0, _path.compilePathMatcherRegExp)(matcher.match);
117117
- const replacer = (substring, ...args) => {
117118
- if (options.minPartials && (0, _path.splitPathString)(substring).length < options.minPartials) {
117119
- return substring;
117120
- }
117121
- const ret = typeof matcher.mark === "string" ? matcher.mark : matcher.mark(substring, ...args);
117122
- return `<${_lodash.default.snakeCase(ret).toUpperCase()}>`;
117123
- };
117124
- return str.replace(regex2, replacer);
117125
- }
117126
- function applyMatcherReplacement(matchers, str, options = {}) {
117127
- return matchers.reduce((ret, matcher) => {
117128
- return applyPathMatcher(matcher, ret, options);
117129
- }, str);
117130
- }
117131
- var createDefaultPathMatchers = (root) => {
117132
- const ret = [
117133
- {
117134
- match: RegExp("(?<=\\/)(\\.pnpm\\/.+?\\/node_modules)(?=\\/)"),
117135
- mark: "pnpmInner"
117136
- }
117137
- ];
117138
- const tmpdir = (0, _path.getRealTemporaryDirectory)();
117139
- tmpdir && ret.push({
117140
- match: tmpdir,
117141
- mark: "temp"
117142
- });
117143
- ret.push({
117144
- match: _os.default.tmpdir(),
117145
- mark: "temp"
117146
- });
117147
- ret.push({
117148
- match: _os.default.homedir(),
117149
- mark: "home"
117150
- });
117151
- ret.push(...matchUpwardPathsAsUnknown(root));
117152
- return ret;
117153
- };
117154
- }
117155
- });
117156
-
117157
117078
  // ../../../toolkit/utils/dist/cjs/cli/port.js
117158
117079
  var require_port = __commonJS({
117159
117080
  "../../../toolkit/utils/dist/cjs/cli/port.js"(exports) {
@@ -117260,7 +117181,8 @@ var require_prettyInstructions = __commonJS({
117260
117181
  const LOCAL_LABEL = "Local: ";
117261
117182
  const NETWORK_LABEL = "Network: ";
117262
117183
  const isLocalhost = (url) => {
117263
- return url === null || url === void 0 ? void 0 : url.includes("localhost");
117184
+ var _url;
117185
+ return (_url = url) === null || _url === void 0 ? void 0 : _url.includes("localhost");
117264
117186
  };
117265
117187
  if (host && host !== _constants.DEFAULT_DEV_HOST) {
117266
117188
  return [
@@ -117287,19 +117209,19 @@ var require_prettyInstructions = __commonJS({
117287
117209
  }, []);
117288
117210
  };
117289
117211
  var prettyInstructions = (appContext, config) => {
117290
- var _appContext_builder_context_devServer, _appContext_builder, _config_dev;
117212
+ var _appContext_builder_context_devServer, _appContext_builder, _config_dev, _config_source;
117291
117213
  const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
117292
- const isHttps = (0, _is.isDev)() && ((_appContext_builder_context_devServer = (_appContext_builder = appContext.builder) === null || _appContext_builder === void 0 ? void 0 : _appContext_builder.context.devServer) === null || _appContext_builder_context_devServer === void 0 ? void 0 : _appContext_builder_context_devServer.https);
117214
+ const isHttps = (0, _is.isDev)() && ((_appContext_builder = appContext.builder) === null || _appContext_builder === void 0 ? void 0 : (_appContext_builder_context_devServer = _appContext_builder.context.devServer) === null || _appContext_builder_context_devServer === void 0 ? void 0 : _appContext_builder_context_devServer.https);
117293
117215
  const urls = getAddressUrls(isHttps ? "https" : "http", port, (_config_dev = config.dev) === null || _config_dev === void 0 ? void 0 : _config_dev.host);
117294
117216
  const routes = !apiOnly ? serverRoutes.filter((route) => route.entryName) : serverRoutes;
117295
117217
  let message = "App running at:\n\n";
117296
- if ((0, _is.isSingleEntry)(entrypoints) || apiOnly) {
117218
+ if ((0, _is.isSingleEntry)(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) || apiOnly) {
117297
117219
  message += urls.map(({ label, url }) => ` ${_compiled.chalk.bold(`> ${label.padEnd(10)}`)}${_compiled.chalk.cyanBright(normalizeUrl(`${url}/${routes[0].urlPath}`))}
117298
117220
  `).join("");
117299
117221
  } else {
117300
117222
  const maxNameLength = Math.max(...routes.map((r) => r.entryName.length));
117301
117223
  urls.forEach(({ label, url }) => {
117302
- message += ` ${_compiled.chalk.bold(`> ${label}`)}
117224
+ message += ` ${_compiled.chalk.bold(`> ${label}`)}${routes.length === 0 ? _compiled.chalk.cyanBright(url) : ""}
117303
117225
  `;
117304
117226
  routes.forEach(({ entryName, urlPath, isSSR }) => {
117305
117227
  if (!checkedEntries.includes(entryName)) {
@@ -117354,8 +117276,9 @@ var require_require = __commonJS({
117354
117276
  });
117355
117277
  var _fs = require_fs();
117356
117278
  var compatRequire = (filePath, interop = true) => {
117279
+ var _mod;
117357
117280
  const mod = require(filePath);
117358
- const rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
117281
+ const rtnESMDefault = interop && ((_mod = mod) === null || _mod === void 0 ? void 0 : _mod.__esModule);
117359
117282
  return rtnESMDefault ? mod.default : mod;
117360
117283
  };
117361
117284
  var dynamicImport = new Function("modulePath", "return import(modulePath)");
@@ -117547,7 +117470,6 @@ var require_cli = __commonJS({
117547
117470
  _export_star._(require_monorepo(), exports);
117548
117471
  _export_star._(require_package4(), exports);
117549
117472
  _export_star._(require_path(), exports);
117550
- _export_star._(require_pathSerializer(), exports);
117551
117473
  _export_star._(require_port(), exports);
117552
117474
  _export_star._(require_prettyInstructions(), exports);
117553
117475
  _export_star._(require_require(), exports);
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "3.1.29",
18
+ "version": "3.1.31",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "main": "./dist/index.js",
21
21
  "files": [
@@ -30,11 +30,11 @@
30
30
  "@types/node": "^14",
31
31
  "jest": "^29",
32
32
  "typescript": "^5",
33
- "@scripts/build": "2.27.0",
34
- "@scripts/jest-config": "2.27.0",
35
- "@modern-js/plugin-i18n": "2.27.0",
36
- "@modern-js/generator-utils": "3.1.29",
37
- "@modern-js/generator-common": "3.1.29"
33
+ "@modern-js/generator-utils": "3.1.31",
34
+ "@scripts/jest-config": "2.29.0",
35
+ "@modern-js/generator-common": "3.1.31",
36
+ "@scripts/build": "2.29.0",
37
+ "@modern-js/plugin-i18n": "2.29.0"
38
38
  },
39
39
  "sideEffects": false,
40
40
  "publishConfig": {