@modern-js/server-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
@@ -35125,6 +35125,8 @@ var require_chainId = __commonJS({
35125
35125
  YAML: "yaml",
35126
35126
  /** Rule for wasm */
35127
35127
  WASM: "wasm",
35128
+ /** Rule for node */
35129
+ NODE: "node",
35128
35130
  /** Rule for bff */
35129
35131
  JS_BFF_API: "js-bff-api"
35130
35132
  },
@@ -35163,6 +35165,8 @@ var require_chainId = __commonJS({
35163
35165
  TOML: "toml",
35164
35166
  /** html-loader */
35165
35167
  HTML: "html",
35168
+ /** node-loader */
35169
+ NODE: "html",
35166
35170
  /** babel-loader */
35167
35171
  BABEL: "babel",
35168
35172
  /** esbuild-loader */
@@ -35181,6 +35185,8 @@ var require_chainId = __commonJS({
35181
35185
  CSS_MODULES_TS: "css-modules-typescript",
35182
35186
  /** mini-css-extract-plugin.loader */
35183
35187
  MINI_CSS_EXTRACT: "mini-css-extract",
35188
+ /** resolve-url-loader */
35189
+ RESOLVE_URL_LOADER_FOR_SASS: "resolve-url-loader",
35184
35190
  /** builder-plugin-image-compress.loader */
35185
35191
  IMAGE_COMPRESS: "image-compress",
35186
35192
  /** builder-plugin-image-compress svgo-loader */
@@ -35228,6 +35234,10 @@ var require_chainId = __commonJS({
35228
35234
  HTML_NONCE: "html-nonce",
35229
35235
  /** HtmlCrossOriginPlugin */
35230
35236
  HTML_CROSS_ORIGIN: "html-cross-origin",
35237
+ /** htmlPreconnectPlugin */
35238
+ HTML_PRECONNECT: "html-preconnect-plugin",
35239
+ /** htmlDnsPrefetchPlugin */
35240
+ HTML_DNS_PREFETCH: "html-dns-prefetch-plugin",
35231
35241
  /** MiniCssExtractPlugin */
35232
35242
  MINI_CSS_EXTRACT: "mini-css-extract",
35233
35243
  /** VueLoaderPlugin */
@@ -35391,7 +35401,7 @@ var require_constants = __commonJS({
35391
35401
  var API_DIR = "api";
35392
35402
  var SERVER_DIR = "server";
35393
35403
  var SHARED_DIR = "shared";
35394
- var CONFIG_CACHE_DIR = "./node_modules/.cache/node-bundle-require";
35404
+ var CONFIG_CACHE_DIR = "./node_modules/.cache/bundle-require";
35395
35405
  var CONFIG_FILE_EXTENSIONS = [
35396
35406
  ".js",
35397
35407
  ".ts",
@@ -35423,7 +35433,6 @@ var require_constants = __commonJS({
35423
35433
  };
35424
35434
  var INTERNAL_MODULE_TOOLS_PLUGINS = {
35425
35435
  "@modern-js/module-tools": "@modern-js/module-tools",
35426
- "@modern-js/doc-tools": "@modern-js/doc-tools",
35427
35436
  "@modern-js/runtime": "@modern-js/runtime/cli",
35428
35437
  "@modern-js/plugin-testing": "@modern-js/plugin-testing/cli",
35429
35438
  "@modern-js/plugin-storybook": "@modern-js/plugin-storybook/cli",
@@ -35699,13 +35708,15 @@ var require_config = __commonJS({
35699
35708
  return isSingleEntry;
35700
35709
  }
35701
35710
  });
35711
+ var _constants = require_constants();
35702
35712
  var _type = require_type();
35703
35713
  var isSSR = (config) => {
35714
+ var _server, _server1;
35704
35715
  const { server } = config;
35705
- if (server === null || server === void 0 ? void 0 : server.ssr) {
35716
+ if ((_server = server) === null || _server === void 0 ? void 0 : _server.ssr) {
35706
35717
  return true;
35707
35718
  }
35708
- if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && !(0, _type.isEmpty)(server.ssrByEntries)) {
35719
+ if (((_server1 = server) === null || _server1 === void 0 ? void 0 : _server1.ssrByEntries) && !(0, _type.isEmpty)(server.ssrByEntries)) {
35709
35720
  for (const name of Object.keys(server.ssrByEntries)) {
35710
35721
  if (server.ssrByEntries[name]) {
35711
35722
  return true;
@@ -35715,30 +35726,32 @@ var require_config = __commonJS({
35715
35726
  return false;
35716
35727
  };
35717
35728
  var isUseSSRBundle = (config) => {
35729
+ var _output;
35718
35730
  const { output: output2 } = config;
35719
- if (output2 === null || output2 === void 0 ? void 0 : output2.ssg) {
35731
+ if ((_output = output2) === null || _output === void 0 ? void 0 : _output.ssg) {
35720
35732
  return true;
35721
35733
  }
35722
35734
  return isSSR(config);
35723
35735
  };
35724
35736
  var isServiceWorker = (config) => {
35725
- var _deploy_worker;
35737
+ var _deploy_worker, _deploy, _output;
35726
35738
  const { output: output2, deploy } = config;
35727
- 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))) {
35739
+ 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))) {
35728
35740
  return true;
35729
35741
  }
35730
35742
  return false;
35731
35743
  };
35732
35744
  var isRouterV5 = (config) => {
35733
- var _config_runtime, _config_runtime1, _config_runtime_router;
35734
- 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";
35745
+ var _config_runtime, _config_runtime_router, _config_runtime1, _config;
35746
+ 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";
35735
35747
  };
35736
35748
  var isSSGEntry = (config, entryName, entrypoints) => {
35749
+ var _config_source, _ssgConfig, _ssgConfig1;
35737
35750
  const ssgConfig = config.output.ssg;
35738
- 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]);
35751
+ 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]);
35739
35752
  return useSSG;
35740
35753
  };
35741
- var isSingleEntry = (entrypoints) => entrypoints.length === 1 && entrypoints[0].entryName === "main";
35754
+ var isSingleEntry = (entrypoints, mainEntryName = _constants.MAIN_ENTRY_NAME) => entrypoints.length === 1 && entrypoints[0].entryName === mainEntryName;
35742
35755
  }
35743
35756
  });
35744
35757
 
@@ -36285,6 +36298,9 @@ var require_logger = __commonJS({
36285
36298
  });
36286
36299
  }
36287
36300
  _export(exports, {
36301
+ isErrorStackMessage: function() {
36302
+ return isErrorStackMessage;
36303
+ },
36288
36304
  Logger: function() {
36289
36305
  return Logger;
36290
36306
  },
@@ -36335,6 +36351,9 @@ var require_logger = __commonJS({
36335
36351
  displayLabel: true,
36336
36352
  uppercaseLabel: false
36337
36353
  };
36354
+ var errorStackRegExp = /^\s*at\s.*:\d+:\d+[\s)]*$/;
36355
+ var anonymousErrorStackRegExp = /^\s*at\s.*\(<anonymous>\)$/;
36356
+ var isErrorStackMessage = (message) => errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message);
36338
36357
  var Logger = class {
36339
36358
  _log(type, message, ...args) {
36340
36359
  if (message === void 0 || message === null) {
@@ -36360,6 +36379,9 @@ ${_chalk.default.grey(rest.join("\n"))}`;
36360
36379
  } else {
36361
36380
  text = message.message;
36362
36381
  }
36382
+ } else if (logType.level === "error" && typeof message === "string") {
36383
+ const lines = message.split("\n");
36384
+ text = lines.map((line) => isErrorStackMessage(line) ? _chalk.default.gray(line) : line).join("\n");
36363
36385
  } else {
36364
36386
  text = `${message}`;
36365
36387
  }
@@ -36482,7 +36504,7 @@ var require_alias = __commonJS({
36482
36504
  };
36483
36505
  var mergeAlias = (alias) => (0, _applyOptionsChain.applyOptionsChain)({}, alias);
36484
36506
  var getAliasConfig = (aliasOption, option) => {
36485
- var _tsconfig_compilerOptions, _tsconfig_compilerOptions1;
36507
+ var _tsconfig_compilerOptions, _tsconfig, _tsconfig_compilerOptions1, _tsconfig1;
36486
36508
  const isTsProject2 = _fs.default.existsSync(option.tsconfigPath);
36487
36509
  const alias = mergeAlias(aliasOption);
36488
36510
  if (!isTsProject2) {
@@ -36494,10 +36516,10 @@ var require_alias = __commonJS({
36494
36516
  };
36495
36517
  }
36496
36518
  const tsconfig = (0, _get.readTsConfigByFile)(option.tsconfigPath);
36497
- const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
36519
+ const baseUrl = (_tsconfig = tsconfig) === null || _tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = _tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
36498
36520
  return {
36499
36521
  absoluteBaseUrl: baseUrl ? _path.default.join(option.appDirectory, baseUrl) : option.appDirectory,
36500
- 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),
36522
+ 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),
36501
36523
  isTsPath: true,
36502
36524
  isTsProject: isTsProject2
36503
36525
  };
@@ -36541,15 +36563,6 @@ var require_path = __commonJS({
36541
36563
  getTemplatePath: function() {
36542
36564
  return getTemplatePath;
36543
36565
  },
36544
- compilePathMatcherRegExp: function() {
36545
- return compilePathMatcherRegExp;
36546
- },
36547
- _joinPathParts: function() {
36548
- return _joinPathParts;
36549
- },
36550
- upwardPaths: function() {
36551
- return upwardPaths;
36552
- },
36553
36566
  getRealTemporaryDirectory: function() {
36554
36567
  return getRealTemporaryDirectory;
36555
36568
  },
@@ -36587,20 +36600,6 @@ var require_path = __commonJS({
36587
36600
  parts.push((0, _compiled.nanoid)());
36588
36601
  return _path.default.resolve(...parts);
36589
36602
  };
36590
- function compilePathMatcherRegExp(match) {
36591
- if (typeof match !== "string") {
36592
- return match;
36593
- }
36594
- const escaped = _compiled.lodash.escapeRegExp(match);
36595
- return new RegExp(`(?<=\\W|^)${escaped}(?=\\W|$)`);
36596
- }
36597
- var _joinPathParts = (_part, i, parts) => (0, _compiled.lodash)(parts).filter((part) => ![
36598
- "/",
36599
- "\\"
36600
- ].includes(part)).tap((parts2) => parts2.unshift("")).slice(0, i + 2).join("/");
36601
- function upwardPaths(start) {
36602
- return (0, _compiled.lodash)(start).split(/[/\\]/).filter(Boolean).map(_joinPathParts).reverse().push("/").value();
36603
- }
36604
36603
  function getRealTemporaryDirectory() {
36605
36604
  let ret = null;
36606
36605
  try {
@@ -36852,84 +36851,6 @@ var require_monorepo = __commonJS({
36852
36851
  }
36853
36852
  });
36854
36853
 
36855
- // ../../../toolkit/utils/dist/cjs/cli/pathSerializer.js
36856
- var require_pathSerializer = __commonJS({
36857
- "../../../toolkit/utils/dist/cjs/cli/pathSerializer.js"(exports) {
36858
- "use strict";
36859
- Object.defineProperty(exports, "__esModule", {
36860
- value: true
36861
- });
36862
- function _export(target, all) {
36863
- for (var name in all)
36864
- Object.defineProperty(target, name, {
36865
- enumerable: true,
36866
- get: all[name]
36867
- });
36868
- }
36869
- _export(exports, {
36870
- matchUpwardPathsAsUnknown: function() {
36871
- return matchUpwardPathsAsUnknown;
36872
- },
36873
- applyPathMatcher: function() {
36874
- return applyPathMatcher;
36875
- },
36876
- applyMatcherReplacement: function() {
36877
- return applyMatcherReplacement;
36878
- },
36879
- createDefaultPathMatchers: function() {
36880
- return createDefaultPathMatchers;
36881
- }
36882
- });
36883
- var _interop_require_default = require_interop_require_default();
36884
- var _os = /* @__PURE__ */ _interop_require_default._(require("os"));
36885
- var _lodash = /* @__PURE__ */ _interop_require_default._(require_lodash2());
36886
- var _path = require_path();
36887
- var matchUpwardPathsAsUnknown = (p) => (0, _lodash.default)((0, _path.upwardPaths)((0, _path.normalizeToPosixPath)(p))).map((match) => ({
36888
- match,
36889
- mark: "unknown"
36890
- })).slice(1, -1).value();
36891
- function applyPathMatcher(matcher, str, options = {}) {
36892
- const regex2 = (0, _path.compilePathMatcherRegExp)(matcher.match);
36893
- const replacer = (substring, ...args) => {
36894
- if (options.minPartials && (0, _path.splitPathString)(substring).length < options.minPartials) {
36895
- return substring;
36896
- }
36897
- const ret = typeof matcher.mark === "string" ? matcher.mark : matcher.mark(substring, ...args);
36898
- return `<${_lodash.default.snakeCase(ret).toUpperCase()}>`;
36899
- };
36900
- return str.replace(regex2, replacer);
36901
- }
36902
- function applyMatcherReplacement(matchers, str, options = {}) {
36903
- return matchers.reduce((ret, matcher) => {
36904
- return applyPathMatcher(matcher, ret, options);
36905
- }, str);
36906
- }
36907
- var createDefaultPathMatchers = (root) => {
36908
- const ret = [
36909
- {
36910
- match: RegExp("(?<=\\/)(\\.pnpm\\/.+?\\/node_modules)(?=\\/)"),
36911
- mark: "pnpmInner"
36912
- }
36913
- ];
36914
- const tmpdir = (0, _path.getRealTemporaryDirectory)();
36915
- tmpdir && ret.push({
36916
- match: tmpdir,
36917
- mark: "temp"
36918
- });
36919
- ret.push({
36920
- match: _os.default.tmpdir(),
36921
- mark: "temp"
36922
- });
36923
- ret.push({
36924
- match: _os.default.homedir(),
36925
- mark: "home"
36926
- });
36927
- ret.push(...matchUpwardPathsAsUnknown(root));
36928
- return ret;
36929
- };
36930
- }
36931
- });
36932
-
36933
36854
  // ../../../toolkit/utils/dist/cjs/cli/port.js
36934
36855
  var require_port = __commonJS({
36935
36856
  "../../../toolkit/utils/dist/cjs/cli/port.js"(exports) {
@@ -37036,7 +36957,8 @@ var require_prettyInstructions = __commonJS({
37036
36957
  const LOCAL_LABEL = "Local: ";
37037
36958
  const NETWORK_LABEL = "Network: ";
37038
36959
  const isLocalhost = (url) => {
37039
- return url === null || url === void 0 ? void 0 : url.includes("localhost");
36960
+ var _url;
36961
+ return (_url = url) === null || _url === void 0 ? void 0 : _url.includes("localhost");
37040
36962
  };
37041
36963
  if (host && host !== _constants.DEFAULT_DEV_HOST) {
37042
36964
  return [
@@ -37063,19 +36985,19 @@ var require_prettyInstructions = __commonJS({
37063
36985
  }, []);
37064
36986
  };
37065
36987
  var prettyInstructions = (appContext, config) => {
37066
- var _appContext_builder_context_devServer, _appContext_builder, _config_dev;
36988
+ var _appContext_builder_context_devServer, _appContext_builder, _config_dev, _config_source;
37067
36989
  const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
37068
- 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);
36990
+ 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);
37069
36991
  const urls = getAddressUrls(isHttps ? "https" : "http", port, (_config_dev = config.dev) === null || _config_dev === void 0 ? void 0 : _config_dev.host);
37070
36992
  const routes = !apiOnly ? serverRoutes.filter((route) => route.entryName) : serverRoutes;
37071
36993
  let message = "App running at:\n\n";
37072
- if ((0, _is.isSingleEntry)(entrypoints) || apiOnly) {
36994
+ if ((0, _is.isSingleEntry)(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) || apiOnly) {
37073
36995
  message += urls.map(({ label, url }) => ` ${_compiled.chalk.bold(`> ${label.padEnd(10)}`)}${_compiled.chalk.cyanBright(normalizeUrl(`${url}/${routes[0].urlPath}`))}
37074
36996
  `).join("");
37075
36997
  } else {
37076
36998
  const maxNameLength = Math.max(...routes.map((r) => r.entryName.length));
37077
36999
  urls.forEach(({ label, url }) => {
37078
- message += ` ${_compiled.chalk.bold(`> ${label}`)}
37000
+ message += ` ${_compiled.chalk.bold(`> ${label}`)}${routes.length === 0 ? _compiled.chalk.cyanBright(url) : ""}
37079
37001
  `;
37080
37002
  routes.forEach(({ entryName, urlPath, isSSR }) => {
37081
37003
  if (!checkedEntries.includes(entryName)) {
@@ -37130,8 +37052,9 @@ var require_require = __commonJS({
37130
37052
  });
37131
37053
  var _fs = require_fs();
37132
37054
  var compatRequire = (filePath, interop = true) => {
37055
+ var _mod;
37133
37056
  const mod = require(filePath);
37134
- const rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
37057
+ const rtnESMDefault = interop && ((_mod = mod) === null || _mod === void 0 ? void 0 : _mod.__esModule);
37135
37058
  return rtnESMDefault ? mod.default : mod;
37136
37059
  };
37137
37060
  var dynamicImport = new Function("modulePath", "return import(modulePath)");
@@ -37323,7 +37246,6 @@ var require_cli = __commonJS({
37323
37246
  _export_star._(require_monorepo(), exports);
37324
37247
  _export_star._(require_package2(), exports);
37325
37248
  _export_star._(require_path(), exports);
37326
- _export_star._(require_pathSerializer(), exports);
37327
37249
  _export_star._(require_port(), exports);
37328
37250
  _export_star._(require_prettyInstructions(), exports);
37329
37251
  _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
  "types": "./src/index.ts",
21
21
  "main": "./dist/index.js",
@@ -31,11 +31,11 @@
31
31
  "@types/node": "^14",
32
32
  "jest": "^29",
33
33
  "typescript": "^5",
34
- "@modern-js/generator-common": "3.1.29",
35
- "@scripts/jest-config": "2.27.0",
36
- "@modern-js/dependence-generator": "3.1.29",
37
- "@scripts/build": "2.27.0",
38
- "@modern-js/generator-utils": "3.1.29"
34
+ "@scripts/build": "2.29.0",
35
+ "@scripts/jest-config": "2.29.0",
36
+ "@modern-js/generator-common": "3.1.31",
37
+ "@modern-js/dependence-generator": "3.1.31",
38
+ "@modern-js/generator-utils": "3.1.31"
39
39
  },
40
40
  "sideEffects": false,
41
41
  "publishConfig": {