@modern-js/ssg-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 +7 -7
package/dist/index.js CHANGED
@@ -113724,6 +113724,8 @@ var require_chainId = __commonJS({
113724
113724
  YAML: "yaml",
113725
113725
  /** Rule for wasm */
113726
113726
  WASM: "wasm",
113727
+ /** Rule for node */
113728
+ NODE: "node",
113727
113729
  /** Rule for bff */
113728
113730
  JS_BFF_API: "js-bff-api"
113729
113731
  },
@@ -113762,6 +113764,8 @@ var require_chainId = __commonJS({
113762
113764
  TOML: "toml",
113763
113765
  /** html-loader */
113764
113766
  HTML: "html",
113767
+ /** node-loader */
113768
+ NODE: "html",
113765
113769
  /** babel-loader */
113766
113770
  BABEL: "babel",
113767
113771
  /** esbuild-loader */
@@ -113780,6 +113784,8 @@ var require_chainId = __commonJS({
113780
113784
  CSS_MODULES_TS: "css-modules-typescript",
113781
113785
  /** mini-css-extract-plugin.loader */
113782
113786
  MINI_CSS_EXTRACT: "mini-css-extract",
113787
+ /** resolve-url-loader */
113788
+ RESOLVE_URL_LOADER_FOR_SASS: "resolve-url-loader",
113783
113789
  /** builder-plugin-image-compress.loader */
113784
113790
  IMAGE_COMPRESS: "image-compress",
113785
113791
  /** builder-plugin-image-compress svgo-loader */
@@ -113827,6 +113833,10 @@ var require_chainId = __commonJS({
113827
113833
  HTML_NONCE: "html-nonce",
113828
113834
  /** HtmlCrossOriginPlugin */
113829
113835
  HTML_CROSS_ORIGIN: "html-cross-origin",
113836
+ /** htmlPreconnectPlugin */
113837
+ HTML_PRECONNECT: "html-preconnect-plugin",
113838
+ /** htmlDnsPrefetchPlugin */
113839
+ HTML_DNS_PREFETCH: "html-dns-prefetch-plugin",
113830
113840
  /** MiniCssExtractPlugin */
113831
113841
  MINI_CSS_EXTRACT: "mini-css-extract",
113832
113842
  /** VueLoaderPlugin */
@@ -113990,7 +114000,7 @@ var require_constants = __commonJS({
113990
114000
  var API_DIR = "api";
113991
114001
  var SERVER_DIR = "server";
113992
114002
  var SHARED_DIR = "shared";
113993
- var CONFIG_CACHE_DIR = "./node_modules/.cache/node-bundle-require";
114003
+ var CONFIG_CACHE_DIR = "./node_modules/.cache/bundle-require";
113994
114004
  var CONFIG_FILE_EXTENSIONS = [
113995
114005
  ".js",
113996
114006
  ".ts",
@@ -114022,7 +114032,6 @@ var require_constants = __commonJS({
114022
114032
  };
114023
114033
  var INTERNAL_MODULE_TOOLS_PLUGINS = {
114024
114034
  "@modern-js/module-tools": "@modern-js/module-tools",
114025
- "@modern-js/doc-tools": "@modern-js/doc-tools",
114026
114035
  "@modern-js/runtime": "@modern-js/runtime/cli",
114027
114036
  "@modern-js/plugin-testing": "@modern-js/plugin-testing/cli",
114028
114037
  "@modern-js/plugin-storybook": "@modern-js/plugin-storybook/cli",
@@ -114298,13 +114307,15 @@ var require_config2 = __commonJS({
114298
114307
  return isSingleEntry;
114299
114308
  }
114300
114309
  });
114310
+ var _constants = require_constants();
114301
114311
  var _type = require_type();
114302
114312
  var isSSR = (config) => {
114313
+ var _server, _server1;
114303
114314
  const { server } = config;
114304
- if (server === null || server === void 0 ? void 0 : server.ssr) {
114315
+ if ((_server = server) === null || _server === void 0 ? void 0 : _server.ssr) {
114305
114316
  return true;
114306
114317
  }
114307
- if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && !(0, _type.isEmpty)(server.ssrByEntries)) {
114318
+ if (((_server1 = server) === null || _server1 === void 0 ? void 0 : _server1.ssrByEntries) && !(0, _type.isEmpty)(server.ssrByEntries)) {
114308
114319
  for (const name of Object.keys(server.ssrByEntries)) {
114309
114320
  if (server.ssrByEntries[name]) {
114310
114321
  return true;
@@ -114314,30 +114325,32 @@ var require_config2 = __commonJS({
114314
114325
  return false;
114315
114326
  };
114316
114327
  var isUseSSRBundle = (config) => {
114328
+ var _output;
114317
114329
  const { output: output2 } = config;
114318
- if (output2 === null || output2 === void 0 ? void 0 : output2.ssg) {
114330
+ if ((_output = output2) === null || _output === void 0 ? void 0 : _output.ssg) {
114319
114331
  return true;
114320
114332
  }
114321
114333
  return isSSR(config);
114322
114334
  };
114323
114335
  var isServiceWorker = (config) => {
114324
- var _deploy_worker;
114336
+ var _deploy_worker, _deploy, _output;
114325
114337
  const { output: output2, deploy } = config;
114326
- 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))) {
114338
+ 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))) {
114327
114339
  return true;
114328
114340
  }
114329
114341
  return false;
114330
114342
  };
114331
114343
  var isRouterV5 = (config) => {
114332
- var _config_runtime, _config_runtime1, _config_runtime_router;
114333
- 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";
114344
+ var _config_runtime, _config_runtime_router, _config_runtime1, _config;
114345
+ 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";
114334
114346
  };
114335
114347
  var isSSGEntry = (config, entryName, entrypoints) => {
114348
+ var _config_source, _ssgConfig, _ssgConfig1;
114336
114349
  const ssgConfig = config.output.ssg;
114337
- 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]);
114350
+ 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]);
114338
114351
  return useSSG;
114339
114352
  };
114340
- var isSingleEntry = (entrypoints) => entrypoints.length === 1 && entrypoints[0].entryName === "main";
114353
+ var isSingleEntry = (entrypoints, mainEntryName = _constants.MAIN_ENTRY_NAME) => entrypoints.length === 1 && entrypoints[0].entryName === mainEntryName;
114341
114354
  }
114342
114355
  });
114343
114356
 
@@ -114884,6 +114897,9 @@ var require_logger2 = __commonJS({
114884
114897
  });
114885
114898
  }
114886
114899
  _export(exports, {
114900
+ isErrorStackMessage: function() {
114901
+ return isErrorStackMessage;
114902
+ },
114887
114903
  Logger: function() {
114888
114904
  return Logger;
114889
114905
  },
@@ -114934,6 +114950,9 @@ var require_logger2 = __commonJS({
114934
114950
  displayLabel: true,
114935
114951
  uppercaseLabel: false
114936
114952
  };
114953
+ var errorStackRegExp = /^\s*at\s.*:\d+:\d+[\s)]*$/;
114954
+ var anonymousErrorStackRegExp = /^\s*at\s.*\(<anonymous>\)$/;
114955
+ var isErrorStackMessage = (message) => errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message);
114937
114956
  var Logger = class {
114938
114957
  _log(type, message, ...args) {
114939
114958
  if (message === void 0 || message === null) {
@@ -114959,6 +114978,9 @@ ${_chalk.default.grey(rest.join("\n"))}`;
114959
114978
  } else {
114960
114979
  text = message.message;
114961
114980
  }
114981
+ } else if (logType.level === "error" && typeof message === "string") {
114982
+ const lines = message.split("\n");
114983
+ text = lines.map((line) => isErrorStackMessage(line) ? _chalk.default.gray(line) : line).join("\n");
114962
114984
  } else {
114963
114985
  text = `${message}`;
114964
114986
  }
@@ -115081,7 +115103,7 @@ var require_alias = __commonJS({
115081
115103
  };
115082
115104
  var mergeAlias = (alias) => (0, _applyOptionsChain.applyOptionsChain)({}, alias);
115083
115105
  var getAliasConfig = (aliasOption, option) => {
115084
- var _tsconfig_compilerOptions, _tsconfig_compilerOptions1;
115106
+ var _tsconfig_compilerOptions, _tsconfig, _tsconfig_compilerOptions1, _tsconfig1;
115085
115107
  const isTsProject2 = _fs.default.existsSync(option.tsconfigPath);
115086
115108
  const alias = mergeAlias(aliasOption);
115087
115109
  if (!isTsProject2) {
@@ -115093,10 +115115,10 @@ var require_alias = __commonJS({
115093
115115
  };
115094
115116
  }
115095
115117
  const tsconfig = (0, _get.readTsConfigByFile)(option.tsconfigPath);
115096
- const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
115118
+ const baseUrl = (_tsconfig = tsconfig) === null || _tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = _tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
115097
115119
  return {
115098
115120
  absoluteBaseUrl: baseUrl ? _path.default.join(option.appDirectory, baseUrl) : option.appDirectory,
115099
- 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),
115121
+ 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),
115100
115122
  isTsPath: true,
115101
115123
  isTsProject: isTsProject2
115102
115124
  };
@@ -115140,15 +115162,6 @@ var require_path = __commonJS({
115140
115162
  getTemplatePath: function() {
115141
115163
  return getTemplatePath;
115142
115164
  },
115143
- compilePathMatcherRegExp: function() {
115144
- return compilePathMatcherRegExp;
115145
- },
115146
- _joinPathParts: function() {
115147
- return _joinPathParts;
115148
- },
115149
- upwardPaths: function() {
115150
- return upwardPaths;
115151
- },
115152
115165
  getRealTemporaryDirectory: function() {
115153
115166
  return getRealTemporaryDirectory;
115154
115167
  },
@@ -115186,20 +115199,6 @@ var require_path = __commonJS({
115186
115199
  parts.push((0, _compiled.nanoid)());
115187
115200
  return _path.default.resolve(...parts);
115188
115201
  };
115189
- function compilePathMatcherRegExp(match) {
115190
- if (typeof match !== "string") {
115191
- return match;
115192
- }
115193
- const escaped = _compiled.lodash.escapeRegExp(match);
115194
- return new RegExp(`(?<=\\W|^)${escaped}(?=\\W|$)`);
115195
- }
115196
- var _joinPathParts = (_part, i, parts) => (0, _compiled.lodash)(parts).filter((part) => ![
115197
- "/",
115198
- "\\"
115199
- ].includes(part)).tap((parts2) => parts2.unshift("")).slice(0, i + 2).join("/");
115200
- function upwardPaths(start) {
115201
- return (0, _compiled.lodash)(start).split(/[/\\]/).filter(Boolean).map(_joinPathParts).reverse().push("/").value();
115202
- }
115203
115202
  function getRealTemporaryDirectory() {
115204
115203
  let ret = null;
115205
115204
  try {
@@ -115451,84 +115450,6 @@ var require_monorepo = __commonJS({
115451
115450
  }
115452
115451
  });
115453
115452
 
115454
- // ../../../toolkit/utils/dist/cjs/cli/pathSerializer.js
115455
- var require_pathSerializer = __commonJS({
115456
- "../../../toolkit/utils/dist/cjs/cli/pathSerializer.js"(exports) {
115457
- "use strict";
115458
- Object.defineProperty(exports, "__esModule", {
115459
- value: true
115460
- });
115461
- function _export(target, all) {
115462
- for (var name in all)
115463
- Object.defineProperty(target, name, {
115464
- enumerable: true,
115465
- get: all[name]
115466
- });
115467
- }
115468
- _export(exports, {
115469
- matchUpwardPathsAsUnknown: function() {
115470
- return matchUpwardPathsAsUnknown;
115471
- },
115472
- applyPathMatcher: function() {
115473
- return applyPathMatcher;
115474
- },
115475
- applyMatcherReplacement: function() {
115476
- return applyMatcherReplacement;
115477
- },
115478
- createDefaultPathMatchers: function() {
115479
- return createDefaultPathMatchers;
115480
- }
115481
- });
115482
- var _interop_require_default = require_interop_require_default();
115483
- var _os = /* @__PURE__ */ _interop_require_default._(require("os"));
115484
- var _lodash = /* @__PURE__ */ _interop_require_default._(require_lodash3());
115485
- var _path = require_path();
115486
- var matchUpwardPathsAsUnknown = (p) => (0, _lodash.default)((0, _path.upwardPaths)((0, _path.normalizeToPosixPath)(p))).map((match) => ({
115487
- match,
115488
- mark: "unknown"
115489
- })).slice(1, -1).value();
115490
- function applyPathMatcher(matcher, str, options = {}) {
115491
- const regex2 = (0, _path.compilePathMatcherRegExp)(matcher.match);
115492
- const replacer = (substring, ...args) => {
115493
- if (options.minPartials && (0, _path.splitPathString)(substring).length < options.minPartials) {
115494
- return substring;
115495
- }
115496
- const ret = typeof matcher.mark === "string" ? matcher.mark : matcher.mark(substring, ...args);
115497
- return `<${_lodash.default.snakeCase(ret).toUpperCase()}>`;
115498
- };
115499
- return str.replace(regex2, replacer);
115500
- }
115501
- function applyMatcherReplacement(matchers, str, options = {}) {
115502
- return matchers.reduce((ret, matcher) => {
115503
- return applyPathMatcher(matcher, ret, options);
115504
- }, str);
115505
- }
115506
- var createDefaultPathMatchers = (root) => {
115507
- const ret = [
115508
- {
115509
- match: RegExp("(?<=\\/)(\\.pnpm\\/.+?\\/node_modules)(?=\\/)"),
115510
- mark: "pnpmInner"
115511
- }
115512
- ];
115513
- const tmpdir = (0, _path.getRealTemporaryDirectory)();
115514
- tmpdir && ret.push({
115515
- match: tmpdir,
115516
- mark: "temp"
115517
- });
115518
- ret.push({
115519
- match: _os.default.tmpdir(),
115520
- mark: "temp"
115521
- });
115522
- ret.push({
115523
- match: _os.default.homedir(),
115524
- mark: "home"
115525
- });
115526
- ret.push(...matchUpwardPathsAsUnknown(root));
115527
- return ret;
115528
- };
115529
- }
115530
- });
115531
-
115532
115453
  // ../../../toolkit/utils/dist/cjs/cli/port.js
115533
115454
  var require_port = __commonJS({
115534
115455
  "../../../toolkit/utils/dist/cjs/cli/port.js"(exports) {
@@ -115635,7 +115556,8 @@ var require_prettyInstructions = __commonJS({
115635
115556
  const LOCAL_LABEL = "Local: ";
115636
115557
  const NETWORK_LABEL = "Network: ";
115637
115558
  const isLocalhost = (url) => {
115638
- return url === null || url === void 0 ? void 0 : url.includes("localhost");
115559
+ var _url;
115560
+ return (_url = url) === null || _url === void 0 ? void 0 : _url.includes("localhost");
115639
115561
  };
115640
115562
  if (host && host !== _constants.DEFAULT_DEV_HOST) {
115641
115563
  return [
@@ -115662,19 +115584,19 @@ var require_prettyInstructions = __commonJS({
115662
115584
  }, []);
115663
115585
  };
115664
115586
  var prettyInstructions = (appContext, config) => {
115665
- var _appContext_builder_context_devServer, _appContext_builder, _config_dev;
115587
+ var _appContext_builder_context_devServer, _appContext_builder, _config_dev, _config_source;
115666
115588
  const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
115667
- 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);
115589
+ 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);
115668
115590
  const urls = getAddressUrls(isHttps ? "https" : "http", port, (_config_dev = config.dev) === null || _config_dev === void 0 ? void 0 : _config_dev.host);
115669
115591
  const routes = !apiOnly ? serverRoutes.filter((route) => route.entryName) : serverRoutes;
115670
115592
  let message = "App running at:\n\n";
115671
- if ((0, _is.isSingleEntry)(entrypoints) || apiOnly) {
115593
+ if ((0, _is.isSingleEntry)(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) || apiOnly) {
115672
115594
  message += urls.map(({ label, url }) => ` ${_compiled.chalk.bold(`> ${label.padEnd(10)}`)}${_compiled.chalk.cyanBright(normalizeUrl(`${url}/${routes[0].urlPath}`))}
115673
115595
  `).join("");
115674
115596
  } else {
115675
115597
  const maxNameLength = Math.max(...routes.map((r) => r.entryName.length));
115676
115598
  urls.forEach(({ label, url }) => {
115677
- message += ` ${_compiled.chalk.bold(`> ${label}`)}
115599
+ message += ` ${_compiled.chalk.bold(`> ${label}`)}${routes.length === 0 ? _compiled.chalk.cyanBright(url) : ""}
115678
115600
  `;
115679
115601
  routes.forEach(({ entryName, urlPath, isSSR }) => {
115680
115602
  if (!checkedEntries.includes(entryName)) {
@@ -115729,8 +115651,9 @@ var require_require = __commonJS({
115729
115651
  });
115730
115652
  var _fs = require_fs();
115731
115653
  var compatRequire = (filePath, interop = true) => {
115654
+ var _mod;
115732
115655
  const mod = require(filePath);
115733
- const rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
115656
+ const rtnESMDefault = interop && ((_mod = mod) === null || _mod === void 0 ? void 0 : _mod.__esModule);
115734
115657
  return rtnESMDefault ? mod.default : mod;
115735
115658
  };
115736
115659
  var dynamicImport = new Function("modulePath", "return import(modulePath)");
@@ -115922,7 +115845,6 @@ var require_cli = __commonJS({
115922
115845
  _export_star._(require_monorepo(), exports);
115923
115846
  _export_star._(require_package4(), exports);
115924
115847
  _export_star._(require_path(), exports);
115925
- _export_star._(require_pathSerializer(), exports);
115926
115848
  _export_star._(require_port(), exports);
115927
115849
  _export_star._(require_prettyInstructions(), exports);
115928
115850
  _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": [
@@ -29,12 +29,12 @@
29
29
  "@types/node": "^14",
30
30
  "jest": "^29",
31
31
  "typescript": "^5",
32
- "@modern-js/generator-common": "3.1.29",
33
- "@modern-js/generator-utils": "3.1.29",
34
- "@modern-js/plugin-i18n": "2.27.0",
35
- "@modern-js/dependence-generator": "3.1.29",
36
- "@scripts/build": "2.27.0",
37
- "@scripts/jest-config": "2.27.0"
32
+ "@modern-js/generator-common": "3.1.31",
33
+ "@modern-js/plugin-i18n": "2.29.0",
34
+ "@modern-js/generator-utils": "3.1.31",
35
+ "@modern-js/dependence-generator": "3.1.31",
36
+ "@scripts/build": "2.29.0",
37
+ "@scripts/jest-config": "2.29.0"
38
38
  },
39
39
  "sideEffects": false,
40
40
  "publishConfig": {