@modern-js/create 1.21.2 → 2.0.0-beta.0

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 +233 -165
  2. package/package.json +10 -35
package/dist/index.js CHANGED
@@ -34558,8 +34558,8 @@ ${stats.stack}` : "";
34558
34558
  }
34559
34559
  function formatWebpackMessages(json) {
34560
34560
  var _a, _b, _c;
34561
- const formattedErrors = (_a = json.errors) === null || _a === void 0 ? void 0 : _a.map(formatMessage);
34562
- const formattedWarnings = (_b = json.warnings) === null || _b === void 0 ? void 0 : _b.map(formatMessage);
34561
+ const formattedErrors = (_a = json === null || json === void 0 ? void 0 : json.errors) === null || _a === void 0 ? void 0 : _a.map(formatMessage);
34562
+ const formattedWarnings = (_b = json === null || json === void 0 ? void 0 : json.warnings) === null || _b === void 0 ? void 0 : _b.map(formatMessage);
34563
34563
  const result = {
34564
34564
  errors: formattedErrors || [],
34565
34565
  warnings: formattedWarnings || []
@@ -34941,9 +34941,16 @@ var require_is = __commonJSMin((exports) => {
34941
34941
  exports.isFastRefresh = exports.isUseSSRBundle = exports.isSSR = exports.isEmpty = exports.isTypescript = exports.isDepExists = void 0;
34942
34942
  var fs_1 = __importDefault(__require("fs"));
34943
34943
  var path_1 = __importDefault(__require("path"));
34944
+ var debug_1 = require_debug2();
34944
34945
  var node_env_1 = require_node_env();
34946
+ var debug = (0, debug_1.createDebugger)("judge-depExists");
34945
34947
  var isDepExists = (appDirectory, name4) => {
34946
- const json = __require(path_1.default.resolve(appDirectory, "./package.json"));
34948
+ const pkgPath = path_1.default.resolve(appDirectory, "./package.json");
34949
+ if (!fs_1.default.existsSync(pkgPath)) {
34950
+ debug(`can't find package.json under: %s`, appDirectory);
34951
+ return false;
34952
+ }
34953
+ const json = __require(pkgPath);
34947
34954
  const { dependencies: dependencies2 = {}, devDependencies: devDependencies2 = {} } = json;
34948
34955
  return dependencies2.hasOwnProperty(name4) || devDependencies2.hasOwnProperty(name4);
34949
34956
  };
@@ -34986,17 +34993,23 @@ var require_compatRequire = __commonJSMin((exports) => {
34986
34993
  Object.defineProperty(exports, "__esModule", { value: true });
34987
34994
  exports.cleanRequireCache = exports.requireExistModule = exports.compatRequire = void 0;
34988
34995
  var findExists_1 = require_findExists();
34989
- var compatRequire = (filePath) => {
34996
+ var compatRequire = (filePath, interop = true) => {
34990
34997
  const mod = __require(filePath);
34991
- return (mod === null || mod === void 0 ? void 0 : mod.__esModule) ? mod.default : mod;
34998
+ const rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
34999
+ return rtnESMDefault ? mod.default : mod;
34992
35000
  };
34993
35001
  exports.compatRequire = compatRequire;
34994
- var requireExistModule = (filename, extensions = [".ts", ".js"]) => {
34995
- const exist = (0, findExists_1.findExists)(extensions.map((ext) => `${filename}${ext}`));
35002
+ var requireExistModule = (filename, opt) => {
35003
+ const final = {
35004
+ extensions: [".ts", ".js"],
35005
+ interop: true,
35006
+ ...opt
35007
+ };
35008
+ const exist = (0, findExists_1.findExists)(final.extensions.map((ext) => `${filename}${ext}`));
34996
35009
  if (!exist) {
34997
35010
  return null;
34998
35011
  }
34999
- return (0, exports.compatRequire)(exist);
35012
+ return (0, exports.compatRequire)(exist, final.interop);
35000
35013
  };
35001
35014
  exports.requireExistModule = requireExistModule;
35002
35015
  var cleanRequireCache = (filelist) => {
@@ -35009,7 +35022,7 @@ var require_compatRequire = __commonJSMin((exports) => {
35009
35022
  var require_constants = __commonJSMin((exports) => {
35010
35023
  "use strict";
35011
35024
  Object.defineProperty(exports, "__esModule", { value: true });
35012
- exports.PLUGIN_SCHEMAS = exports.INTERNAL_PLUGINS = exports.DEFAULT_SERVER_CONFIG = exports.OUTPUT_CONFIG_FILE = exports.CONFIG_FILE_EXTENSIONS = exports.CONFIG_CACHE_DIR = exports.SHARED_DIR = exports.SERVER_DIR = exports.API_DIR = exports.LOADABLE_STATS_FILE = exports.SERVER_RENDER_FUNCTION_NAME = exports.ENTRY_NAME_PATTERN = exports.SERVER_BUNDLE_DIRECTORY = exports.LAUNCH_EDITOR_ENDPOINT = exports.MAIN_ENTRY_NAME = exports.ROUTE_SPEC_FILE = exports.HMR_SOCK_PATH = void 0;
35025
+ exports.PLUGIN_SCHEMAS = exports.INTERNAL_SERVER_PLUGINS = exports.INTERNAL_CLI_PLUGINS = exports.DEFAULT_SERVER_CONFIG = exports.OUTPUT_CONFIG_FILE = exports.CONFIG_FILE_EXTENSIONS = exports.CONFIG_CACHE_DIR = exports.SHARED_DIR = exports.SERVER_DIR = exports.API_DIR = exports.LOADABLE_STATS_FILE = exports.SERVER_RENDER_FUNCTION_NAME = exports.ENTRY_NAME_PATTERN = exports.SERVER_BUNDLE_DIRECTORY = exports.LAUNCH_EDITOR_ENDPOINT = exports.MAIN_ENTRY_NAME = exports.ROUTE_SPEC_FILE = exports.HMR_SOCK_PATH = void 0;
35013
35026
  exports.HMR_SOCK_PATH = "/webpack-hmr";
35014
35027
  exports.ROUTE_SPEC_FILE = "route.json";
35015
35028
  exports.MAIN_ENTRY_NAME = "main";
@@ -35025,53 +35038,36 @@ var require_constants = __commonJSMin((exports) => {
35025
35038
  exports.CONFIG_FILE_EXTENSIONS = [".js", ".ts", ".ejs", ".mjs"];
35026
35039
  exports.OUTPUT_CONFIG_FILE = "modern.config.json";
35027
35040
  exports.DEFAULT_SERVER_CONFIG = "modern.server-runtime.config";
35028
- exports.INTERNAL_PLUGINS = {
35029
- "@modern-js/app-tools": { cli: "@modern-js/app-tools/cli" },
35030
- "@modern-js/monorepo-tools": { cli: "@modern-js/monorepo-tools/cli" },
35031
- "@modern-js/module-tools": { cli: "@modern-js/module-tools/cli" },
35032
- "@modern-js/runtime": { cli: "@modern-js/runtime/cli" },
35033
- "@modern-js/plugin-less": { cli: "@modern-js/plugin-less/cli" },
35034
- "@modern-js/plugin-sass": { cli: "@modern-js/plugin-sass/cli" },
35035
- "@modern-js/plugin-esbuild": { cli: "@modern-js/plugin-esbuild/cli" },
35036
- "@modern-js/plugin-proxy": { cli: "@modern-js/plugin-proxy/cli" },
35037
- "@modern-js/plugin-ssg": { cli: "@modern-js/plugin-ssg/cli" },
35038
- "@modern-js/plugin-bff": {
35039
- cli: "@modern-js/plugin-bff/cli",
35040
- server: "@modern-js/plugin-bff/server"
35041
- },
35042
- "@modern-js/plugin-electron": { cli: "@modern-js/plugin-electron/cli" },
35043
- "@modern-js/plugin-testing": { cli: "@modern-js/plugin-testing/cli" },
35044
- "@modern-js/plugin-storybook": { cli: "@modern-js/plugin-storybook/cli" },
35045
- "@modern-js/plugin-express": {
35046
- cli: "@modern-js/plugin-express/cli",
35047
- server: "@modern-js/plugin-express"
35048
- },
35049
- "@modern-js/plugin-egg": {
35050
- cli: "@modern-js/plugin-egg/cli",
35051
- server: "@modern-js/plugin-egg"
35052
- },
35053
- "@modern-js/plugin-koa": {
35054
- cli: "@modern-js/plugin-koa/cli",
35055
- server: "@modern-js/plugin-koa"
35056
- },
35057
- "@modern-js/plugin-nest": {
35058
- cli: "@modern-js/plugin-nest/cli",
35059
- server: "@modern-js/plugin-nest/server"
35060
- },
35061
- "@modern-js/plugin-unbundle": { cli: "@modern-js/plugin-unbundle" },
35062
- "@modern-js/plugin-server": {
35063
- cli: "@modern-js/plugin-server/cli",
35064
- server: "@modern-js/plugin-server/server"
35065
- },
35066
- "@modern-js/plugin-garfish": {
35067
- cli: "@modern-js/plugin-garfish/cli"
35068
- },
35069
- "@modern-js/plugin-tailwindcss": { cli: "@modern-js/plugin-tailwindcss/cli" },
35070
- "@modern-js/plugin-polyfill": {
35071
- cli: "@modern-js/plugin-polyfill/cli",
35072
- server: "@modern-js/plugin-polyfill"
35073
- },
35074
- "@modern-js/plugin-nocode": { cli: "@modern-js/plugin-nocode/cli" }
35041
+ exports.INTERNAL_CLI_PLUGINS = {
35042
+ "@modern-js/app-tools": "@modern-js/app-tools/cli",
35043
+ "@modern-js/monorepo-tools": "@modern-js/monorepo-tools/cli",
35044
+ "@modern-js/module-tools": "@modern-js/module-tools/cli",
35045
+ "@modern-js/module-tools-v2": "@modern-js/module-tools-v2",
35046
+ "@modern-js/runtime": "@modern-js/runtime/cli",
35047
+ "@modern-js/plugin-proxy": "@modern-js/plugin-proxy/cli",
35048
+ "@modern-js/plugin-ssg": "@modern-js/plugin-ssg/cli",
35049
+ "@modern-js/plugin-bff": "@modern-js/plugin-bff/cli",
35050
+ "@modern-js/plugin-testing": "@modern-js/plugin-testing/cli",
35051
+ "@modern-js/plugin-storybook": "@modern-js/plugin-storybook/cli",
35052
+ "@modern-js/plugin-express": "@modern-js/plugin-express/cli",
35053
+ "@modern-js/plugin-egg": "@modern-js/plugin-egg/cli",
35054
+ "@modern-js/plugin-koa": "@modern-js/plugin-koa/cli",
35055
+ "@modern-js/plugin-nest": "@modern-js/plugin-nest/cli",
35056
+ "@modern-js/plugin-server": "@modern-js/plugin-server/cli",
35057
+ "@modern-js/plugin-garfish": "@modern-js/plugin-garfish/cli",
35058
+ "@modern-js/plugin-tailwindcss": "@modern-js/plugin-tailwindcss/cli",
35059
+ "@modern-js/plugin-polyfill": "@modern-js/plugin-polyfill/cli",
35060
+ "@modern-js/plugin-nocode": "@modern-js/plugin-nocode/cli",
35061
+ "@modern-js/plugin-router-legacy": "@modern-js/plugin-router-legacy/cli"
35062
+ };
35063
+ exports.INTERNAL_SERVER_PLUGINS = {
35064
+ "@modern-js/plugin-bff": "@modern-js/plugin-bff/server",
35065
+ "@modern-js/plugin-express": "@modern-js/plugin-express",
35066
+ "@modern-js/plugin-egg": "@modern-js/plugin-egg",
35067
+ "@modern-js/plugin-koa": "@modern-js/plugin-koa",
35068
+ "@modern-js/plugin-nest": "@modern-js/plugin-nest/server",
35069
+ "@modern-js/plugin-server": "@modern-js/plugin-server/server",
35070
+ "@modern-js/plugin-polyfill": "@modern-js/plugin-polyfill"
35075
35071
  };
35076
35072
  exports.PLUGIN_SCHEMAS = {
35077
35073
  "@modern-js/runtime": [
@@ -35108,24 +35104,6 @@ var require_constants = __commonJSMin((exports) => {
35108
35104
  }
35109
35105
  }
35110
35106
  ],
35111
- "@modern-js/plugin-esbuild": [
35112
- {
35113
- target: "tools.esbuild",
35114
- schema: { typeof: ["object"] }
35115
- }
35116
- ],
35117
- "@modern-js/plugin-less": [
35118
- {
35119
- target: "tools.less",
35120
- schema: { typeof: ["object", "function"] }
35121
- }
35122
- ],
35123
- "@modern-js/plugin-sass": [
35124
- {
35125
- target: "tools.sass",
35126
- schema: { typeof: ["object", "function"] }
35127
- }
35128
- ],
35129
35107
  "@modern-js/plugin-tailwindcss": [
35130
35108
  {
35131
35109
  target: "tools.tailwindcss",
@@ -35138,27 +35116,6 @@ var require_constants = __commonJSMin((exports) => {
35138
35116
  schema: { typeof: ["string", "object"] }
35139
35117
  }
35140
35118
  ],
35141
- "@modern-js/plugin-unbundle": [
35142
- {
35143
- target: "output.disableAutoImportStyle",
35144
- schema: { type: "boolean" }
35145
- },
35146
- {
35147
- target: "dev.unbundle",
35148
- schema: {
35149
- type: "object",
35150
- properties: {
35151
- ignore: {
35152
- type: ["string", "array"],
35153
- items: { type: "string" }
35154
- },
35155
- ignoreModuleCache: { type: "boolean" },
35156
- clearPdnCache: { type: "boolean" },
35157
- pdnHost: { type: "string" }
35158
- }
35159
- }
35160
- }
35161
- ],
35162
35119
  "@modern-js/plugin-ssg": [
35163
35120
  {
35164
35121
  target: "output.ssg",
@@ -35533,7 +35490,7 @@ var require_path = __commonJSMin((exports) => {
35533
35490
  return mod && mod.__esModule ? mod : { "default": mod };
35534
35491
  };
35535
35492
  Object.defineProperty(exports, "__esModule", { value: true });
35536
- exports.getTemplatePath = exports.normalizeToPosixPath = exports.normalizeOutputPath = exports.isRelativePath = exports.isPathString = void 0;
35493
+ exports.splitPathString = exports.getRealTemporaryDirectory = exports.upwardPaths = exports._joinPathParts = exports.compilePathMatcherRegExp = exports.getTemplatePath = exports.normalizeToPosixPath = exports.normalizeOutputPath = exports.isRelativePath = exports.isPathString = void 0;
35537
35494
  var path_1 = __importDefault(__require("path"));
35538
35495
  var os_1 = __importDefault(__require("os"));
35539
35496
  var fs_1 = __importDefault(__require("fs"));
@@ -35554,6 +35511,34 @@ var require_path = __commonJSMin((exports) => {
35554
35511
  return path_1.default.resolve(...parts);
35555
35512
  };
35556
35513
  exports.getTemplatePath = getTemplatePath;
35514
+ function compilePathMatcherRegExp(match) {
35515
+ if (typeof match !== "string") {
35516
+ return match;
35517
+ }
35518
+ const escaped = compiled_1.lodash.escapeRegExp(match);
35519
+ return new RegExp(`(?<=\\W|^)${escaped}(?=\\W|$)`);
35520
+ }
35521
+ exports.compilePathMatcherRegExp = compilePathMatcherRegExp;
35522
+ var _joinPathParts = (_part, i, parts) => (0, compiled_1.lodash)(parts).filter((part) => !["/", "\\"].includes(part)).tap((parts2) => parts2.unshift("")).slice(0, i + 2).join("/");
35523
+ exports._joinPathParts = _joinPathParts;
35524
+ function upwardPaths(start) {
35525
+ return (0, compiled_1.lodash)(start).split(/[/\\]/).filter(Boolean).map(exports._joinPathParts).reverse().push("/").value();
35526
+ }
35527
+ exports.upwardPaths = upwardPaths;
35528
+ function getRealTemporaryDirectory() {
35529
+ let ret = null;
35530
+ try {
35531
+ ret = os_1.default.tmpdir();
35532
+ ret = fs_1.default.realpathSync(ret);
35533
+ } catch {
35534
+ }
35535
+ return ret;
35536
+ }
35537
+ exports.getRealTemporaryDirectory = getRealTemporaryDirectory;
35538
+ function splitPathString(str) {
35539
+ return str.split(/[\\/]/);
35540
+ }
35541
+ exports.splitPathString = splitPathString;
35557
35542
  });
35558
35543
  var require_runtimeExports = __commonJSMin((exports) => {
35559
35544
  "use strict";
@@ -35617,6 +35602,52 @@ var require_readTsConfig = __commonJSMin((exports) => {
35617
35602
  };
35618
35603
  exports.readTsConfigByFile = readTsConfigByFile;
35619
35604
  });
35605
+ var require_pathSerializer = __commonJSMin((exports) => {
35606
+ "use strict";
35607
+ var __importDefault = exports && exports.__importDefault || function(mod) {
35608
+ return mod && mod.__esModule ? mod : { "default": mod };
35609
+ };
35610
+ Object.defineProperty(exports, "__esModule", { value: true });
35611
+ exports.createDefaultPathMatchers = exports.applyMatcherReplacement = exports.applyPathMatcher = exports.matchUpwardPathsAsUnknown = void 0;
35612
+ var os_1 = __importDefault(__require("os"));
35613
+ var lodash_1 = __importDefault(require_lodash2());
35614
+ var path_1 = require_path();
35615
+ var matchUpwardPathsAsUnknown = (p) => (0, lodash_1.default)((0, path_1.upwardPaths)((0, path_1.normalizeToPosixPath)(p))).map((match) => ({ match, mark: "unknown" })).slice(1, -1).value();
35616
+ exports.matchUpwardPathsAsUnknown = matchUpwardPathsAsUnknown;
35617
+ function applyPathMatcher(matcher, str, options3 = {}) {
35618
+ const regex = (0, path_1.compilePathMatcherRegExp)(matcher.match);
35619
+ const replacer = (substring, ...args) => {
35620
+ if (options3.minPartials && (0, path_1.splitPathString)(substring).length < options3.minPartials) {
35621
+ return substring;
35622
+ }
35623
+ const ret = typeof matcher.mark === "string" ? matcher.mark : matcher.mark(substring, ...args);
35624
+ return `<${lodash_1.default.snakeCase(ret).toUpperCase()}>`;
35625
+ };
35626
+ return str.replace(regex, replacer);
35627
+ }
35628
+ exports.applyPathMatcher = applyPathMatcher;
35629
+ function applyMatcherReplacement(matchers, str, options3 = {}) {
35630
+ return matchers.reduce((ret, matcher) => {
35631
+ return applyPathMatcher(matcher, ret, options3);
35632
+ }, str);
35633
+ }
35634
+ exports.applyMatcherReplacement = applyMatcherReplacement;
35635
+ var createDefaultPathMatchers = (root) => {
35636
+ const ret = [
35637
+ {
35638
+ match: /(?<=\/)(\.pnpm\/.+?\/node_modules)(?=\/)/,
35639
+ mark: "pnpmInner"
35640
+ }
35641
+ ];
35642
+ const tmpdir = (0, path_1.getRealTemporaryDirectory)();
35643
+ tmpdir && ret.push({ match: tmpdir, mark: "temp" });
35644
+ ret.push({ match: os_1.default.tmpdir(), mark: "temp" });
35645
+ ret.push({ match: os_1.default.homedir(), mark: "home" });
35646
+ ret.push(...(0, exports.matchUpwardPathsAsUnknown)(root));
35647
+ return ret;
35648
+ };
35649
+ exports.createDefaultPathMatchers = createDefaultPathMatchers;
35650
+ });
35620
35651
  var require_generateMetaTags = __commonJSMin((exports) => {
35621
35652
  "use strict";
35622
35653
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -35731,7 +35762,7 @@ var require_alias = __commonJSMin((exports) => {
35731
35762
  return mod && mod.__esModule ? mod : { "default": mod };
35732
35763
  };
35733
35764
  Object.defineProperty(exports, "__esModule", { value: true });
35734
- exports.getUserAlias = exports.getAlias = exports.validAlias = void 0;
35765
+ exports.getUserAlias = exports.getAliasConfig = exports.mergeAlias = exports.validAlias = void 0;
35735
35766
  var fs_1 = __importDefault(__require("fs"));
35736
35767
  var path_1 = __importDefault(__require("path"));
35737
35768
  var compiled_1 = require_compiled();
@@ -35753,33 +35784,33 @@ var require_alias = __commonJSMin((exports) => {
35753
35784
  return null;
35754
35785
  };
35755
35786
  exports.validAlias = validAlias;
35756
- var getAlias = (aliasOption, option) => {
35787
+ var mergeAlias = (alias) => (0, applyOptionsChain_1.applyOptionsChain)({}, alias);
35788
+ exports.mergeAlias = mergeAlias;
35789
+ var getAliasConfig = (aliasOption, option) => {
35757
35790
  var _a, _b;
35758
35791
  const isTsProject = fs_1.default.existsSync(option.tsconfigPath);
35759
- let aliasConfig;
35792
+ const alias = (0, exports.mergeAlias)(aliasOption);
35760
35793
  if (!isTsProject) {
35761
- aliasConfig = {
35794
+ return {
35762
35795
  absoluteBaseUrl: option.appDirectory,
35763
- paths: (0, applyOptionsChain_1.applyOptionsChain)({ "@": ["./src"] }, aliasOption),
35796
+ paths: alias,
35764
35797
  isTsPath: false,
35765
35798
  isTsProject
35766
35799
  };
35767
- } else {
35768
- const tsconfig = (0, readTsConfig_1.readTsConfigByFile)(option.tsconfigPath);
35769
- const baseUrl = (_a = tsconfig === null || tsconfig === void 0 ? void 0 : tsconfig.compilerOptions) === null || _a === void 0 ? void 0 : _a.baseUrl;
35770
- aliasConfig = {
35771
- absoluteBaseUrl: baseUrl ? path_1.default.join(option.appDirectory, baseUrl) : option.appDirectory,
35772
- paths: {
35773
- ...aliasOption || {},
35774
- ...(_b = tsconfig === null || tsconfig === void 0 ? void 0 : tsconfig.compilerOptions) === null || _b === void 0 ? void 0 : _b.paths
35775
- },
35776
- isTsPath: true,
35777
- isTsProject
35778
- };
35779
35800
  }
35780
- return aliasConfig;
35801
+ const tsconfig = (0, readTsConfig_1.readTsConfigByFile)(option.tsconfigPath);
35802
+ const baseUrl = (_a = tsconfig === null || tsconfig === void 0 ? void 0 : tsconfig.compilerOptions) === null || _a === void 0 ? void 0 : _a.baseUrl;
35803
+ return {
35804
+ absoluteBaseUrl: baseUrl ? path_1.default.join(option.appDirectory, baseUrl) : option.appDirectory,
35805
+ paths: {
35806
+ ...alias,
35807
+ ...(_b = tsconfig === null || tsconfig === void 0 ? void 0 : tsconfig.compilerOptions) === null || _b === void 0 ? void 0 : _b.paths
35808
+ },
35809
+ isTsPath: true,
35810
+ isTsProject
35811
+ };
35781
35812
  };
35782
- exports.getAlias = getAlias;
35813
+ exports.getAliasConfig = getAliasConfig;
35783
35814
  var getUserAlias = (alias = {}) => Object.keys(alias).reduce((o, k) => {
35784
35815
  if (Array.isArray(alias[k])) {
35785
35816
  o[k] = alias[k];
@@ -36103,7 +36134,8 @@ var require_chainId = __commonJSMin((exports) => {
36103
36134
  SVG: "svg",
36104
36135
  PUG: "pug",
36105
36136
  TOML: "toml",
36106
- YAML: "yaml"
36137
+ YAML: "yaml",
36138
+ JS_BFF_API: "js-bff-api"
36107
36139
  },
36108
36140
  ONE_OF: {
36109
36141
  JS: "js",
@@ -36141,9 +36173,11 @@ var require_chainId = __commonJSMin((exports) => {
36141
36173
  HTML: "html",
36142
36174
  BABEL: "babel",
36143
36175
  ESBUILD: "esbuild",
36176
+ SWC: "swc",
36144
36177
  STYLE: "style-loader",
36145
36178
  POSTCSS: "postcss",
36146
36179
  MARKDOWN: "markdown",
36180
+ IGNORE_CSS: "ignore-css",
36147
36181
  CSS_MODULES_TS: "css-modules-typescript",
36148
36182
  MINI_CSS_EXTRACT: "mini-css-extract"
36149
36183
  },
@@ -36169,12 +36203,14 @@ var require_chainId = __commonJSMin((exports) => {
36169
36203
  NODE_POLYFILL_PROVIDE: "node-polyfill-provide",
36170
36204
  SUBRESOURCE_INTEGRITY: "subresource-integrity",
36171
36205
  ASSETS_RETRY: "ASSETS_RETRY",
36172
- AUTO_SET_ROOT_SIZE: "auto-set-root-size"
36206
+ AUTO_SET_ROOT_SIZE: "auto-set-root-size",
36207
+ HTML_ASYNC_CHUNK: "html-async-chunk"
36173
36208
  },
36174
36209
  MINIMIZER: {
36175
36210
  JS: "js",
36176
36211
  CSS: "css",
36177
- ESBUILD: "js-css"
36212
+ ESBUILD: "js-css",
36213
+ SWC: "swc"
36178
36214
  },
36179
36215
  RESOLVE_PLUGIN: {
36180
36216
  MODULE_SCOPE: "module-scope",
@@ -36213,6 +36249,53 @@ var require_version = __commonJSMin((exports) => {
36213
36249
  };
36214
36250
  exports.isReact18 = isReact18;
36215
36251
  });
36252
+ var require_plugin = __commonJSMin((exports) => {
36253
+ "use strict";
36254
+ Object.defineProperty(exports, "__esModule", { value: true });
36255
+ exports.getInternalPlugins = void 0;
36256
+ var constants_1 = require_constants();
36257
+ var is_1 = require_is();
36258
+ function getInternalPlugins(appDirectory, internalPlugins = constants_1.INTERNAL_CLI_PLUGINS) {
36259
+ return [
36260
+ ...Object.keys(internalPlugins).filter((name4) => {
36261
+ const config = internalPlugins[name4];
36262
+ if (typeof config !== "string" && config.forced === true) {
36263
+ return true;
36264
+ }
36265
+ return (0, is_1.isDepExists)(appDirectory, name4);
36266
+ }).map((name4) => {
36267
+ const config = internalPlugins[name4];
36268
+ if (typeof config !== "string") {
36269
+ return config.path;
36270
+ } else {
36271
+ return config;
36272
+ }
36273
+ })
36274
+ ];
36275
+ }
36276
+ exports.getInternalPlugins = getInternalPlugins;
36277
+ });
36278
+ var require_routes = __commonJSMin((exports) => {
36279
+ "use strict";
36280
+ var __importDefault = exports && exports.__importDefault || function(mod) {
36281
+ return mod && mod.__esModule ? mod : { "default": mod };
36282
+ };
36283
+ Object.defineProperty(exports, "__esModule", { value: true });
36284
+ exports.getRouteId = exports.getPathWithoutExt = void 0;
36285
+ var path_1 = __importDefault(__require("path"));
36286
+ var path_2 = require_path();
36287
+ var getPathWithoutExt = (filename) => {
36288
+ const extname = path_1.default.extname(filename);
36289
+ return filename.slice(0, -extname.length);
36290
+ };
36291
+ exports.getPathWithoutExt = getPathWithoutExt;
36292
+ var getRouteId = (componentPath, routesDir) => {
36293
+ const relativePath = (0, path_2.normalizeToPosixPath)(path_1.default.relative(routesDir, componentPath));
36294
+ const id = (0, exports.getPathWithoutExt)(relativePath);
36295
+ return id;
36296
+ };
36297
+ exports.getRouteId = getRouteId;
36298
+ });
36216
36299
  var require_dist = __commonJSMin((exports) => {
36217
36300
  "use strict";
36218
36301
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
@@ -36259,6 +36342,7 @@ var require_dist = __commonJSMin((exports) => {
36259
36342
  __exportStar(require_runtimeExports(), exports);
36260
36343
  __exportStar(require_readTsConfig(), exports);
36261
36344
  __exportStar(require_path(), exports);
36345
+ __exportStar(require_pathSerializer(), exports);
36262
36346
  __exportStar(require_generateMetaTags(), exports);
36263
36347
  __exportStar(require_prettyInstructions(), exports);
36264
36348
  __exportStar(require_alias(), exports);
@@ -36273,6 +36357,8 @@ var require_dist = __commonJSMin((exports) => {
36273
36357
  __exportStar(require_analyzeProject(), exports);
36274
36358
  __exportStar(require_chainId(), exports);
36275
36359
  __exportStar(require_version(), exports);
36360
+ __exportStar(require_plugin(), exports);
36361
+ __exportStar(require_routes(), exports);
36276
36362
  });
36277
36363
  var require_constants2 = __commonJSMin((exports) => {
36278
36364
  "use strict";
@@ -65414,7 +65500,6 @@ var require_logger2 = __commonJSMin((exports) => {
65414
65500
  Object.defineProperty(exports, "__esModule", { value: true });
65415
65501
  exports.logger = exports.Logger = void 0;
65416
65502
  var chalk_1 = __importDefault(require_chalk2());
65417
- var { grey, underline } = chalk_1.default;
65418
65503
  var LOG_LEVEL = {
65419
65504
  error: 0,
65420
65505
  warn: 1,
@@ -65429,13 +65514,18 @@ var require_logger2 = __commonJSMin((exports) => {
65429
65514
  level: "error"
65430
65515
  },
65431
65516
  info: {
65432
- color: "blue",
65517
+ color: "cyan",
65433
65518
  label: "info",
65434
65519
  level: "info"
65435
65520
  },
65521
+ success: {
65522
+ color: "green",
65523
+ label: "Success",
65524
+ level: "info"
65525
+ },
65436
65526
  warn: {
65437
65527
  color: "yellow",
65438
- label: "warning",
65528
+ label: "warn",
65439
65529
  level: "warn"
65440
65530
  },
65441
65531
  debug: {
@@ -65447,13 +65537,10 @@ var require_logger2 = __commonJSMin((exports) => {
65447
65537
  };
65448
65538
  var DEFAULT_CONFIG = {
65449
65539
  displayLabel: true,
65450
- underlineLabel: true,
65451
65540
  uppercaseLabel: false
65452
65541
  };
65453
65542
  var Logger2 = class {
65454
65543
  constructor(options3 = {}) {
65455
- this.logCount = 200;
65456
- this.history = {};
65457
65544
  this.level = options3.level || LOG_TYPES.log.level;
65458
65545
  this.config = { ...DEFAULT_CONFIG, ...options3.config || {} };
65459
65546
  this.types = {
@@ -65465,17 +65552,8 @@ var require_logger2 = __commonJSMin((exports) => {
65465
65552
  this[type] = this._log.bind(this, type);
65466
65553
  });
65467
65554
  }
65468
- retainLog(type, message) {
65469
- if (!this.history[type]) {
65470
- this.history[type] = [];
65471
- }
65472
- this.history[type].push(message);
65473
- while (this.history[type].length > this.logCount) {
65474
- this.history[type].shift();
65475
- }
65476
- }
65477
65555
  _log(type, message, ...args) {
65478
- if (message === void 0) {
65556
+ if (message === void 0 || message === null) {
65479
65557
  console.log();
65480
65558
  return;
65481
65559
  }
@@ -65487,28 +65565,21 @@ var require_logger2 = __commonJSMin((exports) => {
65487
65565
  const logType = this.types[type];
65488
65566
  if (this.config.displayLabel && logType.label) {
65489
65567
  label = this.config.uppercaseLabel ? logType.label.toUpperCase() : logType.label;
65490
- if (this.config.underlineLabel) {
65491
- label = underline(label).padEnd(this.longestUnderlinedLabel.length + 1);
65492
- } else {
65493
- label = label.padEnd(this.longestLabel.length + 1);
65494
- }
65495
- label = logType.color ? chalk_1.default[logType.color](label) : label;
65568
+ label = label.padEnd(this.longestLabel.length);
65569
+ label = chalk_1.default.bold(logType.color ? chalk_1.default[logType.color](label) : label);
65496
65570
  }
65497
65571
  if (message instanceof Error) {
65498
65572
  if (message.stack) {
65499
65573
  const [name4, ...rest] = message.stack.split("\n");
65500
65574
  text = `${name4}
65501
- ${grey(rest.join("\n"))}`;
65575
+ ${chalk_1.default.grey(rest.join("\n"))}`;
65502
65576
  } else {
65503
65577
  text = message.message;
65504
65578
  }
65505
65579
  } else {
65506
65580
  text = `${message}`;
65507
65581
  }
65508
- if (logType.level === "warn" || logType.level === "error") {
65509
- this.retainLog(type, text);
65510
- }
65511
- const log = label.length > 0 ? `${label} ${text}` : text;
65582
+ const log = label.length > 0 ? `${label} ${text}` : text;
65512
65583
  console.log(log, ...args);
65513
65584
  }
65514
65585
  getLongestLabel() {
@@ -65521,21 +65592,6 @@ ${grey(rest.join("\n"))}`;
65521
65592
  });
65522
65593
  return longestLabel;
65523
65594
  }
65524
- get longestUnderlinedLabel() {
65525
- return underline(this.longestLabel);
65526
- }
65527
- getRetainedLogs(type) {
65528
- return this.history[type] || [];
65529
- }
65530
- clearRetainedLogs(type) {
65531
- if (type) {
65532
- if (this.history[type]) {
65533
- this.history[type] = [];
65534
- }
65535
- } else {
65536
- this.history = {};
65537
- }
65538
- }
65539
65595
  };
65540
65596
  exports.Logger = Logger2;
65541
65597
  var logger = new Logger2();
@@ -66195,10 +66251,13 @@ var require_getPort2 = __commonJSMin((exports) => {
66195
66251
  var net_1 = __importDefault(__require("net"));
66196
66252
  var compiled_1 = require_compiled2();
66197
66253
  var logger_1 = require_logger2();
66198
- var getPort = async (port, tryLimits = 20) => {
66254
+ var getPort = async (port, { tryLimits = 20, strictPort = false } = {}) => {
66199
66255
  if (typeof port === "string") {
66200
66256
  port = parseInt(port, 10);
66201
66257
  }
66258
+ if (strictPort) {
66259
+ tryLimits = 1;
66260
+ }
66202
66261
  const original = port;
66203
66262
  let found = false;
66204
66263
  let attempts = 0;
@@ -66225,7 +66284,11 @@ var require_getPort2 = __commonJSMin((exports) => {
66225
66284
  }
66226
66285
  }
66227
66286
  if (port !== original) {
66228
- logger_1.logger.info(compiled_1.chalk.red(`Something is already running on port ${original}. ${compiled_1.chalk.yellow(`Use port ${port} instead.`)}`));
66287
+ if (strictPort) {
66288
+ throw new Error(`Port "${original}" is occupied, please choose another one.`);
66289
+ } else {
66290
+ logger_1.logger.info(`Something is already running on port ${original}. ${compiled_1.chalk.yellow(`Use port ${port} instead.`)}`);
66291
+ }
66229
66292
  }
66230
66293
  return port;
66231
66294
  };
@@ -67037,15 +67100,20 @@ var require_chainId2 = __commonJSMin((exports) => {
67037
67100
  }
67038
67101
  };
67039
67102
  });
67040
- var require_reactVersion = __commonJSMin((exports) => {
67103
+ var require_version2 = __commonJSMin((exports) => {
67041
67104
  "use strict";
67042
67105
  var __importDefault = exports && exports.__importDefault || function(mod) {
67043
67106
  return mod && mod.__esModule ? mod : { "default": mod };
67044
67107
  };
67045
67108
  Object.defineProperty(exports, "__esModule", { value: true });
67046
- exports.isReact18 = void 0;
67109
+ exports.isReact18 = exports.getPnpmVersion = void 0;
67047
67110
  var path_1 = __importDefault(__require("path"));
67048
67111
  var compiled_1 = require_compiled2();
67112
+ async function getPnpmVersion() {
67113
+ const { stdout } = await (0, compiled_1.execa)("pnpm", ["--version"]);
67114
+ return stdout;
67115
+ }
67116
+ exports.getPnpmVersion = getPnpmVersion;
67049
67117
  var isReact18 = (cwd) => {
67050
67118
  const pkgPath = path_1.default.join(cwd, "package.json");
67051
67119
  if (!compiled_1.fs.existsSync(pkgPath)) {
@@ -67122,7 +67190,7 @@ var require_dist2 = __commonJSMin((exports) => {
67122
67190
  __exportStar(require_tryResolve2(), exports);
67123
67191
  __exportStar(require_analyzeProject2(), exports);
67124
67192
  __exportStar(require_chainId2(), exports);
67125
- __exportStar(require_reactVersion(), exports);
67193
+ __exportStar(require_version2(), exports);
67126
67194
  });
67127
67195
  var require_logger3 = __commonJSMin((exports) => {
67128
67196
  "use strict";
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.21.2",
14
+ "version": "2.0.0-beta.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/index.js",
@@ -34,13 +34,13 @@
34
34
  },
35
35
  "devDependencies": {
36
36
  "@babel/runtime": "^7.18.0",
37
- "@modern-js/codesmith": "1.6.3",
38
- "@modern-js/generator-plugin-plugin": "2.4.7",
39
- "@modern-js/plugin-i18n": "1.21.2",
40
- "@modern-js/repo-generator": "2.4.7",
41
- "@modern-js/utils": "1.21.2",
42
- "@scripts/build": "1.21.2",
43
- "@scripts/jest-config": "1.21.2",
37
+ "@modern-js/codesmith": "2.0.0",
38
+ "@modern-js/generator-plugin-plugin": "3.0.0-beta.0",
39
+ "@modern-js/plugin-i18n": "2.0.0-beta.0",
40
+ "@modern-js/repo-generator": "3.0.0-beta.0",
41
+ "@modern-js/utils": "2.0.0-beta.0",
42
+ "@scripts/build": "2.0.0-beta.0",
43
+ "@scripts/jest-config": "2.0.0-beta.0",
44
44
  "@types/jest": "^27",
45
45
  "@types/node": "^14",
46
46
  "jest": "^27",
@@ -52,34 +52,9 @@
52
52
  "registry": "https://registry.npmjs.org/",
53
53
  "access": "public"
54
54
  },
55
- "wireit": {
56
- "build": {
57
- "command": "modern build",
58
- "files": [
59
- "src/**/*",
60
- "tsconfig.json",
61
- "package.json",
62
- "modern.config.js"
63
- ],
64
- "output": [
65
- "dist/**/*",
66
- "!dist/node/main.js"
67
- ]
68
- },
69
- "test": {
70
- "command": "jest --passWithNoTests",
71
- "files": [
72
- "src/**/*",
73
- "tsconfig.json",
74
- "package.json",
75
- "tests/**/*"
76
- ],
77
- "output": []
78
- }
79
- },
80
55
  "scripts": {
81
56
  "new": "modern new",
82
- "build": "wireit",
83
- "test": "wireit"
57
+ "build": "modern build",
58
+ "test": "jest --passWithNoTests"
84
59
  }
85
60
  }