@modern-js/entry-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 +46 -123
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -35129,6 +35129,8 @@ var require_chainId = __commonJS({
35129
35129
  YAML: "yaml",
35130
35130
  /** Rule for wasm */
35131
35131
  WASM: "wasm",
35132
+ /** Rule for node */
35133
+ NODE: "node",
35132
35134
  /** Rule for bff */
35133
35135
  JS_BFF_API: "js-bff-api"
35134
35136
  },
@@ -35167,6 +35169,8 @@ var require_chainId = __commonJS({
35167
35169
  TOML: "toml",
35168
35170
  /** html-loader */
35169
35171
  HTML: "html",
35172
+ /** node-loader */
35173
+ NODE: "html",
35170
35174
  /** babel-loader */
35171
35175
  BABEL: "babel",
35172
35176
  /** esbuild-loader */
@@ -35185,6 +35189,8 @@ var require_chainId = __commonJS({
35185
35189
  CSS_MODULES_TS: "css-modules-typescript",
35186
35190
  /** mini-css-extract-plugin.loader */
35187
35191
  MINI_CSS_EXTRACT: "mini-css-extract",
35192
+ /** resolve-url-loader */
35193
+ RESOLVE_URL_LOADER_FOR_SASS: "resolve-url-loader",
35188
35194
  /** builder-plugin-image-compress.loader */
35189
35195
  IMAGE_COMPRESS: "image-compress",
35190
35196
  /** builder-plugin-image-compress svgo-loader */
@@ -35232,6 +35238,10 @@ var require_chainId = __commonJS({
35232
35238
  HTML_NONCE: "html-nonce",
35233
35239
  /** HtmlCrossOriginPlugin */
35234
35240
  HTML_CROSS_ORIGIN: "html-cross-origin",
35241
+ /** htmlPreconnectPlugin */
35242
+ HTML_PRECONNECT: "html-preconnect-plugin",
35243
+ /** htmlDnsPrefetchPlugin */
35244
+ HTML_DNS_PREFETCH: "html-dns-prefetch-plugin",
35235
35245
  /** MiniCssExtractPlugin */
35236
35246
  MINI_CSS_EXTRACT: "mini-css-extract",
35237
35247
  /** VueLoaderPlugin */
@@ -35395,7 +35405,7 @@ var require_constants = __commonJS({
35395
35405
  var API_DIR = "api";
35396
35406
  var SERVER_DIR = "server";
35397
35407
  var SHARED_DIR = "shared";
35398
- var CONFIG_CACHE_DIR = "./node_modules/.cache/node-bundle-require";
35408
+ var CONFIG_CACHE_DIR = "./node_modules/.cache/bundle-require";
35399
35409
  var CONFIG_FILE_EXTENSIONS = [
35400
35410
  ".js",
35401
35411
  ".ts",
@@ -35427,7 +35437,6 @@ var require_constants = __commonJS({
35427
35437
  };
35428
35438
  var INTERNAL_MODULE_TOOLS_PLUGINS = {
35429
35439
  "@modern-js/module-tools": "@modern-js/module-tools",
35430
- "@modern-js/doc-tools": "@modern-js/doc-tools",
35431
35440
  "@modern-js/runtime": "@modern-js/runtime/cli",
35432
35441
  "@modern-js/plugin-testing": "@modern-js/plugin-testing/cli",
35433
35442
  "@modern-js/plugin-storybook": "@modern-js/plugin-storybook/cli",
@@ -35703,13 +35712,15 @@ var require_config = __commonJS({
35703
35712
  return isSingleEntry2;
35704
35713
  }
35705
35714
  });
35715
+ var _constants = require_constants();
35706
35716
  var _type = require_type();
35707
35717
  var isSSR = (config) => {
35718
+ var _server, _server1;
35708
35719
  const { server } = config;
35709
- if (server === null || server === void 0 ? void 0 : server.ssr) {
35720
+ if ((_server = server) === null || _server === void 0 ? void 0 : _server.ssr) {
35710
35721
  return true;
35711
35722
  }
35712
- if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && !(0, _type.isEmpty)(server.ssrByEntries)) {
35723
+ if (((_server1 = server) === null || _server1 === void 0 ? void 0 : _server1.ssrByEntries) && !(0, _type.isEmpty)(server.ssrByEntries)) {
35713
35724
  for (const name of Object.keys(server.ssrByEntries)) {
35714
35725
  if (server.ssrByEntries[name]) {
35715
35726
  return true;
@@ -35719,30 +35730,32 @@ var require_config = __commonJS({
35719
35730
  return false;
35720
35731
  };
35721
35732
  var isUseSSRBundle = (config) => {
35733
+ var _output;
35722
35734
  const { output: output2 } = config;
35723
- if (output2 === null || output2 === void 0 ? void 0 : output2.ssg) {
35735
+ if ((_output = output2) === null || _output === void 0 ? void 0 : _output.ssg) {
35724
35736
  return true;
35725
35737
  }
35726
35738
  return isSSR(config);
35727
35739
  };
35728
35740
  var isServiceWorker = (config) => {
35729
- var _deploy_worker;
35741
+ var _deploy_worker, _deploy, _output;
35730
35742
  const { output: output2, deploy } = config;
35731
- 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))) {
35743
+ 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))) {
35732
35744
  return true;
35733
35745
  }
35734
35746
  return false;
35735
35747
  };
35736
35748
  var isRouterV5 = (config) => {
35737
- var _config_runtime, _config_runtime1, _config_runtime_router;
35738
- 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";
35749
+ var _config_runtime, _config_runtime_router, _config_runtime1, _config;
35750
+ 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";
35739
35751
  };
35740
35752
  var isSSGEntry = (config, entryName, entrypoints) => {
35753
+ var _config_source, _ssgConfig, _ssgConfig1;
35741
35754
  const ssgConfig = config.output.ssg;
35742
- const useSSG = isSingleEntry2(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]);
35755
+ const useSSG = isSingleEntry2(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]);
35743
35756
  return useSSG;
35744
35757
  };
35745
- var isSingleEntry2 = (entrypoints) => entrypoints.length === 1 && entrypoints[0].entryName === "main";
35758
+ var isSingleEntry2 = (entrypoints, mainEntryName = _constants.MAIN_ENTRY_NAME) => entrypoints.length === 1 && entrypoints[0].entryName === mainEntryName;
35746
35759
  }
35747
35760
  });
35748
35761
 
@@ -36289,6 +36302,9 @@ var require_logger = __commonJS({
36289
36302
  });
36290
36303
  }
36291
36304
  _export(exports, {
36305
+ isErrorStackMessage: function() {
36306
+ return isErrorStackMessage;
36307
+ },
36292
36308
  Logger: function() {
36293
36309
  return Logger;
36294
36310
  },
@@ -36339,6 +36355,9 @@ var require_logger = __commonJS({
36339
36355
  displayLabel: true,
36340
36356
  uppercaseLabel: false
36341
36357
  };
36358
+ var errorStackRegExp = /^\s*at\s.*:\d+:\d+[\s)]*$/;
36359
+ var anonymousErrorStackRegExp = /^\s*at\s.*\(<anonymous>\)$/;
36360
+ var isErrorStackMessage = (message) => errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message);
36342
36361
  var Logger = class {
36343
36362
  _log(type, message, ...args) {
36344
36363
  if (message === void 0 || message === null) {
@@ -36364,6 +36383,9 @@ ${_chalk.default.grey(rest.join("\n"))}`;
36364
36383
  } else {
36365
36384
  text = message.message;
36366
36385
  }
36386
+ } else if (logType.level === "error" && typeof message === "string") {
36387
+ const lines = message.split("\n");
36388
+ text = lines.map((line) => isErrorStackMessage(line) ? _chalk.default.gray(line) : line).join("\n");
36367
36389
  } else {
36368
36390
  text = `${message}`;
36369
36391
  }
@@ -36486,7 +36508,7 @@ var require_alias = __commonJS({
36486
36508
  };
36487
36509
  var mergeAlias = (alias) => (0, _applyOptionsChain.applyOptionsChain)({}, alias);
36488
36510
  var getAliasConfig = (aliasOption, option) => {
36489
- var _tsconfig_compilerOptions, _tsconfig_compilerOptions1;
36511
+ var _tsconfig_compilerOptions, _tsconfig, _tsconfig_compilerOptions1, _tsconfig1;
36490
36512
  const isTsProject2 = _fs.default.existsSync(option.tsconfigPath);
36491
36513
  const alias = mergeAlias(aliasOption);
36492
36514
  if (!isTsProject2) {
@@ -36498,10 +36520,10 @@ var require_alias = __commonJS({
36498
36520
  };
36499
36521
  }
36500
36522
  const tsconfig = (0, _get.readTsConfigByFile)(option.tsconfigPath);
36501
- const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
36523
+ const baseUrl = (_tsconfig = tsconfig) === null || _tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = _tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
36502
36524
  return {
36503
36525
  absoluteBaseUrl: baseUrl ? _path.default.join(option.appDirectory, baseUrl) : option.appDirectory,
36504
- 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),
36526
+ 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),
36505
36527
  isTsPath: true,
36506
36528
  isTsProject: isTsProject2
36507
36529
  };
@@ -36545,15 +36567,6 @@ var require_path = __commonJS({
36545
36567
  getTemplatePath: function() {
36546
36568
  return getTemplatePath;
36547
36569
  },
36548
- compilePathMatcherRegExp: function() {
36549
- return compilePathMatcherRegExp;
36550
- },
36551
- _joinPathParts: function() {
36552
- return _joinPathParts;
36553
- },
36554
- upwardPaths: function() {
36555
- return upwardPaths;
36556
- },
36557
36570
  getRealTemporaryDirectory: function() {
36558
36571
  return getRealTemporaryDirectory;
36559
36572
  },
@@ -36591,20 +36604,6 @@ var require_path = __commonJS({
36591
36604
  parts.push((0, _compiled.nanoid)());
36592
36605
  return _path.default.resolve(...parts);
36593
36606
  };
36594
- function compilePathMatcherRegExp(match) {
36595
- if (typeof match !== "string") {
36596
- return match;
36597
- }
36598
- const escaped = _compiled.lodash.escapeRegExp(match);
36599
- return new RegExp(`(?<=\\W|^)${escaped}(?=\\W|$)`);
36600
- }
36601
- var _joinPathParts = (_part, i, parts) => (0, _compiled.lodash)(parts).filter((part) => ![
36602
- "/",
36603
- "\\"
36604
- ].includes(part)).tap((parts2) => parts2.unshift("")).slice(0, i + 2).join("/");
36605
- function upwardPaths(start) {
36606
- return (0, _compiled.lodash)(start).split(/[/\\]/).filter(Boolean).map(_joinPathParts).reverse().push("/").value();
36607
- }
36608
36607
  function getRealTemporaryDirectory() {
36609
36608
  let ret = null;
36610
36609
  try {
@@ -36856,84 +36855,6 @@ var require_monorepo = __commonJS({
36856
36855
  }
36857
36856
  });
36858
36857
 
36859
- // ../../../toolkit/utils/dist/cjs/cli/pathSerializer.js
36860
- var require_pathSerializer = __commonJS({
36861
- "../../../toolkit/utils/dist/cjs/cli/pathSerializer.js"(exports) {
36862
- "use strict";
36863
- Object.defineProperty(exports, "__esModule", {
36864
- value: true
36865
- });
36866
- function _export(target, all) {
36867
- for (var name in all)
36868
- Object.defineProperty(target, name, {
36869
- enumerable: true,
36870
- get: all[name]
36871
- });
36872
- }
36873
- _export(exports, {
36874
- matchUpwardPathsAsUnknown: function() {
36875
- return matchUpwardPathsAsUnknown;
36876
- },
36877
- applyPathMatcher: function() {
36878
- return applyPathMatcher;
36879
- },
36880
- applyMatcherReplacement: function() {
36881
- return applyMatcherReplacement;
36882
- },
36883
- createDefaultPathMatchers: function() {
36884
- return createDefaultPathMatchers;
36885
- }
36886
- });
36887
- var _interop_require_default = require_interop_require_default();
36888
- var _os = /* @__PURE__ */ _interop_require_default._(require("os"));
36889
- var _lodash = /* @__PURE__ */ _interop_require_default._(require_lodash3());
36890
- var _path = require_path();
36891
- var matchUpwardPathsAsUnknown = (p) => (0, _lodash.default)((0, _path.upwardPaths)((0, _path.normalizeToPosixPath)(p))).map((match) => ({
36892
- match,
36893
- mark: "unknown"
36894
- })).slice(1, -1).value();
36895
- function applyPathMatcher(matcher, str, options = {}) {
36896
- const regex2 = (0, _path.compilePathMatcherRegExp)(matcher.match);
36897
- const replacer = (substring, ...args) => {
36898
- if (options.minPartials && (0, _path.splitPathString)(substring).length < options.minPartials) {
36899
- return substring;
36900
- }
36901
- const ret = typeof matcher.mark === "string" ? matcher.mark : matcher.mark(substring, ...args);
36902
- return `<${_lodash.default.snakeCase(ret).toUpperCase()}>`;
36903
- };
36904
- return str.replace(regex2, replacer);
36905
- }
36906
- function applyMatcherReplacement(matchers, str, options = {}) {
36907
- return matchers.reduce((ret, matcher) => {
36908
- return applyPathMatcher(matcher, ret, options);
36909
- }, str);
36910
- }
36911
- var createDefaultPathMatchers = (root) => {
36912
- const ret = [
36913
- {
36914
- match: RegExp("(?<=\\/)(\\.pnpm\\/.+?\\/node_modules)(?=\\/)"),
36915
- mark: "pnpmInner"
36916
- }
36917
- ];
36918
- const tmpdir = (0, _path.getRealTemporaryDirectory)();
36919
- tmpdir && ret.push({
36920
- match: tmpdir,
36921
- mark: "temp"
36922
- });
36923
- ret.push({
36924
- match: _os.default.tmpdir(),
36925
- mark: "temp"
36926
- });
36927
- ret.push({
36928
- match: _os.default.homedir(),
36929
- mark: "home"
36930
- });
36931
- ret.push(...matchUpwardPathsAsUnknown(root));
36932
- return ret;
36933
- };
36934
- }
36935
- });
36936
-
36937
36858
  // ../../../toolkit/utils/dist/cjs/cli/port.js
36938
36859
  var require_port = __commonJS({
36939
36860
  "../../../toolkit/utils/dist/cjs/cli/port.js"(exports) {
@@ -37040,7 +36961,8 @@ var require_prettyInstructions = __commonJS({
37040
36961
  const LOCAL_LABEL = "Local: ";
37041
36962
  const NETWORK_LABEL = "Network: ";
37042
36963
  const isLocalhost = (url) => {
37043
- return url === null || url === void 0 ? void 0 : url.includes("localhost");
36964
+ var _url;
36965
+ return (_url = url) === null || _url === void 0 ? void 0 : _url.includes("localhost");
37044
36966
  };
37045
36967
  if (host && host !== _constants.DEFAULT_DEV_HOST) {
37046
36968
  return [
@@ -37067,19 +36989,19 @@ var require_prettyInstructions = __commonJS({
37067
36989
  }, []);
37068
36990
  };
37069
36991
  var prettyInstructions = (appContext, config) => {
37070
- var _appContext_builder_context_devServer, _appContext_builder, _config_dev;
36992
+ var _appContext_builder_context_devServer, _appContext_builder, _config_dev, _config_source;
37071
36993
  const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
37072
- 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);
36994
+ 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);
37073
36995
  const urls = getAddressUrls(isHttps ? "https" : "http", port, (_config_dev = config.dev) === null || _config_dev === void 0 ? void 0 : _config_dev.host);
37074
36996
  const routes = !apiOnly ? serverRoutes.filter((route) => route.entryName) : serverRoutes;
37075
36997
  let message = "App running at:\n\n";
37076
- if ((0, _is.isSingleEntry)(entrypoints) || apiOnly) {
36998
+ if ((0, _is.isSingleEntry)(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) || apiOnly) {
37077
36999
  message += urls.map(({ label, url }) => ` ${_compiled.chalk.bold(`> ${label.padEnd(10)}`)}${_compiled.chalk.cyanBright(normalizeUrl(`${url}/${routes[0].urlPath}`))}
37078
37000
  `).join("");
37079
37001
  } else {
37080
37002
  const maxNameLength = Math.max(...routes.map((r) => r.entryName.length));
37081
37003
  urls.forEach(({ label, url }) => {
37082
- message += ` ${_compiled.chalk.bold(`> ${label}`)}
37004
+ message += ` ${_compiled.chalk.bold(`> ${label}`)}${routes.length === 0 ? _compiled.chalk.cyanBright(url) : ""}
37083
37005
  `;
37084
37006
  routes.forEach(({ entryName, urlPath, isSSR }) => {
37085
37007
  if (!checkedEntries.includes(entryName)) {
@@ -37134,8 +37056,9 @@ var require_require = __commonJS({
37134
37056
  });
37135
37057
  var _fs = require_fs();
37136
37058
  var compatRequire = (filePath, interop = true) => {
37059
+ var _mod;
37137
37060
  const mod = require(filePath);
37138
- const rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
37061
+ const rtnESMDefault = interop && ((_mod = mod) === null || _mod === void 0 ? void 0 : _mod.__esModule);
37139
37062
  return rtnESMDefault ? mod.default : mod;
37140
37063
  };
37141
37064
  var dynamicImport = new Function("modulePath", "return import(modulePath)");
@@ -37327,7 +37250,6 @@ var require_cli = __commonJS({
37327
37250
  _export_star._(require_monorepo(), exports);
37328
37251
  _export_star._(require_package2(), exports);
37329
37252
  _export_star._(require_path(), exports);
37330
- _export_star._(require_pathSerializer(), exports);
37331
37253
  _export_star._(require_port(), exports);
37332
37254
  _export_star._(require_prettyInstructions(), exports);
37333
37255
  _export_star._(require_require(), exports);
@@ -116259,6 +116181,7 @@ var BooleanConfigName = {
116259
116181
 
116260
116182
  // ../../generator-common/dist/esm-node/mwa/entry.js
116261
116183
  var getEntryNameSchema = (extra = {}) => {
116184
+ var _extra;
116262
116185
  return {
116263
116186
  type: "string",
116264
116187
  title: i18n.t(localeKeys.entry.name),
@@ -116277,7 +116200,7 @@ var getEntryNameSchema = (extra = {}) => {
116277
116200
  dependencies: [],
116278
116201
  fulfill: {
116279
116202
  state: {
116280
- visible: !(extra === null || extra === void 0 ? void 0 : extra.isEmptySrc)
116203
+ visible: !((_extra = extra) === null || _extra === void 0 ? void 0 : _extra.isEmptySrc)
116281
116204
  }
116282
116205
  }
116283
116206
  }
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,12 +30,12 @@
30
30
  "@types/node": "^14",
31
31
  "jest": "^29",
32
32
  "typescript": "^5",
33
- "@modern-js/generator-utils": "3.1.29",
34
- "@modern-js/plugin-i18n": "2.27.0",
35
- "@modern-js/utils": "2.27.0",
36
- "@modern-js/generator-common": "3.1.29",
37
- "@scripts/jest-config": "2.27.0",
38
- "@scripts/build": "2.27.0"
33
+ "@modern-js/generator-utils": "3.1.31",
34
+ "@modern-js/plugin-i18n": "2.29.0",
35
+ "@modern-js/utils": "2.29.0",
36
+ "@modern-js/generator-common": "3.1.31",
37
+ "@scripts/jest-config": "2.29.0",
38
+ "@scripts/build": "2.29.0"
39
39
  },
40
40
  "sideEffects": false,
41
41
  "publishConfig": {