@modern-js/module-tools 2.15.0 → 2.16.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 (135) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/compiled/postcss-custom-properties/index.js +1 -1
  3. package/compiled/postcss-custom-properties/package.json +1 -1
  4. package/dist/build.js +23 -66
  5. package/dist/build.js.map +1 -1
  6. package/dist/builder/build.js +114 -170
  7. package/dist/builder/build.js.map +1 -1
  8. package/dist/builder/clear.js +23 -65
  9. package/dist/builder/clear.js.map +1 -1
  10. package/dist/builder/copy.js +83 -164
  11. package/dist/builder/copy.js.map +1 -1
  12. package/dist/builder/dts/index.js +15 -28
  13. package/dist/builder/dts/index.js.map +1 -1
  14. package/dist/builder/dts/rollup.js +46 -120
  15. package/dist/builder/dts/rollup.js.map +1 -1
  16. package/dist/builder/dts/tsc.js +82 -141
  17. package/dist/builder/dts/tsc.js.map +1 -1
  18. package/dist/builder/index.js +34 -85
  19. package/dist/builder/index.js.map +1 -1
  20. package/dist/builder/platform.js +40 -93
  21. package/dist/builder/platform.js.map +1 -1
  22. package/dist/cli.js +35 -84
  23. package/dist/cli.js.map +1 -1
  24. package/dist/command.js +56 -136
  25. package/dist/command.js.map +1 -1
  26. package/dist/config/defineConfig.js +13 -42
  27. package/dist/config/defineConfig.js.map +1 -1
  28. package/dist/config/legacySchema.js +96 -52
  29. package/dist/config/legacySchema.js.map +1 -1
  30. package/dist/config/normalize.js +73 -149
  31. package/dist/config/normalize.js.map +1 -1
  32. package/dist/config/schema.d.ts +36 -0
  33. package/dist/config/schema.js +118 -56
  34. package/dist/config/schema.js.map +1 -1
  35. package/dist/config/transformLegacyConfig.js +152 -203
  36. package/dist/config/transformLegacyConfig.js.map +1 -1
  37. package/dist/constants/build.js +15 -27
  38. package/dist/constants/build.js.map +1 -1
  39. package/dist/constants/buildPresets.js +71 -84
  40. package/dist/constants/buildPresets.js.map +1 -1
  41. package/dist/constants/colors.js +28 -30
  42. package/dist/constants/colors.js.map +1 -1
  43. package/dist/constants/dts.js +13 -28
  44. package/dist/constants/dts.js.map +1 -1
  45. package/dist/constants/file.js +27 -30
  46. package/dist/constants/file.js.map +1 -1
  47. package/dist/constants/legacyBuildPresets.js +33 -49
  48. package/dist/constants/legacyBuildPresets.js.map +1 -1
  49. package/dist/constants/log.js +15 -33
  50. package/dist/constants/log.js.map +1 -1
  51. package/dist/dev.js +45 -91
  52. package/dist/dev.js.map +1 -1
  53. package/dist/error.js +37 -54
  54. package/dist/error.js.map +1 -1
  55. package/dist/hooks/build.js +22 -35
  56. package/dist/hooks/build.js.map +1 -1
  57. package/dist/hooks/dev.js +15 -33
  58. package/dist/hooks/dev.js.map +1 -1
  59. package/dist/hooks/index.js +15 -42
  60. package/dist/hooks/index.js.map +1 -1
  61. package/dist/hooks/misc.js +10 -28
  62. package/dist/hooks/misc.js.map +1 -1
  63. package/dist/index.js +21 -35
  64. package/dist/index.js.map +1 -1
  65. package/dist/locale/en.d.ts +7 -2
  66. package/dist/locale/en.js +25 -32
  67. package/dist/locale/en.js.map +1 -1
  68. package/dist/locale/index.d.ts +14 -4
  69. package/dist/locale/index.js +18 -31
  70. package/dist/locale/index.js.map +1 -1
  71. package/dist/locale/zh.d.ts +7 -2
  72. package/dist/locale/zh.js +25 -32
  73. package/dist/locale/zh.js.map +1 -1
  74. package/dist/plugins.js +16 -39
  75. package/dist/plugins.js.map +1 -1
  76. package/dist/types/color.js +4 -15
  77. package/dist/types/color.js.map +1 -1
  78. package/dist/types/command.js +4 -15
  79. package/dist/types/command.js.map +1 -1
  80. package/dist/types/config/index.d.ts +6 -0
  81. package/dist/types/config/index.js +6 -17
  82. package/dist/types/config/index.js.map +1 -1
  83. package/dist/types/config/style.js +4 -15
  84. package/dist/types/config/style.js.map +1 -1
  85. package/dist/types/context.js +4 -15
  86. package/dist/types/context.js.map +1 -1
  87. package/dist/types/copy.js +4 -15
  88. package/dist/types/copy.js.map +1 -1
  89. package/dist/types/dts.js +4 -15
  90. package/dist/types/dts.js.map +1 -1
  91. package/dist/types/hooks.js +4 -15
  92. package/dist/types/hooks.js.map +1 -1
  93. package/dist/types/index.js +11 -22
  94. package/dist/types/index.js.map +1 -1
  95. package/dist/types/legacyConfig/index.js +4 -15
  96. package/dist/types/legacyConfig/index.js.map +1 -1
  97. package/dist/types/legacyConfig/output.js +4 -15
  98. package/dist/types/legacyConfig/output.js.map +1 -1
  99. package/dist/types/legacyConfig/source.js +4 -15
  100. package/dist/types/legacyConfig/source.js.map +1 -1
  101. package/dist/types/legacyConfig/tools.js +4 -15
  102. package/dist/types/legacyConfig/tools.js.map +1 -1
  103. package/dist/types/utils.js +4 -17
  104. package/dist/utils/builder.d.ts +20 -2
  105. package/dist/utils/builder.js +81 -68
  106. package/dist/utils/builder.js.map +1 -1
  107. package/dist/utils/common.js +10 -44
  108. package/dist/utils/common.js.map +1 -1
  109. package/dist/utils/config.js +108 -144
  110. package/dist/utils/config.js.map +1 -1
  111. package/dist/utils/context.js +16 -59
  112. package/dist/utils/context.js.map +1 -1
  113. package/dist/utils/dts.js +69 -146
  114. package/dist/utils/dts.js.map +1 -1
  115. package/dist/utils/input.js +44 -87
  116. package/dist/utils/input.js.map +1 -1
  117. package/dist/utils/language.js +15 -60
  118. package/dist/utils/language.js.map +1 -1
  119. package/dist/utils/libuildPlugins.js +27 -67
  120. package/dist/utils/libuildPlugins.js.map +1 -1
  121. package/dist/utils/log.js +14 -61
  122. package/dist/utils/log.js.map +1 -1
  123. package/dist/utils/onExit.js +14 -61
  124. package/dist/utils/onExit.js.map +1 -1
  125. package/dist/utils/path.js +13 -59
  126. package/dist/utils/path.js.map +1 -1
  127. package/dist/utils/print.js +57 -105
  128. package/dist/utils/print.js.map +1 -1
  129. package/dist/utils/style.js +54 -106
  130. package/dist/utils/style.js.map +1 -1
  131. package/dist/utils/tspathsTransform.js +44 -81
  132. package/dist/utils/tspathsTransform.js.map +1 -1
  133. package/package.json +25 -20
  134. package/scripts/debug-mode.js +23 -21
  135. package/dist/types/utils.js.map +0 -1
package/dist/utils/dts.js CHANGED
@@ -1,98 +1,33 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
- var __getProtoOf = Object.getPrototypeOf;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var __export = (target, all) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
25
6
  for (var name in all)
26
- __defProp(target, name, { get: all[name], enumerable: true });
27
- };
28
- var __copyProps = (to, from, except, desc) => {
29
- if (from && typeof from === "object" || typeof from === "function") {
30
- for (let key of __getOwnPropNames(from))
31
- if (!__hasOwnProp.call(to, key) && key !== except)
32
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
- }
34
- return to;
35
- };
36
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
37
- // If the importer is in node compatibility mode or this is not an ESM
38
- // file that has been converted to a CommonJS file using a Babel-
39
- // compatible transform (i.e. "__esModule" has not been set), then set
40
- // "default" to the CommonJS "module.exports" for node compatibility.
41
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
42
- mod
43
- ));
44
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
45
- var __async = (__this, __arguments, generator) => {
46
- return new Promise((resolve, reject) => {
47
- var fulfilled = (value) => {
48
- try {
49
- step(generator.next(value));
50
- } catch (e) {
51
- reject(e);
52
- }
53
- };
54
- var rejected = (value) => {
55
- try {
56
- step(generator.throw(value));
57
- } catch (e) {
58
- reject(e);
59
- }
60
- };
61
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
62
- step((generator = generator.apply(__this, __arguments)).next());
63
- });
64
- };
65
- var dts_exports = {};
66
- __export(dts_exports, {
67
- assignTsConfigPath: () => assignTsConfigPath,
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
68
13
  generatorTsConfig: () => generatorTsConfig,
69
14
  getTscBinPath: () => getTscBinPath,
70
- printOrThrowDtsErrors: () => printOrThrowDtsErrors,
71
- resolveAlias: () => resolveAlias
15
+ resolveAlias: () => resolveAlias,
16
+ assignTsConfigPath: () => assignTsConfigPath,
17
+ printOrThrowDtsErrors: () => printOrThrowDtsErrors
72
18
  });
73
- module.exports = __toCommonJS(dts_exports);
74
- var import_path = __toESM(require("path"));
75
- const generatorTsConfig = (config) => __async(void 0, null, function* () {
76
- const { fs, nanoid } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
77
- const { dtsTempDirectory } = yield Promise.resolve().then(() => __toESM(require("../constants/dts")));
19
+ const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
20
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
21
+ const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
22
+ const generatorTsConfig = async (config) => {
23
+ const { fs, nanoid } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
24
+ const { dtsTempDirectory } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../constants/dts")));
78
25
  const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;
79
- const tempDistAbsRootPath = import_path.default.join(
80
- appDirectory,
81
- `${dtsTempDirectory}/${nanoid()}`
82
- );
83
- const tempDistAbsOurDir = import_path.default.join(
84
- tempDistAbsRootPath,
85
- import_path.default.relative(appDirectory, absSourceDir)
86
- );
87
- const tempTsconfigPath = import_path.default.join(
88
- tempDistAbsRootPath,
89
- import_path.default.basename(tsconfigPath)
90
- );
26
+ const tempDistAbsRootPath = _path.default.join(appDirectory, `${dtsTempDirectory}/${nanoid()}`);
27
+ const tempDistAbsOurDir = _path.default.join(tempDistAbsRootPath, _path.default.relative(appDirectory, absSourceDir));
28
+ const tempTsconfigPath = _path.default.join(tempDistAbsRootPath, _path.default.basename(tsconfigPath));
91
29
  fs.ensureFileSync(tempTsconfigPath);
92
- const extendsPath = import_path.default.join(
93
- import_path.default.relative(import_path.default.dirname(tempTsconfigPath), import_path.default.dirname(tsconfigPath)),
94
- import_path.default.basename(tempTsconfigPath)
95
- );
30
+ const extendsPath = _path.default.join(_path.default.relative(_path.default.dirname(tempTsconfigPath), _path.default.dirname(tsconfigPath)), _path.default.basename(tempTsconfigPath));
96
31
  const resetConfig = {
97
32
  extends: extendsPath,
98
33
  compilerOptions: {
@@ -113,89 +48,77 @@ const generatorTsConfig = (config) => __async(void 0, null, function* () {
113
48
  tempDistAbsRootPath,
114
49
  tempDistAbsSrcPath: tempDistAbsOurDir
115
50
  };
116
- });
117
- const getTscBinPath = (appDirectory) => __async(void 0, null, function* () {
118
- const { fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
119
- const { default: findUp, exists: pathExists } = yield Promise.resolve().then(() => __toESM(require("../../compiled/find-up")));
120
- const tscBinFile = yield findUp(
121
- (directory) => __async(void 0, null, function* () {
122
- const targetFilePath = import_path.default.join(directory, "./node_modules/.bin/tsc");
123
- const hasTscBinFile = yield pathExists(targetFilePath);
124
- if (hasTscBinFile) {
125
- return targetFilePath;
126
- }
127
- return void 0;
128
- }),
129
- { cwd: appDirectory }
130
- );
51
+ };
52
+ const getTscBinPath = async (appDirectory) => {
53
+ const { fs } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
54
+ const { default: findUp, exists: pathExists } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../../compiled/find-up")));
55
+ const tscBinFile = await findUp(async (directory) => {
56
+ const targetFilePath = _path.default.join(directory, "./node_modules/.bin/tsc");
57
+ const hasTscBinFile = await pathExists(targetFilePath);
58
+ if (hasTscBinFile) {
59
+ return targetFilePath;
60
+ }
61
+ return void 0;
62
+ }, {
63
+ cwd: appDirectory
64
+ });
131
65
  if (!tscBinFile || !fs.existsSync(tscBinFile)) {
132
- throw new Error(
133
- "Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory."
134
- );
66
+ throw new Error("Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.");
135
67
  }
136
68
  return tscBinFile;
137
- });
138
- const resolveAlias = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (config, options, watchFilenames = []) {
139
- var _a, _b;
69
+ };
70
+ const resolveAlias = async (config, options, watchFilenames = []) => {
71
+ var _userTsconfig_compilerOptions;
140
72
  const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;
141
- const { globby, fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
142
- const { transformDtsAlias } = yield Promise.resolve().then(() => __toESM(require("./tspathsTransform")));
73
+ const { globby, fs } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
74
+ const { transformDtsAlias } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./tspathsTransform")));
143
75
  const { distAbsPath } = config;
144
76
  const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;
145
- const dtsFilenames = watchFilenames.length > 0 ? watchFilenames : globby.sync(dtsDistPath, { absolute: true });
77
+ const dtsFilenames = watchFilenames.length > 0 ? watchFilenames : globby.sync(dtsDistPath, {
78
+ absolute: true
79
+ });
80
+ var _userTsconfig_compilerOptions_paths;
146
81
  const result = transformDtsAlias({
147
82
  filenames: dtsFilenames,
148
83
  baseUrl: tempDistAbsRootPath,
149
- paths: (_b = (_a = userTsconfig.compilerOptions) == null ? void 0 : _a.paths) != null ? _b : {}
84
+ paths: (_userTsconfig_compilerOptions_paths = (_userTsconfig_compilerOptions = userTsconfig.compilerOptions) === null || _userTsconfig_compilerOptions === void 0 ? void 0 : _userTsconfig_compilerOptions.paths) !== null && _userTsconfig_compilerOptions_paths !== void 0 ? _userTsconfig_compilerOptions_paths : {}
150
85
  });
151
86
  for (const r of result) {
152
87
  fs.writeFileSync(r.path, r.content);
153
88
  }
154
- yield fs.copy(tempDistAbsSrcPath, distAbsPath);
155
- });
156
- const assignTsConfigPath = (config, options) => __async(void 0, null, function* () {
157
- var _a;
158
- const { defaultTsConfigPath } = yield Promise.resolve().then(() => __toESM(require("../constants/dts")));
89
+ await fs.copy(tempDistAbsSrcPath, distAbsPath);
90
+ };
91
+ const assignTsConfigPath = async (config, options) => {
92
+ const { defaultTsConfigPath } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../constants/dts")));
159
93
  if (typeof options.tsconfig === "string" && options.tsconfig !== defaultTsConfigPath) {
160
- config.dts = __spreadProps(__spreadValues({
94
+ var _config_dts;
95
+ config.dts = {
161
96
  only: false,
162
97
  distPath: "./",
163
- abortOnError: true
164
- }, (_a = config.dts) != null ? _a : {}), {
98
+ abortOnError: true,
99
+ ...(_config_dts = config.dts) !== null && _config_dts !== void 0 ? _config_dts : {},
165
100
  tsconfigPath: options.tsconfig
166
- });
101
+ };
167
102
  }
168
103
  return config;
169
- });
170
- const printOrThrowDtsErrors = (error, options) => __async(void 0, null, function* () {
171
- const { logger, chalk } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
172
- const { InternalDTSError } = yield Promise.resolve().then(() => __toESM(require("../error")));
173
- const local = yield Promise.resolve().then(() => __toESM(require("../locale")));
174
- const { abortOnError, buildType } = options != null ? options : {};
104
+ };
105
+ const printOrThrowDtsErrors = async (error, options) => {
106
+ const { logger, chalk } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
107
+ const { InternalDTSError } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../error")));
108
+ const local = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../locale")));
109
+ const { abortOnError, buildType } = options !== null && options !== void 0 ? options : {};
175
110
  if (error instanceof Error) {
176
111
  if (abortOnError) {
177
112
  throw new InternalDTSError(error, {
178
113
  buildType
179
114
  });
180
115
  } else {
181
- logger.warn(
182
- chalk.bgYellowBright(local.i18n.t(local.localeKeys.dts.abortOnError))
183
- );
184
- logger.error(
185
- new InternalDTSError(error, {
186
- buildType
187
- })
188
- );
116
+ logger.warn(chalk.bgYellowBright(local.i18n.t(local.localeKeys.warns.dts.abortOnError)));
117
+ logger.error(new InternalDTSError(error, {
118
+ buildType
119
+ }));
189
120
  }
190
121
  }
191
- });
192
- // Annotate the CommonJS export names for ESM import in node:
193
- 0 && (module.exports = {
194
- assignTsConfigPath,
195
- generatorTsConfig,
196
- getTscBinPath,
197
- printOrThrowDtsErrors,
198
- resolveAlias
199
- });
122
+ };
200
123
 
201
124
  //# sourceMappingURL=dts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":"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","names":[],"sources":["../../src/utils/dts.ts"],"sourcesContent":["import path from 'path';\n// import type { NodePath } from '../../compiled/@babel/traverse';\n// import type * as tt from '../../compiled/@babel/types';\n// import t from '../../compiled/@babel/types';\nimport type {\n ITsconfig,\n BundlelessGeneratorDtsConfig,\n BuildCommandOptions,\n BaseBuildConfig,\n BuildType,\n // AliasOption,\n} from '../types';\n\nexport const generatorTsConfig = async (\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { fs, nanoid } = await import('@modern-js/utils');\n const { dtsTempDirectory } = await import('../constants/dts');\n\n const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;\n const tempDistAbsRootPath = path.join(\n appDirectory,\n `${dtsTempDirectory}/${nanoid()}`,\n );\n const tempDistAbsOurDir = path.join(\n tempDistAbsRootPath,\n path.relative(appDirectory, absSourceDir),\n );\n\n const tempTsconfigPath = path.join(\n tempDistAbsRootPath,\n path.basename(tsconfigPath),\n );\n fs.ensureFileSync(tempTsconfigPath);\n\n const extendsPath = path.join(\n path.relative(path.dirname(tempTsconfigPath), path.dirname(tsconfigPath)),\n path.basename(tempTsconfigPath),\n );\n\n const resetConfig: ITsconfig = {\n extends: extendsPath,\n compilerOptions: {\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n // when `outDir` is './dist', `declarationDir` is `./types`\n // tsc will emit:\n // - ./dist/index.js\n // - ./types/index.d.ts\n // we only want to emit declarations\n declarationDir: tempDistAbsOurDir,\n },\n };\n\n fs.writeJSONSync(tempTsconfigPath, resetConfig);\n\n return {\n tempTsconfigPath,\n tempDistAbsRootPath,\n tempDistAbsSrcPath: tempDistAbsOurDir,\n };\n};\n\nexport const getTscBinPath = async (appDirectory: string) => {\n const { fs } = await import('@modern-js/utils');\n const { default: findUp, exists: pathExists } = await import(\n '../../compiled/find-up'\n );\n const tscBinFile = await findUp(\n async (directory: string) => {\n const targetFilePath = path.join(directory, './node_modules/.bin/tsc');\n const hasTscBinFile = await pathExists(targetFilePath);\n if (hasTscBinFile) {\n return targetFilePath;\n }\n return undefined;\n },\n { cwd: appDirectory },\n );\n\n if (!tscBinFile || !fs.existsSync(tscBinFile)) {\n throw new Error(\n 'Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.',\n );\n }\n\n return tscBinFile;\n};\n\nexport const resolveAlias = async (\n config: BundlelessGeneratorDtsConfig,\n options: {\n userTsconfig: ITsconfig;\n tempTsconfigPath: string;\n tempDistAbsRootPath: string;\n tempDistAbsSrcPath: string;\n },\n watchFilenames: string[] = [],\n) => {\n const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;\n const { globby, fs } = await import('@modern-js/utils');\n const { transformDtsAlias } = await import('./tspathsTransform');\n const { distAbsPath } = config;\n const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;\n const dtsFilenames =\n watchFilenames.length > 0\n ? watchFilenames\n : globby.sync(dtsDistPath, { absolute: true });\n const result = transformDtsAlias({\n filenames: dtsFilenames,\n baseUrl: tempDistAbsRootPath,\n paths: userTsconfig.compilerOptions?.paths ?? {},\n });\n for (const r of result) {\n fs.writeFileSync(r.path, r.content);\n }\n\n await fs.copy(tempDistAbsSrcPath, distAbsPath);\n};\n\n// export const matchesPattern = (calleePath: NodePath, pattern: string) => {\n// const { node } = calleePath;\n\n// if (t.isMemberExpression(node)) {\n// return calleePath.matchesPattern(pattern);\n// }\n\n// if (!t.isIdentifier(node) || pattern.includes('.')) {\n// return false;\n// }\n\n// const name = pattern.split('.')[0];\n\n// return node.name === name;\n// };\n\n// export const isImportCall = (calleePath: NodePath<tt.CallExpression>) => {\n// return t.isImport(calleePath.node.callee);\n// };\n\n// export const verifyTsConfigPaths = async (\n// tsconfigAbsPath: string,\n// userAliases?: AliasOption,\n// ) => {\n// const { readTsConfigByFile, chalk } = await import('@modern-js/utils');\n// if (!userAliases) {\n// return;\n// }\n\n// const paths = Object.keys(\n// readTsConfigByFile(tsconfigAbsPath).compilerOptions?.paths || {},\n// ).map(key => key.replace(/\\/\\*$/, ''));\n\n// Object.keys(userAliases).forEach(name => {\n// if (paths.includes(name)) {\n// throw new Error(\n// chalk.red(\n// `It looks like you have configured the alias ${chalk.bold(\n// name,\n// )} in both the modern.config file and tsconfig.json.\\n Please remove the configuration in modern.config file and just keep the configuration in tsconfig.json.`,\n// ),\n// );\n// }\n// });\n// };\n\nexport const assignTsConfigPath = async (\n config: BaseBuildConfig,\n options: BuildCommandOptions,\n) => {\n const { defaultTsConfigPath } = await import('../constants/dts');\n\n // user run `build --tsconfig './tsconfig.build.json'`\n if (\n typeof options.tsconfig === 'string' &&\n options.tsconfig !== defaultTsConfigPath\n ) {\n config.dts = {\n only: false,\n distPath: './',\n abortOnError: true,\n ...(config.dts ?? {}),\n tsconfigPath: options.tsconfig,\n };\n }\n\n return config;\n};\n\nexport const printOrThrowDtsErrors = async (\n error: unknown,\n options: { abortOnError?: boolean; buildType: BuildType },\n) => {\n const { logger, chalk } = await import('@modern-js/utils');\n const { InternalDTSError } = await import('../error');\n const local = await import('../locale');\n const { abortOnError, buildType } = options ?? {};\n if (error instanceof Error) {\n if (abortOnError) {\n throw new InternalDTSError(error, {\n buildType,\n });\n } else {\n logger.warn(\n chalk.bgYellowBright(local.i18n.t(local.localeKeys.dts.abortOnError)),\n );\n logger.error(\n new InternalDTSError(error, {\n buildType,\n }),\n );\n }\n }\n};\n"]}
1
+ {"version":3,"file":null,"mappings":"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","names":["generatorTsConfig","getTscBinPath","resolveAlias","assignTsConfigPath","printOrThrowDtsErrors","config","fs","nanoid","dtsTempDirectory","appDirectory","sourceDir","absSourceDir","tsconfigPath","tempDistAbsRootPath","path","join","tempDistAbsOurDir","relative","tempTsconfigPath","basename","ensureFileSync","extendsPath","dirname","resetConfig","extends","compilerOptions","declaration","emitDeclarationOnly","declarationDir","writeJSONSync","tempDistAbsSrcPath","default","findUp","exists","pathExists","tscBinFile","directory","targetFilePath","hasTscBinFile","undefined","cwd","existsSync","Error","options","watchFilenames","userTsconfig","globby","transformDtsAlias","distAbsPath","dtsDistPath","dtsFilenames","length","sync","absolute","result","filenames","baseUrl","paths","r","writeFileSync","content","copy","defaultTsConfigPath","tsconfig","dts","only","distPath","abortOnError","error","logger","chalk","InternalDTSError","local","buildType","warn","bgYellowBright","i18n","t","localeKeys","warns"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/dts.ts"],"sourcesContent":["import path from 'path';\n// import type { NodePath } from '../../compiled/@babel/traverse';\n// import type * as tt from '../../compiled/@babel/types';\n// import t from '../../compiled/@babel/types';\nimport type {\n ITsconfig,\n BundlelessGeneratorDtsConfig,\n BuildCommandOptions,\n BaseBuildConfig,\n BuildType,\n // AliasOption,\n} from '../types';\n\nexport const generatorTsConfig = async (\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { fs, nanoid } = await import('@modern-js/utils');\n const { dtsTempDirectory } = await import('../constants/dts');\n\n const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;\n const tempDistAbsRootPath = path.join(\n appDirectory,\n `${dtsTempDirectory}/${nanoid()}`,\n );\n const tempDistAbsOurDir = path.join(\n tempDistAbsRootPath,\n path.relative(appDirectory, absSourceDir),\n );\n\n const tempTsconfigPath = path.join(\n tempDistAbsRootPath,\n path.basename(tsconfigPath),\n );\n fs.ensureFileSync(tempTsconfigPath);\n\n const extendsPath = path.join(\n path.relative(path.dirname(tempTsconfigPath), path.dirname(tsconfigPath)),\n path.basename(tempTsconfigPath),\n );\n\n const resetConfig: ITsconfig = {\n extends: extendsPath,\n compilerOptions: {\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n // when `outDir` is './dist', `declarationDir` is `./types`\n // tsc will emit:\n // - ./dist/index.js\n // - ./types/index.d.ts\n // we only want to emit declarations\n declarationDir: tempDistAbsOurDir,\n },\n };\n\n fs.writeJSONSync(tempTsconfigPath, resetConfig);\n\n return {\n tempTsconfigPath,\n tempDistAbsRootPath,\n tempDistAbsSrcPath: tempDistAbsOurDir,\n };\n};\n\nexport const getTscBinPath = async (appDirectory: string) => {\n const { fs } = await import('@modern-js/utils');\n const { default: findUp, exists: pathExists } = await import(\n '../../compiled/find-up'\n );\n const tscBinFile = await findUp(\n async (directory: string) => {\n const targetFilePath = path.join(directory, './node_modules/.bin/tsc');\n const hasTscBinFile = await pathExists(targetFilePath);\n if (hasTscBinFile) {\n return targetFilePath;\n }\n return undefined;\n },\n { cwd: appDirectory },\n );\n\n if (!tscBinFile || !fs.existsSync(tscBinFile)) {\n throw new Error(\n 'Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.',\n );\n }\n\n return tscBinFile;\n};\n\nexport const resolveAlias = async (\n config: BundlelessGeneratorDtsConfig,\n options: {\n userTsconfig: ITsconfig;\n tempTsconfigPath: string;\n tempDistAbsRootPath: string;\n tempDistAbsSrcPath: string;\n },\n watchFilenames: string[] = [],\n) => {\n const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;\n const { globby, fs } = await import('@modern-js/utils');\n const { transformDtsAlias } = await import('./tspathsTransform');\n const { distAbsPath } = config;\n const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;\n const dtsFilenames =\n watchFilenames.length > 0\n ? watchFilenames\n : globby.sync(dtsDistPath, { absolute: true });\n const result = transformDtsAlias({\n filenames: dtsFilenames,\n baseUrl: tempDistAbsRootPath,\n paths: userTsconfig.compilerOptions?.paths ?? {},\n });\n for (const r of result) {\n fs.writeFileSync(r.path, r.content);\n }\n\n await fs.copy(tempDistAbsSrcPath, distAbsPath);\n};\n\n// export const matchesPattern = (calleePath: NodePath, pattern: string) => {\n// const { node } = calleePath;\n\n// if (t.isMemberExpression(node)) {\n// return calleePath.matchesPattern(pattern);\n// }\n\n// if (!t.isIdentifier(node) || pattern.includes('.')) {\n// return false;\n// }\n\n// const name = pattern.split('.')[0];\n\n// return node.name === name;\n// };\n\n// export const isImportCall = (calleePath: NodePath<tt.CallExpression>) => {\n// return t.isImport(calleePath.node.callee);\n// };\n\n// export const verifyTsConfigPaths = async (\n// tsconfigAbsPath: string,\n// userAliases?: AliasOption,\n// ) => {\n// const { readTsConfigByFile, chalk } = await import('@modern-js/utils');\n// if (!userAliases) {\n// return;\n// }\n\n// const paths = Object.keys(\n// readTsConfigByFile(tsconfigAbsPath).compilerOptions?.paths || {},\n// ).map(key => key.replace(/\\/\\*$/, ''));\n\n// Object.keys(userAliases).forEach(name => {\n// if (paths.includes(name)) {\n// throw new Error(\n// chalk.red(\n// `It looks like you have configured the alias ${chalk.bold(\n// name,\n// )} in both the modern.config file and tsconfig.json.\\n Please remove the configuration in modern.config file and just keep the configuration in tsconfig.json.`,\n// ),\n// );\n// }\n// });\n// };\n\nexport const assignTsConfigPath = async (\n config: BaseBuildConfig,\n options: BuildCommandOptions,\n) => {\n const { defaultTsConfigPath } = await import('../constants/dts');\n\n // user run `build --tsconfig './tsconfig.build.json'`\n if (\n typeof options.tsconfig === 'string' &&\n options.tsconfig !== defaultTsConfigPath\n ) {\n config.dts = {\n only: false,\n distPath: './',\n abortOnError: true,\n ...(config.dts ?? {}),\n tsconfigPath: options.tsconfig,\n };\n }\n\n return config;\n};\n\nexport const printOrThrowDtsErrors = async (\n error: unknown,\n options: { abortOnError?: boolean; buildType: BuildType },\n) => {\n const { logger, chalk } = await import('@modern-js/utils');\n const { InternalDTSError } = await import('../error');\n const local = await import('../locale');\n const { abortOnError, buildType } = options ?? {};\n if (error instanceof Error) {\n if (abortOnError) {\n throw new InternalDTSError(error, {\n buildType,\n });\n } else {\n logger.warn(\n chalk.bgYellowBright(\n local.i18n.t(local.localeKeys.warns.dts.abortOnError),\n ),\n );\n logger.error(\n new InternalDTSError(error, {\n buildType,\n }),\n );\n }\n }\n};\n"]}
@@ -1,127 +1,84 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
8
6
  for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var __async = (__this, __arguments, generator) => {
29
- return new Promise((resolve, reject) => {
30
- var fulfilled = (value) => {
31
- try {
32
- step(generator.next(value));
33
- } catch (e) {
34
- reject(e);
35
- }
36
- };
37
- var rejected = (value) => {
38
- try {
39
- step(generator.throw(value));
40
- } catch (e) {
41
- reject(e);
42
- }
43
- };
44
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
45
- step((generator = generator.apply(__this, __arguments)).next());
46
- });
47
- };
48
- var input_exports = {};
49
- __export(input_exports, {
50
- addInputToPreset: () => addInputToPreset,
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ joinPathWithPrefix: () => joinPathWithPrefix,
51
14
  getAbsInput: () => getAbsInput,
15
+ addInputToPreset: () => addInputToPreset,
52
16
  getDefaultIndexEntry: () => getDefaultIndexEntry,
53
- joinPathWithPrefix: () => joinPathWithPrefix,
54
17
  normalizeInput: () => normalizeInput
55
18
  });
56
- module.exports = __toCommonJS(input_exports);
57
- var import_path = __toESM(require("path"));
19
+ const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
20
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
21
+ const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
58
22
  const joinPathWithPrefix = (flag) => (p1, globPath) => {
59
23
  const haveFlag = globPath.trim().startsWith(flag);
60
24
  if (haveFlag) {
61
- return import_path.default.join(flag, p1, globPath.replace(flag, ""));
25
+ return _path.default.join(flag, p1, globPath.replace(flag, ""));
62
26
  }
63
- return import_path.default.join(p1, globPath);
27
+ return _path.default.join(p1, globPath);
64
28
  };
65
- const getAbsInput = (entry, options) => __async(void 0, null, function* () {
66
- const { slash } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
29
+ const getAbsInput = async (entry, options) => {
30
+ const { slash } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
67
31
  const { appDirectory } = options;
68
32
  const resolvePathWithNoMatchFlag = joinPathWithPrefix("!");
69
33
  if (Array.isArray(entry)) {
70
- return entry.map(
71
- (p) => import_path.default.isAbsolute(p) ? slash(p) : slash(resolvePathWithNoMatchFlag(appDirectory, p))
72
- );
34
+ return entry.map((p) => _path.default.isAbsolute(p) ? slash(p) : slash(resolvePathWithNoMatchFlag(appDirectory, p)));
73
35
  }
74
36
  const newEntry = {};
75
37
  for (const key of Object.keys(entry)) {
76
- newEntry[key] = import_path.default.isAbsolute(entry[key]) ? slash(entry[key]) : slash(resolvePathWithNoMatchFlag(appDirectory, entry[key]));
38
+ newEntry[key] = _path.default.isAbsolute(entry[key]) ? slash(entry[key]) : slash(resolvePathWithNoMatchFlag(appDirectory, entry[key]));
77
39
  }
78
40
  return newEntry;
79
- });
80
- const addInputToPreset = (config, context) => __async(void 0, null, function* () {
41
+ };
42
+ const addInputToPreset = async (config, context) => {
81
43
  if (Array.isArray(config)) {
82
44
  for (const c of config) {
83
45
  if (c.buildType === "bundle") {
84
- c.input = yield getDefaultIndexEntry(context);
46
+ c.input = await getDefaultIndexEntry(context);
85
47
  } else if (c.buildType === "bundleless") {
86
48
  c.sourceDir = "./src";
87
49
  }
88
50
  }
89
51
  } else if (config.buildType === "bundle") {
90
- config.input = yield getDefaultIndexEntry(context);
52
+ config.input = await getDefaultIndexEntry(context);
91
53
  } else if (config.buildType === "bundleless") {
92
54
  config.sourceDir = "./src";
93
55
  }
94
56
  return config;
95
- });
96
- const getDefaultIndexEntry = (_0) => __async(void 0, [_0], function* ({
97
- isTsProject,
98
- appDirectory
99
- }) {
100
- const { fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
101
- let entry = isTsProject ? import_path.default.join(appDirectory, "./src/index.ts") : import_path.default.join(appDirectory, "./src/index.js");
57
+ };
58
+ const getDefaultIndexEntry = async ({ isTsProject, appDirectory }) => {
59
+ const { fs } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
60
+ let entry = isTsProject ? _path.default.join(appDirectory, "./src/index.ts") : _path.default.join(appDirectory, "./src/index.js");
102
61
  if (fs.existsSync(entry)) {
103
- return [`./${import_path.default.relative(appDirectory, entry)}`];
62
+ return [
63
+ `./${_path.default.relative(appDirectory, entry)}`
64
+ ];
104
65
  }
105
- entry = isTsProject ? import_path.default.join(appDirectory, "./src/index.tsx") : import_path.default.join(appDirectory, "./src/index.jsx");
66
+ entry = isTsProject ? _path.default.join(appDirectory, "./src/index.tsx") : _path.default.join(appDirectory, "./src/index.jsx");
106
67
  if (fs.existsSync(entry)) {
107
- return [`./${import_path.default.relative(appDirectory, entry)}`];
68
+ return [
69
+ `./${_path.default.relative(appDirectory, entry)}`
70
+ ];
108
71
  }
109
72
  return [];
110
- });
111
- const normalizeInput = (baseConfig, options) => __async(void 0, null, function* () {
73
+ };
74
+ const normalizeInput = async (baseConfig, options) => {
112
75
  if (baseConfig.buildType === "bundleless" && !baseConfig.input) {
113
- const { slash } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
114
- return [slash(baseConfig.sourceDir)];
76
+ const { slash } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
77
+ return [
78
+ slash(baseConfig.sourceDir)
79
+ ];
115
80
  }
116
81
  return getAbsInput(baseConfig.input, options);
117
- });
118
- // Annotate the CommonJS export names for ESM import in node:
119
- 0 && (module.exports = {
120
- addInputToPreset,
121
- getAbsInput,
122
- getDefaultIndexEntry,
123
- joinPathWithPrefix,
124
- normalizeInput
125
- });
82
+ };
126
83
 
127
84
  //# sourceMappingURL=input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAYV,MAAM,qBACX,CAAC,SAAiB,CAAC,IAAY,aAAqB;AAClD,QAAM,WAAW,SAAS,KAAK,EAAE,WAAW,IAAI;AAChD,MAAI,UAAU;AACZ,WAAO,oBAAK,KAAK,MAAM,IAAI,SAAS,QAAQ,MAAM,EAAE,CAAC;AAAA,EACvD;AAEA,SAAO,oBAAK,KAAK,IAAI,QAAQ;AAC/B;AAEK,MAAM,cAAc,CAAO,OAAc,YAA0B;AACxE,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,QAAM,EAAE,aAAa,IAAI;AACzB,QAAM,6BAA6B,mBAAmB,GAAG;AAEzD,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM;AAAA,MAAI,OACf,oBAAK,WAAW,CAAC,IACb,MAAM,CAAC,IACP,MAAM,2BAA2B,cAAc,CAAC,CAAC;AAAA,IACvD;AAAA,EACF;AAEA,QAAM,WAAmC,CAAC;AAC1C,aAAW,OAAO,OAAO,KAAK,KAAK,GAAG;AACpC,aAAS,GAAG,IAAI,oBAAK,WAAW,MAAM,GAAG,CAAC,IACtC,MAAM,MAAM,GAAG,CAAC,IAChB,MAAM,2BAA2B,cAAc,MAAM,GAAG,CAAC,CAAC;AAAA,EAChE;AACA,SAAO;AACT;AAEO,MAAM,mBAAmB,CAC9B,QACA,YACG;AACH,MAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,eAAW,KAAK,QAAQ;AACtB,UAAI,EAAE,cAAc,UAAU;AAC5B,UAAE,QAAQ,MAAM,qBAAqB,OAAO;AAAA,MAC9C,WAAW,EAAE,cAAc,cAAc;AACvC,UAAE,YAAY;AAAA,MAChB;AAAA,IACF;AAAA,EACF,WAAW,OAAO,cAAc,UAAU;AACxC,WAAO,QAAQ,MAAM,qBAAqB,OAAO;AAAA,EACnD,WAAW,OAAO,cAAc,cAAc;AAC5C,WAAO,YAAY;AAAA,EACrB;AAEA,SAAO;AACT;AAEO,MAAM,uBAAuB,CAAO,OAMrC,iBANqC,KAMrC,WANqC;AAAA,EACzC;AAAA,EACA;AACF,GAGM;AACJ,QAAM,EAAE,GAAG,IAAI,MAAM,6CAAO,kBAAkB;AAC9C,MAAI,QAAQ,cACR,oBAAK,KAAK,cAAc,gBAAgB,IACxC,oBAAK,KAAK,cAAc,gBAAgB;AAC5C,MAAI,GAAG,WAAW,KAAK,GAAG;AACxB,WAAO,CAAC,KAAK,oBAAK,SAAS,cAAc,KAAK,GAAG;AAAA,EACnD;AAEA,UAAQ,cACJ,oBAAK,KAAK,cAAc,iBAAiB,IACzC,oBAAK,KAAK,cAAc,iBAAiB;AAC7C,MAAI,GAAG,WAAW,KAAK,GAAG;AACxB,WAAO,CAAC,KAAK,oBAAK,SAAS,cAAc,KAAK,GAAG;AAAA,EACnD;AAEA,SAAO,CAAC;AACV;AAEO,MAAM,iBAAiB,CAC5B,YACA,YACG;AACH,MAAI,WAAW,cAAc,gBAAgB,CAAC,WAAW,OAAO;AAC9D,UAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,WAAO,CAAC,MAAM,WAAW,SAAS,CAAC;AAAA,EACrC;AACA,SAAO,YAAY,WAAW,OAAO,OAAO;AAC9C;;;;;;;;;","names":[],"sources":["../../src/utils/input.ts"],"sourcesContent":["import path from 'path';\nimport { ModuleContext } from '../types';\nimport type {\n Input,\n BaseBuildConfig,\n PartialBuildConfig,\n} from '../types/config';\n\ninterface EntryOptions {\n appDirectory: string;\n}\n\nexport const joinPathWithPrefix =\n (flag: string) => (p1: string, globPath: string) => {\n const haveFlag = globPath.trim().startsWith(flag);\n if (haveFlag) {\n return path.join(flag, p1, globPath.replace(flag, ''));\n }\n\n return path.join(p1, globPath);\n };\n\nexport const getAbsInput = async (entry: Input, options: EntryOptions) => {\n const { slash } = await import('@modern-js/utils');\n const { appDirectory } = options;\n const resolvePathWithNoMatchFlag = joinPathWithPrefix('!');\n\n if (Array.isArray(entry)) {\n return entry.map(p =>\n path.isAbsolute(p)\n ? slash(p)\n : slash(resolvePathWithNoMatchFlag(appDirectory, p)),\n );\n }\n\n const newEntry: Record<string, string> = {};\n for (const key of Object.keys(entry)) {\n newEntry[key] = path.isAbsolute(entry[key])\n ? slash(entry[key])\n : slash(resolvePathWithNoMatchFlag(appDirectory, entry[key]));\n }\n return newEntry;\n};\n\nexport const addInputToPreset = async (\n config: PartialBuildConfig,\n context: ModuleContext,\n) => {\n if (Array.isArray(config)) {\n for (const c of config) {\n if (c.buildType === 'bundle') {\n c.input = await getDefaultIndexEntry(context);\n } else if (c.buildType === 'bundleless') {\n c.sourceDir = './src';\n }\n }\n } else if (config.buildType === 'bundle') {\n config.input = await getDefaultIndexEntry(context);\n } else if (config.buildType === 'bundleless') {\n config.sourceDir = './src';\n }\n\n return config;\n};\n\nexport const getDefaultIndexEntry = async ({\n isTsProject,\n appDirectory,\n}: {\n isTsProject: boolean;\n appDirectory: string;\n}) => {\n const { fs } = await import('@modern-js/utils');\n let entry = isTsProject\n ? path.join(appDirectory, './src/index.ts')\n : path.join(appDirectory, './src/index.js');\n if (fs.existsSync(entry)) {\n return [`./${path.relative(appDirectory, entry)}`];\n }\n\n entry = isTsProject\n ? path.join(appDirectory, './src/index.tsx')\n : path.join(appDirectory, './src/index.jsx');\n if (fs.existsSync(entry)) {\n return [`./${path.relative(appDirectory, entry)}`];\n }\n\n return [];\n};\n\nexport const normalizeInput = async (\n baseConfig: BaseBuildConfig,\n options: EntryOptions,\n) => {\n if (baseConfig.buildType === 'bundleless' && !baseConfig.input) {\n const { slash } = await import('@modern-js/utils');\n return [slash(baseConfig.sourceDir)];\n }\n return getAbsInput(baseConfig.input, options);\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAYaA,oBAAkB,MAAlBA;EAUAC,aAAW,MAAXA;EAsBAC,kBAAgB,MAAhBA;EAqBAC,sBAAoB,MAApBA;EAyBAC,gBAAc,MAAdA;;;;iEA1FI;AAYV,MAAMJ,qBACX,CAACK,SAAiB,CAACC,IAAYC,aAAqB;AAClD,QAAMC,WAAWD,SAASE,KAAI,EAAGC,WAAWL;AAC5C,MAAIG,UAAU;AACZ,WAAOG,cAAKC,KAAKP,MAAMC,IAAIC,SAASM,QAAQR,MAAM;EACpD;AAEA,SAAOM,cAAKC,KAAKN,IAAIC;AACvB;AAEK,MAAMN,cAAc,OAAOa,OAAcC,YAA0B;AACxE,QAAM,EAAEC,MAAK,IAAK,MAAM,iFAAO;AAC/B,QAAM,EAAEC,aAAY,IAAKF;AACzB,QAAMG,6BAA6BlB,mBAAmB;AAEtD,MAAImB,MAAMC,QAAQN,QAAQ;AACxB,WAAOA,MAAMO,IAAIC,OACfX,cAAKY,WAAWD,KACZN,MAAMM,KACNN,MAAME,2BAA2BD,cAAcK,GAAG;EAE1D;AAEA,QAAME,WAAmC,CAAC;AAC1C,aAAWC,OAAOC,OAAOC,KAAKb,QAAQ;AACpCU,aAASC,OAAOd,cAAKY,WAAWT,MAAMW,IAAI,IACtCT,MAAMF,MAAMW,IAAI,IAChBT,MAAME,2BAA2BD,cAAcH,MAAMW,IAAI;EAC/D;AACA,SAAOD;AACT;AAEO,MAAMtB,mBAAmB,OAC9B0B,QACAC,YACG;AACH,MAAIV,MAAMC,QAAQQ,SAAS;AACzB,eAAWE,KAAKF,QAAQ;AACtB,UAAIE,EAAEC,cAAc,UAAU;AAC5BD,UAAEE,QAAQ,MAAM7B,qBAAqB0B;MACvC,WAAWC,EAAEC,cAAc,cAAc;AACvCD,UAAEG,YAAY;MAChB;IACF;EACF,WAAWL,OAAOG,cAAc,UAAU;AACxCH,WAAOI,QAAQ,MAAM7B,qBAAqB0B;EAC5C,WAAWD,OAAOG,cAAc,cAAc;AAC5CH,WAAOK,YAAY;EACrB;AAEA,SAAOL;AACT;AAEO,MAAMzB,uBAAuB,OAAO,EACzC+B,aACAjB,aAAY,MAIR;AACJ,QAAM,EAAEkB,GAAE,IAAK,MAAM,iFAAO;AAC5B,MAAIrB,QAAQoB,cACRvB,cAAKC,KAAKK,cAAc,oBACxBN,cAAKC,KAAKK,cAAc;AAC5B,MAAIkB,GAAGC,WAAWtB,QAAQ;AACxB,WAAO;MAAC,KAAKH,cAAK0B,SAASpB,cAAcH;;EAC3C;AAEAA,UAAQoB,cACJvB,cAAKC,KAAKK,cAAc,qBACxBN,cAAKC,KAAKK,cAAc;AAC5B,MAAIkB,GAAGC,WAAWtB,QAAQ;AACxB,WAAO;MAAC,KAAKH,cAAK0B,SAASpB,cAAcH;;EAC3C;AAEA,SAAO;AACT;AAEO,MAAMV,iBAAiB,OAC5BkC,YACAvB,YACG;AACH,MAAIuB,WAAWP,cAAc,gBAAgB,CAACO,WAAWN,OAAO;AAC9D,UAAM,EAAEhB,MAAK,IAAK,MAAM,iFAAO;AAC/B,WAAO;MAACA,MAAMsB,WAAWL,SAAS;;EACpC;AACA,SAAOhC,YAAYqC,WAAWN,OAAOjB;AACvC;","names":["joinPathWithPrefix","getAbsInput","addInputToPreset","getDefaultIndexEntry","normalizeInput","flag","p1","globPath","haveFlag","trim","startsWith","path","join","replace","entry","options","slash","appDirectory","resolvePathWithNoMatchFlag","Array","isArray","map","p","isAbsolute","newEntry","key","Object","keys","config","context","c","buildType","input","sourceDir","isTsProject","fs","existsSync","relative","baseConfig"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/input.ts"],"sourcesContent":["import path from 'path';\nimport { ModuleContext } from '../types';\nimport type {\n Input,\n BaseBuildConfig,\n PartialBuildConfig,\n} from '../types/config';\n\ninterface EntryOptions {\n appDirectory: string;\n}\n\nexport const joinPathWithPrefix =\n (flag: string) => (p1: string, globPath: string) => {\n const haveFlag = globPath.trim().startsWith(flag);\n if (haveFlag) {\n return path.join(flag, p1, globPath.replace(flag, ''));\n }\n\n return path.join(p1, globPath);\n };\n\nexport const getAbsInput = async (entry: Input, options: EntryOptions) => {\n const { slash } = await import('@modern-js/utils');\n const { appDirectory } = options;\n const resolvePathWithNoMatchFlag = joinPathWithPrefix('!');\n\n if (Array.isArray(entry)) {\n return entry.map(p =>\n path.isAbsolute(p)\n ? slash(p)\n : slash(resolvePathWithNoMatchFlag(appDirectory, p)),\n );\n }\n\n const newEntry: Record<string, string> = {};\n for (const key of Object.keys(entry)) {\n newEntry[key] = path.isAbsolute(entry[key])\n ? slash(entry[key])\n : slash(resolvePathWithNoMatchFlag(appDirectory, entry[key]));\n }\n return newEntry;\n};\n\nexport const addInputToPreset = async (\n config: PartialBuildConfig,\n context: ModuleContext,\n) => {\n if (Array.isArray(config)) {\n for (const c of config) {\n if (c.buildType === 'bundle') {\n c.input = await getDefaultIndexEntry(context);\n } else if (c.buildType === 'bundleless') {\n c.sourceDir = './src';\n }\n }\n } else if (config.buildType === 'bundle') {\n config.input = await getDefaultIndexEntry(context);\n } else if (config.buildType === 'bundleless') {\n config.sourceDir = './src';\n }\n\n return config;\n};\n\nexport const getDefaultIndexEntry = async ({\n isTsProject,\n appDirectory,\n}: {\n isTsProject: boolean;\n appDirectory: string;\n}) => {\n const { fs } = await import('@modern-js/utils');\n let entry = isTsProject\n ? path.join(appDirectory, './src/index.ts')\n : path.join(appDirectory, './src/index.js');\n if (fs.existsSync(entry)) {\n return [`./${path.relative(appDirectory, entry)}`];\n }\n\n entry = isTsProject\n ? path.join(appDirectory, './src/index.tsx')\n : path.join(appDirectory, './src/index.jsx');\n if (fs.existsSync(entry)) {\n return [`./${path.relative(appDirectory, entry)}`];\n }\n\n return [];\n};\n\nexport const normalizeInput = async (\n baseConfig: BaseBuildConfig,\n options: EntryOptions,\n) => {\n if (baseConfig.buildType === 'bundleless' && !baseConfig.input) {\n const { slash } = await import('@modern-js/utils');\n return [slash(baseConfig.sourceDir)];\n }\n return getAbsInput(baseConfig.input, options);\n};\n"]}
@@ -1,65 +1,20 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var __async = (__this, __arguments, generator) => {
29
- return new Promise((resolve, reject) => {
30
- var fulfilled = (value) => {
31
- try {
32
- step(generator.next(value));
33
- } catch (e) {
34
- reject(e);
35
- }
36
- };
37
- var rejected = (value) => {
38
- try {
39
- step(generator.throw(value));
40
- } catch (e) {
41
- reject(e);
42
- }
43
- };
44
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
45
- step((generator = generator.apply(__this, __arguments)).next());
46
- });
47
- };
48
- var language_exports = {};
49
- __export(language_exports, {
50
- initLocalLanguage: () => initLocalLanguage
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "initLocalLanguage", {
6
+ enumerable: true,
7
+ get: () => initLocalLanguage
51
8
  });
52
- module.exports = __toCommonJS(language_exports);
53
- const initLocalLanguage = () => __async(void 0, null, function* () {
54
- const local = yield Promise.resolve().then(() => __toESM(require("../locale")));
55
- const { getLocaleLanguage } = yield Promise.resolve().then(() => __toESM(require("@modern-js/plugin-i18n/language-detector")));
9
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
10
+ const initLocalLanguage = async () => {
11
+ const local = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../locale")));
12
+ const { getLocaleLanguage } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/plugin-i18n/language-detector")));
56
13
  const locale = getLocaleLanguage();
57
- local.i18n.changeLanguage({ locale });
14
+ local.i18n.changeLanguage({
15
+ locale
16
+ });
58
17
  return local;
59
- });
60
- // Annotate the CommonJS export names for ESM import in node:
61
- 0 && (module.exports = {
62
- initLocalLanguage
63
- });
18
+ };
64
19
 
65
20
  //# sourceMappingURL=language.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,oBAAoB,MAAY;AAC3C,QAAM,QAAQ,MAAM,6CAAO,WAAW;AACtC,QAAM,EAAE,kBAAkB,IAAI,MAAM,6CAClC,0CACF;AACA,QAAM,SAAS,kBAAkB;AACjC,QAAM,KAAK,eAAe,EAAE,OAAO,CAAC;AACpC,SAAO;AACT;;;;;","names":[],"sources":["../../src/utils/language.ts"],"sourcesContent":["export const initLocalLanguage = async () => {\n const local = await import('../locale');\n const { getLocaleLanguage } = await import(\n '@modern-js/plugin-i18n/language-detector'\n );\n const locale = getLocaleLanguage();\n local.i18n.changeLanguage({ locale });\n return local;\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;+BAAaA;;aAAAA;;;AAAN,MAAMA,oBAAoB,YAAY;AAC3C,QAAMC,QAAQ,MAAM,iFAAO;AAC3B,QAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAClC;AAEF,QAAMC,SAASD;AACfD,QAAMG,KAAKC,eAAe;IAAEF;EAAO;AACnC,SAAOF;AACT;","names":["initLocalLanguage","local","getLocaleLanguage","locale","i18n","changeLanguage"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/language.ts"],"sourcesContent":["export const initLocalLanguage = async () => {\n const local = await import('../locale');\n const { getLocaleLanguage } = await import(\n '@modern-js/plugin-i18n/language-detector'\n );\n const locale = getLocaleLanguage();\n local.i18n.changeLanguage({ locale });\n return local;\n};\n"]}