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