@modern-js/packages-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 +5 -5
package/dist/index.js CHANGED
@@ -115794,6 +115794,8 @@ var require_chainId = __commonJS({
115794
115794
  YAML: "yaml",
115795
115795
  /** Rule for wasm */
115796
115796
  WASM: "wasm",
115797
+ /** Rule for node */
115798
+ NODE: "node",
115797
115799
  /** Rule for bff */
115798
115800
  JS_BFF_API: "js-bff-api"
115799
115801
  },
@@ -115832,6 +115834,8 @@ var require_chainId = __commonJS({
115832
115834
  TOML: "toml",
115833
115835
  /** html-loader */
115834
115836
  HTML: "html",
115837
+ /** node-loader */
115838
+ NODE: "html",
115835
115839
  /** babel-loader */
115836
115840
  BABEL: "babel",
115837
115841
  /** esbuild-loader */
@@ -115850,6 +115854,8 @@ var require_chainId = __commonJS({
115850
115854
  CSS_MODULES_TS: "css-modules-typescript",
115851
115855
  /** mini-css-extract-plugin.loader */
115852
115856
  MINI_CSS_EXTRACT: "mini-css-extract",
115857
+ /** resolve-url-loader */
115858
+ RESOLVE_URL_LOADER_FOR_SASS: "resolve-url-loader",
115853
115859
  /** builder-plugin-image-compress.loader */
115854
115860
  IMAGE_COMPRESS: "image-compress",
115855
115861
  /** builder-plugin-image-compress svgo-loader */
@@ -115897,6 +115903,10 @@ var require_chainId = __commonJS({
115897
115903
  HTML_NONCE: "html-nonce",
115898
115904
  /** HtmlCrossOriginPlugin */
115899
115905
  HTML_CROSS_ORIGIN: "html-cross-origin",
115906
+ /** htmlPreconnectPlugin */
115907
+ HTML_PRECONNECT: "html-preconnect-plugin",
115908
+ /** htmlDnsPrefetchPlugin */
115909
+ HTML_DNS_PREFETCH: "html-dns-prefetch-plugin",
115900
115910
  /** MiniCssExtractPlugin */
115901
115911
  MINI_CSS_EXTRACT: "mini-css-extract",
115902
115912
  /** VueLoaderPlugin */
@@ -116060,7 +116070,7 @@ var require_constants = __commonJS({
116060
116070
  var API_DIR = "api";
116061
116071
  var SERVER_DIR = "server";
116062
116072
  var SHARED_DIR = "shared";
116063
- var CONFIG_CACHE_DIR = "./node_modules/.cache/node-bundle-require";
116073
+ var CONFIG_CACHE_DIR = "./node_modules/.cache/bundle-require";
116064
116074
  var CONFIG_FILE_EXTENSIONS = [
116065
116075
  ".js",
116066
116076
  ".ts",
@@ -116092,7 +116102,6 @@ var require_constants = __commonJS({
116092
116102
  };
116093
116103
  var INTERNAL_MODULE_TOOLS_PLUGINS = {
116094
116104
  "@modern-js/module-tools": "@modern-js/module-tools",
116095
- "@modern-js/doc-tools": "@modern-js/doc-tools",
116096
116105
  "@modern-js/runtime": "@modern-js/runtime/cli",
116097
116106
  "@modern-js/plugin-testing": "@modern-js/plugin-testing/cli",
116098
116107
  "@modern-js/plugin-storybook": "@modern-js/plugin-storybook/cli",
@@ -116368,13 +116377,15 @@ var require_config2 = __commonJS({
116368
116377
  return isSingleEntry;
116369
116378
  }
116370
116379
  });
116380
+ var _constants = require_constants();
116371
116381
  var _type = require_type();
116372
116382
  var isSSR = (config) => {
116383
+ var _server, _server1;
116373
116384
  const { server } = config;
116374
- if (server === null || server === void 0 ? void 0 : server.ssr) {
116385
+ if ((_server = server) === null || _server === void 0 ? void 0 : _server.ssr) {
116375
116386
  return true;
116376
116387
  }
116377
- if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && !(0, _type.isEmpty)(server.ssrByEntries)) {
116388
+ if (((_server1 = server) === null || _server1 === void 0 ? void 0 : _server1.ssrByEntries) && !(0, _type.isEmpty)(server.ssrByEntries)) {
116378
116389
  for (const name of Object.keys(server.ssrByEntries)) {
116379
116390
  if (server.ssrByEntries[name]) {
116380
116391
  return true;
@@ -116384,30 +116395,32 @@ var require_config2 = __commonJS({
116384
116395
  return false;
116385
116396
  };
116386
116397
  var isUseSSRBundle = (config) => {
116398
+ var _output;
116387
116399
  const { output: output2 } = config;
116388
- if (output2 === null || output2 === void 0 ? void 0 : output2.ssg) {
116400
+ if ((_output = output2) === null || _output === void 0 ? void 0 : _output.ssg) {
116389
116401
  return true;
116390
116402
  }
116391
116403
  return isSSR(config);
116392
116404
  };
116393
116405
  var isServiceWorker = (config) => {
116394
- var _deploy_worker;
116406
+ var _deploy_worker, _deploy, _output;
116395
116407
  const { output: output2, deploy } = config;
116396
- 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))) {
116408
+ 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))) {
116397
116409
  return true;
116398
116410
  }
116399
116411
  return false;
116400
116412
  };
116401
116413
  var isRouterV5 = (config) => {
116402
- var _config_runtime, _config_runtime1, _config_runtime_router;
116403
- 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";
116414
+ var _config_runtime, _config_runtime_router, _config_runtime1, _config;
116415
+ 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";
116404
116416
  };
116405
116417
  var isSSGEntry = (config, entryName, entrypoints) => {
116418
+ var _config_source, _ssgConfig, _ssgConfig1;
116406
116419
  const ssgConfig = config.output.ssg;
116407
- 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]);
116420
+ 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]);
116408
116421
  return useSSG;
116409
116422
  };
116410
- var isSingleEntry = (entrypoints) => entrypoints.length === 1 && entrypoints[0].entryName === "main";
116423
+ var isSingleEntry = (entrypoints, mainEntryName = _constants.MAIN_ENTRY_NAME) => entrypoints.length === 1 && entrypoints[0].entryName === mainEntryName;
116411
116424
  }
116412
116425
  });
116413
116426
 
@@ -116954,6 +116967,9 @@ var require_logger2 = __commonJS({
116954
116967
  });
116955
116968
  }
116956
116969
  _export(exports, {
116970
+ isErrorStackMessage: function() {
116971
+ return isErrorStackMessage;
116972
+ },
116957
116973
  Logger: function() {
116958
116974
  return Logger;
116959
116975
  },
@@ -117004,6 +117020,9 @@ var require_logger2 = __commonJS({
117004
117020
  displayLabel: true,
117005
117021
  uppercaseLabel: false
117006
117022
  };
117023
+ var errorStackRegExp = /^\s*at\s.*:\d+:\d+[\s)]*$/;
117024
+ var anonymousErrorStackRegExp = /^\s*at\s.*\(<anonymous>\)$/;
117025
+ var isErrorStackMessage = (message) => errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message);
117007
117026
  var Logger = class {
117008
117027
  _log(type, message, ...args) {
117009
117028
  if (message === void 0 || message === null) {
@@ -117029,6 +117048,9 @@ ${_chalk.default.grey(rest.join("\n"))}`;
117029
117048
  } else {
117030
117049
  text = message.message;
117031
117050
  }
117051
+ } else if (logType.level === "error" && typeof message === "string") {
117052
+ const lines = message.split("\n");
117053
+ text = lines.map((line) => isErrorStackMessage(line) ? _chalk.default.gray(line) : line).join("\n");
117032
117054
  } else {
117033
117055
  text = `${message}`;
117034
117056
  }
@@ -117151,7 +117173,7 @@ var require_alias = __commonJS({
117151
117173
  };
117152
117174
  var mergeAlias = (alias) => (0, _applyOptionsChain.applyOptionsChain)({}, alias);
117153
117175
  var getAliasConfig = (aliasOption, option) => {
117154
- var _tsconfig_compilerOptions, _tsconfig_compilerOptions1;
117176
+ var _tsconfig_compilerOptions, _tsconfig, _tsconfig_compilerOptions1, _tsconfig1;
117155
117177
  const isTsProject = _fs.default.existsSync(option.tsconfigPath);
117156
117178
  const alias = mergeAlias(aliasOption);
117157
117179
  if (!isTsProject) {
@@ -117163,10 +117185,10 @@ var require_alias = __commonJS({
117163
117185
  };
117164
117186
  }
117165
117187
  const tsconfig = (0, _get.readTsConfigByFile)(option.tsconfigPath);
117166
- const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
117188
+ const baseUrl = (_tsconfig = tsconfig) === null || _tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = _tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
117167
117189
  return {
117168
117190
  absoluteBaseUrl: baseUrl ? _path.default.join(option.appDirectory, baseUrl) : option.appDirectory,
117169
- 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),
117191
+ 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),
117170
117192
  isTsPath: true,
117171
117193
  isTsProject
117172
117194
  };
@@ -117210,15 +117232,6 @@ var require_path = __commonJS({
117210
117232
  getTemplatePath: function() {
117211
117233
  return getTemplatePath;
117212
117234
  },
117213
- compilePathMatcherRegExp: function() {
117214
- return compilePathMatcherRegExp;
117215
- },
117216
- _joinPathParts: function() {
117217
- return _joinPathParts;
117218
- },
117219
- upwardPaths: function() {
117220
- return upwardPaths;
117221
- },
117222
117235
  getRealTemporaryDirectory: function() {
117223
117236
  return getRealTemporaryDirectory;
117224
117237
  },
@@ -117256,20 +117269,6 @@ var require_path = __commonJS({
117256
117269
  parts.push((0, _compiled.nanoid)());
117257
117270
  return _path.default.resolve(...parts);
117258
117271
  };
117259
- function compilePathMatcherRegExp(match) {
117260
- if (typeof match !== "string") {
117261
- return match;
117262
- }
117263
- const escaped = _compiled.lodash.escapeRegExp(match);
117264
- return new RegExp(`(?<=\\W|^)${escaped}(?=\\W|$)`);
117265
- }
117266
- var _joinPathParts = (_part, i, parts) => (0, _compiled.lodash)(parts).filter((part) => ![
117267
- "/",
117268
- "\\"
117269
- ].includes(part)).tap((parts2) => parts2.unshift("")).slice(0, i + 2).join("/");
117270
- function upwardPaths(start) {
117271
- return (0, _compiled.lodash)(start).split(/[/\\]/).filter(Boolean).map(_joinPathParts).reverse().push("/").value();
117272
- }
117273
117272
  function getRealTemporaryDirectory() {
117274
117273
  let ret = null;
117275
117274
  try {
@@ -117521,84 +117520,6 @@ var require_monorepo = __commonJS({
117521
117520
  }
117522
117521
  });
117523
117522
 
117524
- // ../../../toolkit/utils/dist/cjs/cli/pathSerializer.js
117525
- var require_pathSerializer = __commonJS({
117526
- "../../../toolkit/utils/dist/cjs/cli/pathSerializer.js"(exports) {
117527
- "use strict";
117528
- Object.defineProperty(exports, "__esModule", {
117529
- value: true
117530
- });
117531
- function _export(target, all) {
117532
- for (var name in all)
117533
- Object.defineProperty(target, name, {
117534
- enumerable: true,
117535
- get: all[name]
117536
- });
117537
- }
117538
- _export(exports, {
117539
- matchUpwardPathsAsUnknown: function() {
117540
- return matchUpwardPathsAsUnknown;
117541
- },
117542
- applyPathMatcher: function() {
117543
- return applyPathMatcher;
117544
- },
117545
- applyMatcherReplacement: function() {
117546
- return applyMatcherReplacement;
117547
- },
117548
- createDefaultPathMatchers: function() {
117549
- return createDefaultPathMatchers;
117550
- }
117551
- });
117552
- var _interop_require_default = require_interop_require_default();
117553
- var _os = /* @__PURE__ */ _interop_require_default._(require("os"));
117554
- var _lodash = /* @__PURE__ */ _interop_require_default._(require_lodash3());
117555
- var _path = require_path();
117556
- var matchUpwardPathsAsUnknown = (p) => (0, _lodash.default)((0, _path.upwardPaths)((0, _path.normalizeToPosixPath)(p))).map((match) => ({
117557
- match,
117558
- mark: "unknown"
117559
- })).slice(1, -1).value();
117560
- function applyPathMatcher(matcher, str, options = {}) {
117561
- const regex2 = (0, _path.compilePathMatcherRegExp)(matcher.match);
117562
- const replacer = (substring, ...args) => {
117563
- if (options.minPartials && (0, _path.splitPathString)(substring).length < options.minPartials) {
117564
- return substring;
117565
- }
117566
- const ret = typeof matcher.mark === "string" ? matcher.mark : matcher.mark(substring, ...args);
117567
- return `<${_lodash.default.snakeCase(ret).toUpperCase()}>`;
117568
- };
117569
- return str.replace(regex2, replacer);
117570
- }
117571
- function applyMatcherReplacement(matchers, str, options = {}) {
117572
- return matchers.reduce((ret, matcher) => {
117573
- return applyPathMatcher(matcher, ret, options);
117574
- }, str);
117575
- }
117576
- var createDefaultPathMatchers = (root) => {
117577
- const ret = [
117578
- {
117579
- match: RegExp("(?<=\\/)(\\.pnpm\\/.+?\\/node_modules)(?=\\/)"),
117580
- mark: "pnpmInner"
117581
- }
117582
- ];
117583
- const tmpdir = (0, _path.getRealTemporaryDirectory)();
117584
- tmpdir && ret.push({
117585
- match: tmpdir,
117586
- mark: "temp"
117587
- });
117588
- ret.push({
117589
- match: _os.default.tmpdir(),
117590
- mark: "temp"
117591
- });
117592
- ret.push({
117593
- match: _os.default.homedir(),
117594
- mark: "home"
117595
- });
117596
- ret.push(...matchUpwardPathsAsUnknown(root));
117597
- return ret;
117598
- };
117599
- }
117600
- });
117601
-
117602
117523
  // ../../../toolkit/utils/dist/cjs/cli/port.js
117603
117524
  var require_port = __commonJS({
117604
117525
  "../../../toolkit/utils/dist/cjs/cli/port.js"(exports) {
@@ -117705,7 +117626,8 @@ var require_prettyInstructions = __commonJS({
117705
117626
  const LOCAL_LABEL = "Local: ";
117706
117627
  const NETWORK_LABEL = "Network: ";
117707
117628
  const isLocalhost = (url) => {
117708
- return url === null || url === void 0 ? void 0 : url.includes("localhost");
117629
+ var _url;
117630
+ return (_url = url) === null || _url === void 0 ? void 0 : _url.includes("localhost");
117709
117631
  };
117710
117632
  if (host && host !== _constants.DEFAULT_DEV_HOST) {
117711
117633
  return [
@@ -117732,19 +117654,19 @@ var require_prettyInstructions = __commonJS({
117732
117654
  }, []);
117733
117655
  };
117734
117656
  var prettyInstructions = (appContext, config) => {
117735
- var _appContext_builder_context_devServer, _appContext_builder, _config_dev;
117657
+ var _appContext_builder_context_devServer, _appContext_builder, _config_dev, _config_source;
117736
117658
  const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
117737
- 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);
117659
+ 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);
117738
117660
  const urls = getAddressUrls(isHttps ? "https" : "http", port, (_config_dev = config.dev) === null || _config_dev === void 0 ? void 0 : _config_dev.host);
117739
117661
  const routes = !apiOnly ? serverRoutes.filter((route) => route.entryName) : serverRoutes;
117740
117662
  let message = "App running at:\n\n";
117741
- if ((0, _is.isSingleEntry)(entrypoints) || apiOnly) {
117663
+ if ((0, _is.isSingleEntry)(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) || apiOnly) {
117742
117664
  message += urls.map(({ label, url }) => ` ${_compiled.chalk.bold(`> ${label.padEnd(10)}`)}${_compiled.chalk.cyanBright(normalizeUrl(`${url}/${routes[0].urlPath}`))}
117743
117665
  `).join("");
117744
117666
  } else {
117745
117667
  const maxNameLength = Math.max(...routes.map((r) => r.entryName.length));
117746
117668
  urls.forEach(({ label, url }) => {
117747
- message += ` ${_compiled.chalk.bold(`> ${label}`)}
117669
+ message += ` ${_compiled.chalk.bold(`> ${label}`)}${routes.length === 0 ? _compiled.chalk.cyanBright(url) : ""}
117748
117670
  `;
117749
117671
  routes.forEach(({ entryName, urlPath, isSSR }) => {
117750
117672
  if (!checkedEntries.includes(entryName)) {
@@ -117799,8 +117721,9 @@ var require_require = __commonJS({
117799
117721
  });
117800
117722
  var _fs = require_fs();
117801
117723
  var compatRequire = (filePath, interop = true) => {
117724
+ var _mod;
117802
117725
  const mod = require(filePath);
117803
- const rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
117726
+ const rtnESMDefault = interop && ((_mod = mod) === null || _mod === void 0 ? void 0 : _mod.__esModule);
117804
117727
  return rtnESMDefault ? mod.default : mod;
117805
117728
  };
117806
117729
  var dynamicImport = new Function("modulePath", "return import(modulePath)");
@@ -117992,7 +117915,6 @@ var require_cli = __commonJS({
117992
117915
  _export_star._(require_monorepo(), exports);
117993
117916
  _export_star._(require_package4(), exports);
117994
117917
  _export_star._(require_path(), exports);
117995
- _export_star._(require_pathSerializer(), exports);
117996
117918
  _export_star._(require_port(), exports);
117997
117919
  _export_star._(require_prettyInstructions(), exports);
117998
117920
  _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,10 +30,10 @@
30
30
  "@types/node": "^14",
31
31
  "jest": "^29",
32
32
  "typescript": "^5",
33
- "@modern-js/generator-utils": "3.1.29",
34
- "@modern-js/generator-common": "3.1.29",
35
- "@scripts/build": "2.27.0",
36
- "@scripts/jest-config": "2.27.0"
33
+ "@modern-js/generator-utils": "3.1.31",
34
+ "@modern-js/generator-common": "3.1.31",
35
+ "@scripts/jest-config": "2.29.0",
36
+ "@scripts/build": "2.29.0"
37
37
  },
38
38
  "sideEffects": false,
39
39
  "publishConfig": {