@modern-js/ssg-generator 2.2.1 → 2.3.3

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 +71 -110
  2. package/package.json +10 -10
package/dist/index.js CHANGED
@@ -35668,20 +35668,28 @@ var require_compiled = __commonJSMin((exports) => {
35668
35668
  var require_format = __commonJSMin((exports) => {
35669
35669
  "use strict";
35670
35670
  Object.defineProperty(exports, "__esModule", { value: true });
35671
- exports.formatProxyOptions = exports.formatWebpackMessages = void 0;
35672
- var friendlySyntaxErrorLabel = "Syntax error:";
35671
+ exports.formatWebpackMessages = void 0;
35672
+ var friendlySyntaxErrorLabel = "SyntaxError:";
35673
35673
  function isLikelyASyntaxError(message) {
35674
35674
  return message.includes(friendlySyntaxErrorLabel);
35675
35675
  }
35676
- function formatMessage(message) {
35677
- var _a;
35676
+ function formatMessage(stats) {
35678
35677
  let lines = [];
35679
- if (typeof message === "object") {
35680
- message = `${message.moduleName && `${message.moduleName}
35681
- `}${message.details || message.stack || message.message}`;
35678
+ let message;
35679
+ if (typeof stats === "object") {
35680
+ const fileName = stats.moduleName ? `File: ${stats.moduleName}
35681
+ ` : "";
35682
+ const mainMessage = stats.message;
35683
+ const details = stats.details ? `
35684
+ Details: ${stats.details}
35685
+ ` : "";
35686
+ const stack = stats.stack ? `
35687
+ ${stats.stack}` : "";
35688
+ message = `${fileName}${mainMessage}${details}${stack}`;
35689
+ } else {
35690
+ message = stats;
35682
35691
  }
35683
35692
  lines = message.split("\n");
35684
- lines = lines.filter((line3) => !/Module [A-z ]+\(from/.test(line3));
35685
35693
  lines = lines.map((line3) => {
35686
35694
  const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line3);
35687
35695
  if (!parsingError) {
@@ -35698,11 +35706,8 @@ var require_format = __commonJSMin((exports) => {
35698
35706
  lines.splice(1, 1);
35699
35707
  }
35700
35708
  lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
35701
- if ((_a = lines[1]) === null || _a === void 0 ? void 0 : _a.startsWith("Module not found: ")) {
35702
- lines = [
35703
- lines[0],
35704
- lines[1].replace("Error: ", "").replace("Module not found: Cannot find file:", "Cannot find file:").replace("[CaseSensitivePathsPlugin] ", "").replace("Cannot resolve 'file' or 'directory' ", "")
35705
- ];
35709
+ if (lines[1] && lines[1].indexOf("Module not found:") !== -1) {
35710
+ lines[1] = lines[1].replace("Error: ", "");
35706
35711
  }
35707
35712
  message = lines.join("\n");
35708
35713
  message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, "");
@@ -35729,29 +35734,6 @@ var require_format = __commonJSMin((exports) => {
35729
35734
  return result;
35730
35735
  }
35731
35736
  exports.formatWebpackMessages = formatWebpackMessages;
35732
- function formatProxyOptions(proxyOptions) {
35733
- const formattedProxy = [];
35734
- if (!Array.isArray(proxyOptions)) {
35735
- if ("target" in proxyOptions) {
35736
- formattedProxy.push(proxyOptions);
35737
- } else {
35738
- Array.prototype.push.apply(formattedProxy, Object.keys(proxyOptions).reduce((total, source) => {
35739
- const option = proxyOptions[source];
35740
- total.push({
35741
- context: source,
35742
- changeOrigin: true,
35743
- logLevel: "warn",
35744
- ...typeof option === "string" ? { target: option } : option
35745
- });
35746
- return total;
35747
- }, []));
35748
- }
35749
- } else {
35750
- formattedProxy.push(...proxyOptions);
35751
- }
35752
- return formattedProxy;
35753
- }
35754
- exports.formatProxyOptions = formatProxyOptions;
35755
35737
  });
35756
35738
  var require_logger = __commonJSMin((exports) => {
35757
35739
  "use strict";
@@ -36251,7 +36233,6 @@ var require_constants = __commonJSMin((exports) => {
36251
36233
  "@modern-js/plugin-electron": { cli: "@modern-js/plugin-electron/cli" },
36252
36234
  "@modern-js/plugin-testing": { cli: "@modern-js/plugin-testing/cli" },
36253
36235
  "@modern-js/plugin-storybook": { cli: "@modern-js/plugin-storybook/cli" },
36254
- "@modern-js/plugin-docsite": { cli: "@modern-js/plugin-docsite/cli" },
36255
36236
  "@modern-js/plugin-express": {
36256
36237
  cli: "@modern-js/plugin-express/cli",
36257
36238
  server: "@modern-js/plugin-express"
@@ -36269,7 +36250,6 @@ var require_constants = __commonJSMin((exports) => {
36269
36250
  server: "@modern-js/plugin-nest/server"
36270
36251
  },
36271
36252
  "@modern-js/plugin-unbundle": { cli: "@modern-js/plugin-unbundle" },
36272
- "@modern-js/plugin-server-build": { cli: "@modern-js/plugin-server-build" },
36273
36253
  "@modern-js/plugin-server": {
36274
36254
  cli: "@modern-js/plugin-server/cli",
36275
36255
  server: "@modern-js/plugin-server/server"
@@ -36277,26 +36257,12 @@ var require_constants = __commonJSMin((exports) => {
36277
36257
  "@modern-js/plugin-garfish": {
36278
36258
  cli: "@modern-js/plugin-garfish/cli"
36279
36259
  },
36280
- "@modern-js/plugin-jarvis": { cli: "@modern-js/plugin-jarvis/cli" },
36281
36260
  "@modern-js/plugin-tailwindcss": { cli: "@modern-js/plugin-tailwindcss/cli" },
36282
- "@modern-js/plugin-lambda-fc": { cli: "@modern-js/plugin-lambda-fc/cli" },
36283
- "@modern-js/plugin-lambda-scf": { cli: "@modern-js/plugin-lambda-scf/cli" },
36284
- "@modern-js/plugin-cdn-oss": { cli: "@modern-js/plugin-cdn-oss/cli" },
36285
- "@modern-js/plugin-cdn-cos": { cli: "@modern-js/plugin-cdn-cos/cli" },
36286
- "@modern-js/plugin-static-hosting": {
36287
- cli: "@modern-js/plugin-static-hosting/cli"
36288
- },
36289
36261
  "@modern-js/plugin-polyfill": {
36290
36262
  cli: "@modern-js/plugin-polyfill/cli",
36291
36263
  server: "@modern-js/plugin-polyfill"
36292
36264
  },
36293
- "@modern-js/plugin-multiprocess": {
36294
- cli: "@modern-js/plugin-multiprocess/cli"
36295
- },
36296
- "@modern-js/plugin-nocode": { cli: "@modern-js/plugin-nocode/cli" },
36297
- "@modern-js/plugin-design-token": {
36298
- cli: "@modern-js/plugin-design-token/cli"
36299
- }
36265
+ "@modern-js/plugin-nocode": { cli: "@modern-js/plugin-nocode/cli" }
36300
36266
  };
36301
36267
  exports.PLUGIN_SCHEMAS = {
36302
36268
  "@modern-js/runtime": [
@@ -37284,8 +37250,8 @@ var require_analyzeProject = __commonJSMin((exports) => {
37284
37250
  exports.isApiOnly = void 0;
37285
37251
  var path2 = __importStar(__require("path"));
37286
37252
  var compiled_1 = require_compiled();
37287
- var isApiOnly = async (appDirectory) => {
37288
- const srcDir = path2.join(appDirectory, "src");
37253
+ var isApiOnly = async (appDirectory, entryDir) => {
37254
+ const srcDir = path2.join(appDirectory, entryDir !== null && entryDir !== void 0 ? entryDir : "src");
37289
37255
  const existSrc = await compiled_1.fs.pathExists(srcDir);
37290
37256
  const options2 = (0, compiled_1.minimist)(process.argv.slice(2));
37291
37257
  return !existSrc || Boolean(options2["api-only"]);
@@ -37299,7 +37265,18 @@ var require_chainId = __commonJSMin((exports) => {
37299
37265
  exports.CHAIN_ID = {
37300
37266
  RULE: {
37301
37267
  MJS: "mjs",
37302
- LOADERS: "loaders"
37268
+ LOADERS: "loaders",
37269
+ FONT: "font",
37270
+ IMAGE: "image",
37271
+ MEDIA: "media",
37272
+ JS: "js",
37273
+ TS: "ts",
37274
+ CSS: "css",
37275
+ LESS: "less",
37276
+ SASS: "sass",
37277
+ SVG: "svg",
37278
+ SVG_INLINE: "svg-inline",
37279
+ SVG_URL: "svg-url"
37303
37280
  },
37304
37281
  ONE_OF: {
37305
37282
  JS: "js",
@@ -37325,6 +37302,8 @@ var require_chainId = __commonJSMin((exports) => {
37325
37302
  USE: {
37326
37303
  TS: "ts",
37327
37304
  CSS: "css",
37305
+ SASS: "sass",
37306
+ LESS: "less",
37328
37307
  URL: "url",
37329
37308
  FILE: "file",
37330
37309
  SVGR: "svgr",
@@ -37353,6 +37332,7 @@ var require_chainId = __commonJSMin((exports) => {
37353
37332
  INLINE_HTML: "inline-html",
37354
37333
  BUNDLE_ANALYZER: "bundle-analyze",
37355
37334
  BOTTOM_TEMPLATE: "bottom-template",
37335
+ HTML_CROSS_ORIGIN: "html-cross-origin",
37356
37336
  MINI_CSS_EXTRACT: "mini-css-extract",
37357
37337
  REACT_FAST_REFRESH: "react-fast-refresh",
37358
37338
  NODE_POLYFILL_PROVIDE: "node-polyfill-provide"
@@ -37368,6 +37348,32 @@ var require_chainId = __commonJSMin((exports) => {
37368
37348
  }
37369
37349
  };
37370
37350
  });
37351
+ var require_reactVersion = __commonJSMin((exports) => {
37352
+ "use strict";
37353
+ var __importDefault = exports && exports.__importDefault || function(mod) {
37354
+ return mod && mod.__esModule ? mod : { "default": mod };
37355
+ };
37356
+ Object.defineProperty(exports, "__esModule", { value: true });
37357
+ exports.isReact18 = void 0;
37358
+ var path_1 = __importDefault(__require("path"));
37359
+ var compiled_1 = require_compiled();
37360
+ var isReact18 = (cwd) => {
37361
+ const pkgPath = path_1.default.join(cwd, "package.json");
37362
+ if (!compiled_1.fs.existsSync(pkgPath)) {
37363
+ return false;
37364
+ }
37365
+ const pkgInfo = JSON.parse(compiled_1.fs.readFileSync(pkgPath, "utf8"));
37366
+ const deps = {
37367
+ ...pkgInfo.devDependencies,
37368
+ ...pkgInfo.dependencies
37369
+ };
37370
+ if (typeof deps.react !== "string") {
37371
+ return false;
37372
+ }
37373
+ return compiled_1.semver.satisfies(compiled_1.semver.minVersion(deps.react), ">=18.0.0");
37374
+ };
37375
+ exports.isReact18 = isReact18;
37376
+ });
37371
37377
  var require_dist = __commonJSMin((exports) => {
37372
37378
  "use strict";
37373
37379
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
@@ -37427,6 +37433,7 @@ var require_dist = __commonJSMin((exports) => {
37427
37433
  __exportStar(require_tryResolve(), exports);
37428
37434
  __exportStar(require_analyzeProject(), exports);
37429
37435
  __exportStar(require_chainId(), exports);
37436
+ __exportStar(require_reactVersion(), exports);
37430
37437
  });
37431
37438
  var require_esprima = __commonJSMin((exports, module2) => {
37432
37439
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -45796,6 +45803,7 @@ var require_generator = __commonJSMin((exports) => {
45796
45803
  this.materialsManager = materialsManager;
45797
45804
  this.outputPath = outputPath;
45798
45805
  this.event = new _events.EventEmitter();
45806
+ this.event.setMaxListeners(15);
45799
45807
  this._context = _objectSpread({
45800
45808
  materials: {},
45801
45809
  config: {},
@@ -100655,7 +100663,6 @@ var ZH_LOCALE = {
100655
100663
  mwa_storybook: "\u542F\u7528\u300CVisual Testing (Storybook)\u300D\u6A21\u5F0F",
100656
100664
  ssg: "\u542F\u7528\u300CSSG\u300D\u529F\u80FD",
100657
100665
  polyfill: "\u542F\u7528\u300C\u57FA\u4E8E UA \u7684 Polyfill\u300D\u529F\u80FD",
100658
- deploy: "\u542F\u7528\u300C\u90E8\u7F72\u300D\u529F\u80FD",
100659
100666
  proxy: "\u542F\u7528\u300C\u5168\u5C40\u4EE3\u7406\u300D"
100660
100667
  },
100661
100668
  element: {
@@ -100683,22 +100690,15 @@ var ZH_LOCALE = {
100683
100690
  no: "\u4E0D\u9700\u8981",
100684
100691
  electron: "Electron"
100685
100692
  },
100686
- needModifyConfig: {
100687
- self: "\u662F\u5426\u9700\u8981\u8C03\u6574\u9ED8\u8BA4\u914D\u7F6E?",
100688
- enableLess: "\u662F\u5426\u542F\u7528 Less \u652F\u6301?",
100689
- enableSass: "\u662F\u5426\u542F\u7528 Sass \u652F\u6301?"
100690
- },
100691
100693
  entry: {
100692
100694
  name: "\u8BF7\u586B\u5199\u5165\u53E3\u540D\u79F0",
100693
100695
  no_empty: "\u5165\u53E3\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\uFF01",
100694
100696
  no_pages: '\u5165\u53E3\u540D\u79F0\u4E0D\u652F\u6301 "pages"\uFF01',
100695
100697
  needModifyConfig: "\u662F\u5426\u9700\u8981\u8C03\u6574\u9ED8\u8BA4\u914D\u7F6E?",
100696
- disableStateManagement: "\u662F\u5426\u5173\u95ED\u300C\u5E94\u7528\u72B6\u6001\u7BA1\u7406\u300D\u529F\u80FD?",
100697
100698
  clientRoute: {
100698
100699
  self: "\u8BF7\u9009\u62E9\u5BA2\u6237\u7AEF\u8DEF\u7531\u65B9\u5F0F",
100699
- selfControlRoute: "\u542F\u7528\u81EA\u63A7\u8DEF\u7531",
100700
- conventionalRoute: "\u542F\u7528\u7EA6\u5B9A\u5F0F\u8DEF\u7531",
100701
- no: "\u4E0D\u542F\u7528"
100700
+ selfControlRoute: "\u81EA\u63A7\u8DEF\u7531",
100701
+ conventionalRoute: "\u7EA6\u5B9A\u5F0F\u8DEF\u7531"
100702
100702
  }
100703
100703
  },
100704
100704
  packageName: {
@@ -100724,23 +100724,6 @@ var ZH_LOCALE = {
100724
100724
  func: "\u51FD\u6570\u6A21\u5F0F",
100725
100725
  framework: "\u6846\u67B6\u6A21\u5F0F"
100726
100726
  }
100727
- },
100728
- deploy: {
100729
- cloud: {
100730
- self: "\u9ED8\u8BA4\u4F7F\u7528\u6846\u67B6\u5185\u7F6E\u7684\u4EA7\u54C1\u7EA7 Web \u670D\u52A1\u5668\uFF0C\u662F\u5426\u8C03\u6574\uFF1F"
100731
- },
100732
- cdn: {
100733
- self: "\u8BF7\u9009\u62E9 CDN \u5E73\u53F0",
100734
- oss: "\u963F\u91CC\u4E91 OSS",
100735
- cos: "\u817E\u8BAF\u4E91 COS",
100736
- no: "\u4E0D\u4F7F\u7528 CDN"
100737
- },
100738
- lambda: {
100739
- self: "\u8BF7\u9009\u62E9\u4E91\u51FD\u6570\u5E73\u53F0",
100740
- fc: "\u963F\u91CC\u4E91 FC",
100741
- scf: "\u817E\u8BAF\u4E91 SCF",
100742
- no: "\u4E0D\u4F7F\u7528\u4E91\u51FD\u6570\u90E8\u7F72"
100743
- }
100744
100727
  }
100745
100728
  };
100746
100729
  var EN_LOCALE = {
@@ -100782,7 +100765,6 @@ var EN_LOCALE = {
100782
100765
  mwa_storybook: "Enable Visual Testing (Storybook)",
100783
100766
  ssg: "Enable SSG",
100784
100767
  polyfill: "Enable UA-based Polyfill Feature",
100785
- deploy: "Enable Deploy",
100786
100768
  proxy: "Enable Global Proxy"
100787
100769
  },
100788
100770
  element: {
@@ -100820,21 +100802,15 @@ var EN_LOCALE = {
100820
100802
  no: "Not Enabled",
100821
100803
  electron: "Electron"
100822
100804
  },
100823
- needModifyConfig: {
100824
- self: "Modify the Default Configuration?",
100825
- enableLess: "Enable Less?",
100826
- enableSass: "Enable Sass?"
100827
- },
100828
100805
  entry: {
100829
100806
  name: "Entry name",
100830
100807
  no_empty: "The entry name cannot be empty!",
100831
100808
  no_pages: 'The entry name cannot be "pages"!',
100832
- disableStateManagement: "Disable App State Management?",
100809
+ needModifyConfig: "Modify the Default Configuration?",
100833
100810
  clientRoute: {
100834
100811
  self: "Client Routing",
100835
- selfControlRoute: "Enable Self Control Route",
100836
- conventionalRoute: "Enable Conventional Route",
100837
- no: "Not Enabled"
100812
+ selfControlRoute: "Self Control Route",
100813
+ conventionalRoute: "Conventional Route"
100838
100814
  }
100839
100815
  },
100840
100816
  framework: {
@@ -100850,23 +100826,6 @@ var EN_LOCALE = {
100850
100826
  func: "Function",
100851
100827
  framework: "Framework"
100852
100828
  }
100853
- },
100854
- deploy: {
100855
- cloud: {
100856
- self: "Modify the default Web Server?"
100857
- },
100858
- cdn: {
100859
- self: "Please select the cdn platform you want to use",
100860
- oss: "Aliyun OSS",
100861
- cos: "Tencent COS",
100862
- no: "Not Enabled"
100863
- },
100864
- lambda: {
100865
- self: "Please select the lambda you want to use",
100866
- fc: "Aliyun FC",
100867
- scf: "Tencent SCF",
100868
- no: "Not Enabled"
100869
- }
100870
100829
  }
100871
100830
  };
100872
100831
  var i18n = new I18n2();
@@ -100878,6 +100837,7 @@ init_toConsumableArray();
100878
100837
  init_defineProperty();
100879
100838
  var _SolutionText;
100880
100839
  var _SubSolutionText;
100840
+ var _SolutionToolsMap;
100881
100841
  var _SolutionGenerator;
100882
100842
  var _SubSolutionGenerator;
100883
100843
  var Solution;
@@ -100909,6 +100869,7 @@ var SubSolutionText = (_SubSolutionText = {}, _defineProperty(_SubSolutionText,
100909
100869
  }), _defineProperty(_SubSolutionText, SubSolution.InnerModule, function() {
100910
100870
  return i18n.t(localeKeys.sub_solution.inner_module);
100911
100871
  }), _SubSolutionText);
100872
+ var SolutionToolsMap = (_SolutionToolsMap = {}, _defineProperty(_SolutionToolsMap, Solution.MWA, "@modern-js/app-tools"), _defineProperty(_SolutionToolsMap, Solution.Module, "@modern-js/module-tools"), _defineProperty(_SolutionToolsMap, Solution.Monorepo, "@modern-js/monorepo-tools"), _SolutionToolsMap);
100912
100873
  var SolutionGenerator = (_SolutionGenerator = {}, _defineProperty(_SolutionGenerator, Solution.MWA, "@modern-js/mwa-generator"), _defineProperty(_SolutionGenerator, Solution.Module, "@modern-js/module-generator"), _defineProperty(_SolutionGenerator, Solution.Monorepo, "@modern-js/monorepo-generator"), _SolutionGenerator);
100913
100874
  var SubSolutionGenerator = (_SubSolutionGenerator = {}, _defineProperty(_SubSolutionGenerator, SubSolution.MWA, "@modern-js/mwa-generator"), _defineProperty(_SubSolutionGenerator, SubSolution.MWATest, "@modern-js/mwa-generator"), _defineProperty(_SubSolutionGenerator, SubSolution.Module, "@modern-js/module-generator"), _defineProperty(_SubSolutionGenerator, SubSolution.InnerModule, "@modern-js/module-generator"), _SubSolutionGenerator);
100914
100875
  var DependenceGenerator = "@modern-js/dependence-generator";
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.2.1",
14
+ "version": "2.3.3",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "main": "./dist/index.js",
17
17
  "files": [
@@ -20,18 +20,18 @@
20
20
  ],
21
21
  "devDependencies": {
22
22
  "@babel/runtime": "^7.18.0",
23
- "@modern-js/codesmith": "^1.4.0",
24
- "@modern-js/codesmith-api-app": "^1.3.0",
25
- "@modern-js/generator-common": "2.2.1",
26
- "@modern-js/generator-utils": "2.2.1",
27
- "@modern-js/dependence-generator": "2.2.1",
28
- "@modern-js/codesmith-api-json": "^1.3.0",
23
+ "@modern-js/codesmith": "^1.5.0",
24
+ "@modern-js/codesmith-api-app": "^1.5.0",
25
+ "@modern-js/codesmith-api-json": "^1.5.0",
26
+ "@modern-js/dependence-generator": "2.3.3",
27
+ "@modern-js/generator-common": "2.3.3",
28
+ "@modern-js/generator-utils": "2.3.3",
29
+ "@scripts/build": "1.18.0",
30
+ "@scripts/jest-config": "1.18.0",
29
31
  "@types/jest": "^27",
30
32
  "@types/node": "^14",
31
- "typescript": "^4",
32
- "@scripts/build": "1.15.0",
33
33
  "jest": "^27",
34
- "@scripts/jest-config": "1.15.0"
34
+ "typescript": "^4"
35
35
  },
36
36
  "sideEffects": false,
37
37
  "modernConfig": {