@modern-js/packages-generator 3.0.11 → 3.1.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 +139 -1
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -137598,7 +137598,7 @@ var require_format2 = __commonJS({
137598
137598
  if (typeof stats === "object") {
137599
137599
  const fileName = stats.moduleName ? `File: ${stats.moduleName}
137600
137600
  ` : "";
137601
- const mainMessage = stats.message;
137601
+ const mainMessage = typeof stats.formatted === "string" ? stats.formatted : stats.message;
137602
137602
  const details = stats.details ? `
137603
137603
  Details: ${stats.details}
137604
137604
  ` : "";
@@ -140959,6 +140959,143 @@ var require_getTargetDir = __commonJS({
140959
140959
  }
140960
140960
  });
140961
140961
 
140962
+ // ../../../toolkit/utils/dist/babel.js
140963
+ var require_babel = __commonJS({
140964
+ "../../../toolkit/utils/dist/babel.js"(exports, module2) {
140965
+ var __defProp2 = Object.defineProperty;
140966
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
140967
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
140968
+ var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
140969
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
140970
+ var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
140971
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
140972
+ var __spreadValues2 = (a, b) => {
140973
+ for (var prop in b || (b = {}))
140974
+ if (__hasOwnProp2.call(b, prop))
140975
+ __defNormalProp2(a, prop, b[prop]);
140976
+ if (__getOwnPropSymbols2)
140977
+ for (var prop of __getOwnPropSymbols2(b)) {
140978
+ if (__propIsEnum2.call(b, prop))
140979
+ __defNormalProp2(a, prop, b[prop]);
140980
+ }
140981
+ return a;
140982
+ };
140983
+ var __export2 = (target, all) => {
140984
+ for (var name in all)
140985
+ __defProp2(target, name, { get: all[name], enumerable: true });
140986
+ };
140987
+ var __copyProps2 = (to, from, except, desc) => {
140988
+ if (from && typeof from === "object" || typeof from === "function") {
140989
+ for (let key of __getOwnPropNames2(from))
140990
+ if (!__hasOwnProp2.call(to, key) && key !== except)
140991
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
140992
+ }
140993
+ return to;
140994
+ };
140995
+ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
140996
+ var babel_exports = {};
140997
+ __export2(babel_exports, {
140998
+ applyUserBabelConfig: () => applyUserBabelConfig,
140999
+ getBabelUtils: () => getBabelUtils
141000
+ });
141001
+ module2.exports = __toCommonJS2(babel_exports);
141002
+ var import_path4 = require("path");
141003
+ var import_applyOptionsChain = require_applyOptionsChain2();
141004
+ var import_ensureArray = require_ensureArray2();
141005
+ var import_path22 = require_path2();
141006
+ var formatPath = (originPath) => {
141007
+ if ((0, import_path4.isAbsolute)(originPath)) {
141008
+ return originPath.split(import_path4.sep).join("/");
141009
+ }
141010
+ return originPath;
141011
+ };
141012
+ var getPluginItemName = (item) => {
141013
+ if (typeof item === "string") {
141014
+ return formatPath(item);
141015
+ }
141016
+ if (Array.isArray(item) && typeof item[0] === "string") {
141017
+ return formatPath(item[0]);
141018
+ }
141019
+ return null;
141020
+ };
141021
+ var addPlugins = (plugins, config) => {
141022
+ if (config.plugins) {
141023
+ config.plugins.push(...plugins);
141024
+ } else {
141025
+ config.plugins = plugins;
141026
+ }
141027
+ };
141028
+ var addPresets = (presets, config) => {
141029
+ if (config.presets) {
141030
+ config.presets.push(...presets);
141031
+ } else {
141032
+ config.presets = presets;
141033
+ }
141034
+ };
141035
+ var removePlugins = (plugins, config) => {
141036
+ if (!config.plugins) {
141037
+ return;
141038
+ }
141039
+ const removeList = (0, import_ensureArray.ensureArray)(plugins);
141040
+ config.plugins = config.plugins.filter((item) => {
141041
+ const name = getPluginItemName(item);
141042
+ if (name) {
141043
+ return !removeList.find((removeItem) => name.includes(removeItem));
141044
+ }
141045
+ return true;
141046
+ });
141047
+ };
141048
+ var removePresets = (presets, config) => {
141049
+ if (!config.presets) {
141050
+ return;
141051
+ }
141052
+ const removeList = (0, import_ensureArray.ensureArray)(presets);
141053
+ config.presets = config.presets.filter((item) => {
141054
+ const name = getPluginItemName(item);
141055
+ if (name) {
141056
+ return !removeList.find((removeItem) => name.includes(removeItem));
141057
+ }
141058
+ return true;
141059
+ });
141060
+ };
141061
+ var modifyPresetOptions = (presetName, options, presets = []) => {
141062
+ presets.forEach((preset, index) => {
141063
+ if (Array.isArray(preset)) {
141064
+ if (typeof preset[0] === "string" && (0, import_path22.normalizeToPosixPath)(preset[0]).includes(presetName)) {
141065
+ preset[1] = __spreadValues2(__spreadValues2({}, preset[1] || {}), options);
141066
+ }
141067
+ } else if (typeof preset === "string" && (0, import_path22.normalizeToPosixPath)(preset).includes(presetName)) {
141068
+ presets[index] = [preset, options];
141069
+ }
141070
+ });
141071
+ };
141072
+ var getBabelUtils = (config) => {
141073
+ const noop = () => {
141074
+ };
141075
+ return {
141076
+ addPlugins: (plugins) => addPlugins(plugins, config),
141077
+ addPresets: (presets) => addPresets(presets, config),
141078
+ removePlugins: (plugins) => removePlugins(plugins, config),
141079
+ removePresets: (presets) => removePresets(presets, config),
141080
+ // `addIncludes` and `addExcludes` are noop functions by default,
141081
+ // It can be overridden by `extraBabelUtils`.
141082
+ addIncludes: noop,
141083
+ addExcludes: noop,
141084
+ // Compat `presetEnvOptions` and `presetReactOptions` in Eden.
141085
+ modifyPresetEnvOptions: (options) => modifyPresetOptions("@babel/preset-env", options, config.presets || []),
141086
+ modifyPresetReactOptions: (options) => modifyPresetOptions("@babel/preset-react", options, config.presets || [])
141087
+ };
141088
+ };
141089
+ var applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils) => {
141090
+ if (userBabelConfig) {
141091
+ const babelUtils = __spreadValues2(__spreadValues2({}, getBabelUtils(defaultOptions)), extraBabelUtils);
141092
+ return (0, import_applyOptionsChain.applyOptionsChain)(defaultOptions, userBabelConfig || {}, babelUtils);
141093
+ }
141094
+ return defaultOptions;
141095
+ };
141096
+ }
141097
+ });
141098
+
140962
141099
  // ../../../toolkit/utils/dist/index.js
140963
141100
  var require_dist3 = __commonJS({
140964
141101
  "../../../toolkit/utils/dist/index.js"(exports, module2) {
@@ -141022,6 +141159,7 @@ var require_dist3 = __commonJS({
141022
141159
  __reExport(src_exports2, require_getCoreJsVersion(), module2.exports);
141023
141160
  __reExport(src_exports2, require_react(), module2.exports);
141024
141161
  __reExport(src_exports2, require_getTargetDir(), module2.exports);
141162
+ __reExport(src_exports2, require_babel(), module2.exports);
141025
141163
  }
141026
141164
  });
141027
141165
 
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "3.0.11",
14
+ "version": "3.1.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "main": "./dist/index.js",
17
17
  "files": [
@@ -23,14 +23,14 @@
23
23
  "@modern-js/codesmith": "2.0.5",
24
24
  "@modern-js/codesmith-api-app": "2.0.5",
25
25
  "@modern-js/codesmith-api-json": "2.0.5",
26
- "@types/jest": "^27",
26
+ "@types/jest": "^29",
27
27
  "@types/node": "^14",
28
- "jest": "^27",
28
+ "jest": "^29",
29
29
  "typescript": "^4",
30
- "@modern-js/generator-utils": "3.0.11",
31
- "@scripts/build": "2.9.0",
32
- "@scripts/jest-config": "2.9.0",
33
- "@modern-js/generator-common": "3.0.11"
30
+ "@modern-js/generator-utils": "3.1.0",
31
+ "@scripts/jest-config": "2.10.0",
32
+ "@modern-js/generator-common": "3.1.0",
33
+ "@scripts/build": "2.10.0"
34
34
  },
35
35
  "sideEffects": false,
36
36
  "publishConfig": {