@modern-js/module-tools 2.10.1-beta.0 → 2.10.1-beta.1

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 (62) hide show
  1. package/dist/build.js +29 -9
  2. package/dist/build.js.map +1 -1
  3. package/dist/builder/build.js +86 -48
  4. package/dist/builder/build.js.map +1 -1
  5. package/dist/builder/clear.js +29 -9
  6. package/dist/builder/clear.js.map +1 -1
  7. package/dist/builder/copy.js +78 -39
  8. package/dist/builder/copy.js.map +1 -1
  9. package/dist/builder/dts/rollup.js +61 -26
  10. package/dist/builder/dts/rollup.js.map +1 -1
  11. package/dist/builder/dts/tsc.js +77 -37
  12. package/dist/builder/dts/tsc.js.map +1 -1
  13. package/dist/builder/index.js +36 -16
  14. package/dist/builder/index.js.map +1 -1
  15. package/dist/builder/platform.js +33 -13
  16. package/dist/builder/platform.js.map +1 -1
  17. package/dist/cli.js +45 -23
  18. package/dist/cli.js.map +1 -1
  19. package/dist/command.js +76 -39
  20. package/dist/command.js.map +1 -1
  21. package/dist/config/defineConfig.js +18 -2
  22. package/dist/config/defineConfig.js.map +1 -1
  23. package/dist/config/normalize.js +73 -45
  24. package/dist/config/normalize.js.map +1 -1
  25. package/dist/config/transformLegacyConfig.js +130 -90
  26. package/dist/config/transformLegacyConfig.js.map +1 -1
  27. package/dist/constants/buildPresets.js +23 -14
  28. package/dist/constants/buildPresets.js.map +1 -1
  29. package/dist/dev.js +43 -19
  30. package/dist/dev.js.map +1 -1
  31. package/dist/error.js +2 -7
  32. package/dist/error.js.map +1 -1
  33. package/dist/hooks/index.js +15 -6
  34. package/dist/hooks/index.js.map +1 -1
  35. package/dist/utils/builder.js +27 -7
  36. package/dist/utils/builder.js.map +1 -1
  37. package/dist/utils/common.js +19 -3
  38. package/dist/utils/common.js.map +1 -1
  39. package/dist/utils/config.js +83 -57
  40. package/dist/utils/config.js.map +1 -1
  41. package/dist/utils/context.js +23 -3
  42. package/dist/utils/context.js.map +1 -1
  43. package/dist/utils/dts.js +64 -25
  44. package/dist/utils/dts.js.map +1 -1
  45. package/dist/utils/input.js +34 -14
  46. package/dist/utils/input.js.map +1 -1
  47. package/dist/utils/language.js +23 -3
  48. package/dist/utils/language.js.map +1 -1
  49. package/dist/utils/libuildPlugins.js +29 -9
  50. package/dist/utils/libuildPlugins.js.map +1 -1
  51. package/dist/utils/log.js +23 -3
  52. package/dist/utils/log.js.map +1 -1
  53. package/dist/utils/onExit.js +26 -6
  54. package/dist/utils/onExit.js.map +1 -1
  55. package/dist/utils/path.js +23 -3
  56. package/dist/utils/path.js.map +1 -1
  57. package/dist/utils/print.js +24 -4
  58. package/dist/utils/print.js.map +1 -1
  59. package/dist/utils/style.js +52 -29
  60. package/dist/utils/style.js.map +1 -1
  61. package/lib/types.d.ts +0 -98
  62. package/package.json +5 -5
@@ -25,17 +25,37 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
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
+ };
28
48
  var context_exports = {};
29
49
  __export(context_exports, {
30
50
  initModuleContext: () => initModuleContext
31
51
  });
32
52
  module.exports = __toCommonJS(context_exports);
33
- const initModuleContext = async (api) => {
34
- const { isTypescript } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
53
+ const initModuleContext = (api) => __async(void 0, null, function* () {
54
+ const { isTypescript } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
35
55
  const { appDirectory, srcDirectory } = api.useAppContext();
36
56
  const isTsProject = isTypescript(appDirectory);
37
57
  return { isTsProject, appDirectory, srcDirectory };
38
- };
58
+ });
39
59
  // Annotate the CommonJS export names for ESM import in node:
40
60
  0 && (module.exports = {
41
61
  initModuleContext
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,oBAAoB,OAAO,QAAgC;AACtE,QAAM,EAAE,aAAa,IAAI,MAAM,6CAAO,kBAAkB;AACxD,QAAM,EAAE,cAAc,aAAa,IAAI,IAAI,cAAc;AACzD,QAAM,cAAc,aAAa,YAAY;AAE7C,SAAO,EAAE,aAAa,cAAc,aAAa;AACnD;;;;;","names":[],"sources":["../../src/utils/context.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport type { ModuleTools } from '../types';\n\nexport const initModuleContext = async (api: PluginAPI<ModuleTools>) => {\n const { isTypescript } = await import('@modern-js/utils');\n const { appDirectory, srcDirectory } = api.useAppContext();\n const isTsProject = isTypescript(appDirectory);\n\n return { isTsProject, appDirectory, srcDirectory };\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,oBAAoB,CAAO,QAAgC;AACtE,QAAM,EAAE,aAAa,IAAI,MAAM,6CAAO,kBAAkB;AACxD,QAAM,EAAE,cAAc,aAAa,IAAI,IAAI,cAAc;AACzD,QAAM,cAAc,aAAa,YAAY;AAE7C,SAAO,EAAE,aAAa,cAAc,aAAa;AACnD;;;;;","names":[],"sources":["../../src/utils/context.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport type { ModuleTools } from '../types';\n\nexport const initModuleContext = async (api: PluginAPI<ModuleTools>) => {\n const { isTypescript } = await import('@modern-js/utils');\n const { appDirectory, srcDirectory } = api.useAppContext();\n const isTsProject = isTypescript(appDirectory);\n\n return { isTsProject, appDirectory, srcDirectory };\n};\n"]}
package/dist/utils/dts.js CHANGED
@@ -1,9 +1,26 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
8
  var __getProtoOf = Object.getPrototypeOf;
6
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));
7
24
  var __export = (target, all) => {
8
25
  for (var name in all)
9
26
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -25,6 +42,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
42
  mod
26
43
  ));
27
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
+ };
28
65
  var dts_exports = {};
29
66
  __export(dts_exports, {
30
67
  assignTsConfigPath: () => assignTsConfigPath,
@@ -34,9 +71,9 @@ __export(dts_exports, {
34
71
  });
35
72
  module.exports = __toCommonJS(dts_exports);
36
73
  var import_path = __toESM(require("path"));
37
- const generatorTsConfig = async (config) => {
38
- const { fs, nanoid } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
39
- const { dtsTempDirectory } = await Promise.resolve().then(() => __toESM(require("../constants/dts")));
74
+ const generatorTsConfig = (config) => __async(void 0, null, function* () {
75
+ const { fs, nanoid } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
76
+ const { dtsTempDirectory } = yield Promise.resolve().then(() => __toESM(require("../constants/dts")));
40
77
  const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;
41
78
  const tempDistAbsRootPath = import_path.default.join(
42
79
  appDirectory,
@@ -67,19 +104,19 @@ const generatorTsConfig = async (config) => {
67
104
  tempDistAbsRootPath,
68
105
  tempDistAbsSrcPath: tempDistAbsOurDir
69
106
  };
70
- };
71
- const getTscBinPath = async (appDirectory) => {
72
- const { fs } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
73
- const { default: findUp, exists: pathExists } = await Promise.resolve().then(() => __toESM(require("../../compiled/find-up")));
74
- const tscBinFile = await findUp(
75
- async (directory) => {
107
+ });
108
+ const getTscBinPath = (appDirectory) => __async(void 0, null, function* () {
109
+ const { fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
110
+ const { default: findUp, exists: pathExists } = yield Promise.resolve().then(() => __toESM(require("../../compiled/find-up")));
111
+ const tscBinFile = yield findUp(
112
+ (directory) => __async(void 0, null, function* () {
76
113
  const targetFilePath = import_path.default.join(directory, "./node_modules/.bin/tsc");
77
- const hasTscBinFile = await pathExists(targetFilePath);
114
+ const hasTscBinFile = yield pathExists(targetFilePath);
78
115
  if (hasTscBinFile) {
79
116
  return targetFilePath;
80
117
  }
81
118
  return void 0;
82
- },
119
+ }),
83
120
  { cwd: appDirectory }
84
121
  );
85
122
  if (!tscBinFile || !fs.existsSync(tscBinFile)) {
@@ -88,36 +125,38 @@ const getTscBinPath = async (appDirectory) => {
88
125
  );
89
126
  }
90
127
  return tscBinFile;
91
- };
92
- const resolveAlias = async (config, options, watchFilenames = []) => {
128
+ });
129
+ const resolveAlias = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (config, options, watchFilenames = []) {
130
+ var _a, _b;
93
131
  const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;
94
- const { globby, fs } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
95
- const { transformDtsAlias } = await Promise.resolve().then(() => __toESM(require("./tspathsTransform")));
132
+ const { globby, fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
133
+ const { transformDtsAlias } = yield Promise.resolve().then(() => __toESM(require("./tspathsTransform")));
96
134
  const { distAbsPath } = config;
97
135
  const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;
98
136
  const dtsFilenames = watchFilenames.length > 0 ? watchFilenames : globby.sync(dtsDistPath, { absolute: true });
99
137
  const result = transformDtsAlias({
100
138
  filenames: dtsFilenames,
101
139
  baseUrl: tempDistAbsRootPath,
102
- paths: userTsconfig.compilerOptions?.paths ?? {}
140
+ paths: (_b = (_a = userTsconfig.compilerOptions) == null ? void 0 : _a.paths) != null ? _b : {}
103
141
  });
104
142
  for (const r of result) {
105
143
  fs.writeFileSync(r.path, r.content);
106
144
  }
107
- await fs.copy(tempDistAbsSrcPath, distAbsPath);
108
- };
109
- const assignTsConfigPath = async (config, options) => {
110
- const { defaultTsConfigPath } = await Promise.resolve().then(() => __toESM(require("../constants/dts")));
145
+ yield fs.copy(tempDistAbsSrcPath, distAbsPath);
146
+ });
147
+ const assignTsConfigPath = (config, options) => __async(void 0, null, function* () {
148
+ var _a;
149
+ const { defaultTsConfigPath } = yield Promise.resolve().then(() => __toESM(require("../constants/dts")));
111
150
  if (typeof options.tsconfig === "string" && options.tsconfig !== defaultTsConfigPath) {
112
- config.dts = {
151
+ config.dts = __spreadProps(__spreadValues({
113
152
  only: false,
114
- distPath: "./",
115
- ...config.dts ?? {},
153
+ distPath: "./"
154
+ }, (_a = config.dts) != null ? _a : {}), {
116
155
  tsconfigPath: options.tsconfig
117
- };
156
+ });
118
157
  }
119
158
  return config;
120
- };
159
+ });
121
160
  // Annotate the CommonJS export names for ESM import in node:
122
161
  0 && (module.exports = {
123
162
  assignTsConfigPath,
@@ -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 // 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(tempDistAbsRootPath, `tsconfig.json`);\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 outDir: 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 ...(config.dts ?? {}),\n tsconfigPath: options.tsconfig,\n };\n }\n\n return config;\n};\n"]}
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 // 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(tempDistAbsRootPath, `tsconfig.json`);\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 outDir: 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 ...(config.dts ?? {}),\n tsconfigPath: options.tsconfig,\n };\n }\n\n return config;\n};\n"]}
@@ -25,6 +25,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
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
+ };
28
48
  var input_exports = {};
29
49
  __export(input_exports, {
30
50
  addInputToPreset: () => addInputToPreset,
@@ -34,8 +54,8 @@ __export(input_exports, {
34
54
  });
35
55
  module.exports = __toCommonJS(input_exports);
36
56
  var import_path = __toESM(require("path"));
37
- const getAbsInput = async (entry, options) => {
38
- const { slash } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
57
+ const getAbsInput = (entry, options) => __async(void 0, null, function* () {
58
+ const { slash } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
39
59
  const { appDirectory } = options;
40
60
  if (Array.isArray(entry)) {
41
61
  return entry.map(
@@ -47,28 +67,28 @@ const getAbsInput = async (entry, options) => {
47
67
  newEntry[key] = import_path.default.isAbsolute(entry[key]) ? slash(entry[key]) : slash(import_path.default.join(appDirectory, entry[key]));
48
68
  }
49
69
  return newEntry;
50
- };
51
- const addInputToPreset = async (config, context) => {
70
+ });
71
+ const addInputToPreset = (config, context) => __async(void 0, null, function* () {
52
72
  if (Array.isArray(config)) {
53
73
  for (const c of config) {
54
74
  if (c.buildType === "bundle") {
55
- c.input = await getDefaultIndexEntry(context);
75
+ c.input = yield getDefaultIndexEntry(context);
56
76
  } else if (c.buildType === "bundleless") {
57
77
  c.sourceDir = "./src";
58
78
  }
59
79
  }
60
80
  } else if (config.buildType === "bundle") {
61
- config.input = await getDefaultIndexEntry(context);
81
+ config.input = yield getDefaultIndexEntry(context);
62
82
  } else if (config.buildType === "bundleless") {
63
83
  config.sourceDir = "./src";
64
84
  }
65
85
  return config;
66
- };
67
- const getDefaultIndexEntry = async ({
86
+ });
87
+ const getDefaultIndexEntry = (_0) => __async(void 0, [_0], function* ({
68
88
  isTsProject,
69
89
  appDirectory
70
- }) => {
71
- const { fs } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
90
+ }) {
91
+ const { fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
72
92
  let entry = isTsProject ? import_path.default.join(appDirectory, "./src/index.ts") : import_path.default.join(appDirectory, "./src/index.js");
73
93
  if (fs.existsSync(entry)) {
74
94
  return [`./${import_path.default.relative(appDirectory, entry)}`];
@@ -78,14 +98,14 @@ const getDefaultIndexEntry = async ({
78
98
  return [`./${import_path.default.relative(appDirectory, entry)}`];
79
99
  }
80
100
  return [];
81
- };
82
- const normalizeInput = async (baseConfig, options) => {
101
+ });
102
+ const normalizeInput = (baseConfig, options) => __async(void 0, null, function* () {
83
103
  if (baseConfig.buildType === "bundleless" && !baseConfig.input) {
84
- const { slash } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
104
+ const { slash } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
85
105
  return [slash(baseConfig.sourceDir)];
86
106
  }
87
107
  return getAbsInput(baseConfig.input, options);
88
- };
108
+ });
89
109
  // Annotate the CommonJS export names for ESM import in node:
90
110
  0 && (module.exports = {
91
111
  addInputToPreset,
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAYV,MAAM,cAAc,OAAO,OAAc,YAA0B;AACxE,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,QAAM,EAAE,aAAa,IAAI;AAEzB,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM;AAAA,MAAI,OACf,oBAAK,WAAW,CAAC,IAAI,MAAM,CAAC,IAAI,MAAM,oBAAK,KAAK,cAAc,CAAC,CAAC;AAAA,IAClE;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,oBAAK,KAAK,cAAc,MAAM,GAAG,CAAC,CAAC;AAAA,EAC/C;AACA,SAAO;AACT;AAEO,MAAM,mBAAmB,OAC9B,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,OAAO;AAAA,EACzC;AAAA,EACA;AACF,MAGM;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,OAC5B,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 getAbsInput = async (entry: Input, options: EntryOptions) => {\n const { slash } = await import('@modern-js/utils');\n const { appDirectory } = options;\n\n if (Array.isArray(entry)) {\n return entry.map(p =>\n path.isAbsolute(p) ? slash(p) : slash(path.join(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(path.join(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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAYV,MAAM,cAAc,CAAO,OAAc,YAA0B;AACxE,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,QAAM,EAAE,aAAa,IAAI;AAEzB,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM;AAAA,MAAI,OACf,oBAAK,WAAW,CAAC,IAAI,MAAM,CAAC,IAAI,MAAM,oBAAK,KAAK,cAAc,CAAC,CAAC;AAAA,IAClE;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,oBAAK,KAAK,cAAc,MAAM,GAAG,CAAC,CAAC;AAAA,EAC/C;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 getAbsInput = async (entry: Input, options: EntryOptions) => {\n const { slash } = await import('@modern-js/utils');\n const { appDirectory } = options;\n\n if (Array.isArray(entry)) {\n return entry.map(p =>\n path.isAbsolute(p) ? slash(p) : slash(path.join(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(path.join(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"]}
@@ -25,6 +25,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
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
+ };
28
48
  var language_exports = {};
29
49
  __export(language_exports, {
30
50
  getLocaleLanguage: () => getLocaleLanguage,
@@ -37,12 +57,12 @@ function getLocaleLanguage() {
37
57
  const detector = new i18n.I18CLILanguageDetector();
38
58
  return detector.detect();
39
59
  }
40
- const initLocalLanguage = async () => {
41
- const local = await Promise.resolve().then(() => __toESM(require("../locale")));
60
+ const initLocalLanguage = () => __async(void 0, null, function* () {
61
+ const local = yield Promise.resolve().then(() => __toESM(require("../locale")));
42
62
  const locale = getLocaleLanguage();
43
63
  local.i18n.changeLanguage({ locale });
44
64
  return local;
45
- };
65
+ });
46
66
  // Annotate the CommonJS export names for ESM import in node:
47
67
  0 && (module.exports = {
48
68
  getLocaleLanguage,
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AAEvB,MAAM,OACJ,oBAAO,KAAK,4CAA4C,OAAO;AAE1D,SAAS,oBAAoB;AAClC,QAAM,WAAW,IAAI,KAAK,uBAAuB;AACjD,SAAO,SAAS,OAAO;AACzB;AAEO,MAAM,oBAAoB,YAAY;AAC3C,QAAM,QAAQ,MAAM,6CAAO,WAAW;AACtC,QAAM,SAAS,kBAAkB;AACjC,QAAM,KAAK,eAAe,EAAE,OAAO,CAAC;AACpC,SAAO;AACT;;;;;;","names":[],"sources":["../../src/utils/language.ts"],"sourcesContent":["import { Import } from '@modern-js/utils';\n\nconst i18n: typeof import('@modern-js/plugin-i18n/language-detector') =\n Import.lazy('@modern-js/plugin-i18n/language-detector', require);\n\nexport function getLocaleLanguage() {\n const detector = new i18n.I18CLILanguageDetector();\n return detector.detect();\n}\n\nexport const initLocalLanguage = async () => {\n const local = await import('../locale');\n const locale = getLocaleLanguage();\n local.i18n.changeLanguage({ locale });\n return local;\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AAEvB,MAAM,OACJ,oBAAO,KAAK,4CAA4C,OAAO;AAE1D,SAAS,oBAAoB;AAClC,QAAM,WAAW,IAAI,KAAK,uBAAuB;AACjD,SAAO,SAAS,OAAO;AACzB;AAEO,MAAM,oBAAoB,MAAY;AAC3C,QAAM,QAAQ,MAAM,6CAAO,WAAW;AACtC,QAAM,SAAS,kBAAkB;AACjC,QAAM,KAAK,eAAe,EAAE,OAAO,CAAC;AACpC,SAAO;AACT;;;;;;","names":[],"sources":["../../src/utils/language.ts"],"sourcesContent":["import { Import } from '@modern-js/utils';\n\nconst i18n: typeof import('@modern-js/plugin-i18n/language-detector') =\n Import.lazy('@modern-js/plugin-i18n/language-detector', require);\n\nexport function getLocaleLanguage() {\n const detector = new i18n.I18CLILanguageDetector();\n return detector.detect();\n}\n\nexport const initLocalLanguage = async () => {\n const local = await import('../locale');\n const locale = getLocaleLanguage();\n local.i18n.changeLanguage({ locale });\n return local;\n};\n"]}
@@ -25,6 +25,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
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
+ };
28
48
  var libuildPlugins_exports = {};
29
49
  __export(libuildPlugins_exports, {
30
50
  externalPlugin: () => externalPlugin,
@@ -35,16 +55,16 @@ const watchPlugin = (api, config) => {
35
55
  return {
36
56
  name: "watch-plugin",
37
57
  apply(compiler) {
38
- compiler.hooks.watchChange.tap("watch-plugin", async () => {
39
- const { watchSectionTitle } = await Promise.resolve().then(() => __toESM(require("./log")));
40
- const { SectionTitleStatus } = await Promise.resolve().then(() => __toESM(require("../constants/log")));
58
+ compiler.hooks.watchChange.tap("watch-plugin", () => __async(this, null, function* () {
59
+ const { watchSectionTitle } = yield Promise.resolve().then(() => __toESM(require("./log")));
60
+ const { SectionTitleStatus } = yield Promise.resolve().then(() => __toESM(require("../constants/log")));
41
61
  const titleText = `[${config.buildType === "bundle" ? "Bundle" : "Bundleless"}:${config.format}_${config.target}]`;
42
62
  console.info(
43
- await watchSectionTitle(titleText, SectionTitleStatus.Log)
63
+ yield watchSectionTitle(titleText, SectionTitleStatus.Log)
44
64
  );
45
65
  const runner = api.useHookRunners();
46
66
  runner.buildWatchJs({ buildConfig: config });
47
- });
67
+ }));
48
68
  }
49
69
  };
50
70
  };
@@ -52,11 +72,11 @@ const externalPlugin = (config, options) => {
52
72
  return {
53
73
  name: "external-plugin",
54
74
  apply(compiler) {
55
- compiler.hooks.initialize.tapPromise("external-plugin", async () => {
56
- const { getFinalExternals } = await Promise.resolve().then(() => __toESM(require("./builder")));
57
- const finalExternals = await getFinalExternals(config, options);
75
+ compiler.hooks.initialize.tapPromise("external-plugin", () => __async(this, null, function* () {
76
+ const { getFinalExternals } = yield Promise.resolve().then(() => __toESM(require("./builder")));
77
+ const finalExternals = yield getFinalExternals(config, options);
58
78
  compiler.config.external = finalExternals;
59
- });
79
+ }));
60
80
  }
61
81
  };
62
82
  };
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,cAAc,CACzB,KACA,WACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,YAAY,IAAI,gBAAgB,YAAY;AACzD,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,OAAO;AAClD,cAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,kBAAkB;AAC9D,cAAM,YAAY,IAChB,OAAO,cAAc,WAAW,WAAW,gBACzC,OAAO,UAAU,OAAO;AAC5B,gBAAQ;AAAA,UACN,MAAM,kBAAkB,WAAW,mBAAmB,GAAG;AAAA,QAC3D;AACA,cAAM,SAAS,IAAI,eAAe;AAClC,eAAO,aAAa,EAAE,aAAa,OAAO,CAAC;AAAA,MAC7C,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,MAAM,iBAAiB,CAC5B,QACA,YACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,WAAW,WAAW,mBAAmB,YAAY;AAClE,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,WAAW;AACtD,cAAM,iBAAiB,MAAM,kBAAkB,QAAQ,OAAO;AAC9D,iBAAS,OAAO,WAAW;AAAA,MAC7B,CAAC;AAAA,IACH;AAAA,EACF;AACF;;;;;;","names":[],"sources":["../../src/utils/libuildPlugins.ts"],"sourcesContent":["import type { LibuildPlugin } from '@modern-js/libuild';\nimport type { BaseBuildConfig, PluginAPI, ModuleTools } from '../types';\n\nexport const watchPlugin = (\n api: PluginAPI<ModuleTools>,\n config: BaseBuildConfig,\n): LibuildPlugin => {\n return {\n name: 'watch-plugin',\n apply(compiler) {\n compiler.hooks.watchChange.tap('watch-plugin', async () => {\n const { watchSectionTitle } = await import('./log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n config.buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }:${config.format}_${config.target}]`;\n console.info(\n await watchSectionTitle(titleText, SectionTitleStatus.Log),\n );\n const runner = api.useHookRunners();\n runner.buildWatchJs({ buildConfig: config });\n });\n },\n };\n};\n\nexport const externalPlugin = (\n config: BaseBuildConfig,\n options: { appDirectory: string },\n): LibuildPlugin => {\n return {\n name: 'external-plugin',\n apply(compiler) {\n compiler.hooks.initialize.tapPromise('external-plugin', async () => {\n const { getFinalExternals } = await import('./builder');\n const finalExternals = await getFinalExternals(config, options);\n compiler.config.external = finalExternals;\n });\n },\n };\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,cAAc,CACzB,KACA,WACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,YAAY,IAAI,gBAAgB,MAAY;AACzD,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,OAAO;AAClD,cAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,kBAAkB;AAC9D,cAAM,YAAY,IAChB,OAAO,cAAc,WAAW,WAAW,gBACzC,OAAO,UAAU,OAAO;AAC5B,gBAAQ;AAAA,UACN,MAAM,kBAAkB,WAAW,mBAAmB,GAAG;AAAA,QAC3D;AACA,cAAM,SAAS,IAAI,eAAe;AAClC,eAAO,aAAa,EAAE,aAAa,OAAO,CAAC;AAAA,MAC7C,EAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,MAAM,iBAAiB,CAC5B,QACA,YACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,WAAW,WAAW,mBAAmB,MAAY;AAClE,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,WAAW;AACtD,cAAM,iBAAiB,MAAM,kBAAkB,QAAQ,OAAO;AAC9D,iBAAS,OAAO,WAAW;AAAA,MAC7B,EAAC;AAAA,IACH;AAAA,EACF;AACF;;;;;;","names":[],"sources":["../../src/utils/libuildPlugins.ts"],"sourcesContent":["import type { LibuildPlugin } from '@modern-js/libuild';\nimport type { BaseBuildConfig, PluginAPI, ModuleTools } from '../types';\n\nexport const watchPlugin = (\n api: PluginAPI<ModuleTools>,\n config: BaseBuildConfig,\n): LibuildPlugin => {\n return {\n name: 'watch-plugin',\n apply(compiler) {\n compiler.hooks.watchChange.tap('watch-plugin', async () => {\n const { watchSectionTitle } = await import('./log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n config.buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }:${config.format}_${config.target}]`;\n console.info(\n await watchSectionTitle(titleText, SectionTitleStatus.Log),\n );\n const runner = api.useHookRunners();\n runner.buildWatchJs({ buildConfig: config });\n });\n },\n };\n};\n\nexport const externalPlugin = (\n config: BaseBuildConfig,\n options: { appDirectory: string },\n): LibuildPlugin => {\n return {\n name: 'external-plugin',\n apply(compiler) {\n compiler.hooks.initialize.tapPromise('external-plugin', async () => {\n const { getFinalExternals } = await import('./builder');\n const finalExternals = await getFinalExternals(config, options);\n compiler.config.external = finalExternals;\n });\n },\n };\n};\n"]}
package/dist/utils/log.js CHANGED
@@ -25,14 +25,34 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
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
+ };
28
48
  var log_exports = {};
29
49
  __export(log_exports, {
30
50
  watchSectionTitle: () => watchSectionTitle
31
51
  });
32
52
  module.exports = __toCommonJS(log_exports);
33
53
  var import_log = require("../constants/log");
34
- const watchSectionTitle = async (str, status, detailLog) => {
35
- const { chalk } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
54
+ const watchSectionTitle = (str, status, detailLog) => __async(void 0, null, function* () {
55
+ const { chalk } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
36
56
  if (status === import_log.SectionTitleStatus.Success) {
37
57
  return `${chalk.bgWhite.gray.underline(str)} ${chalk.green.underline(
38
58
  "Successful"
@@ -43,7 +63,7 @@ const watchSectionTitle = async (str, status, detailLog) => {
43
63
  )}`;
44
64
  }
45
65
  return `${chalk.bgWhite.gray.underline(str)} ${detailLog ? detailLog : chalk.blue.underline("Log")}`;
46
- };
66
+ });
47
67
  // Annotate the CommonJS export names for ESM import in node:
48
68
  0 && (module.exports = {
49
69
  watchSectionTitle
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAmC;AAE5B,MAAM,oBAAoB,OAC/B,KACA,QACA,cACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,MAAI,WAAW,8BAAmB,SAAS;AACzC,WAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KAAK,MAAM,MAAM;AAAA,MACzD;AAAA,IACF;AAAA,EACF,WAAW,WAAW,8BAAmB,MAAM;AAC7C,WAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KAAK,MAAM,IAAI;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KACxC,YAAY,YAAY,MAAM,KAAK,UAAU,KAAK;AAEtD;;;;;","names":[],"sources":["../../src/utils/log.ts"],"sourcesContent":["import { SectionTitleStatus } from '../constants/log';\n\nexport const watchSectionTitle = async (\n str: string,\n status: SectionTitleStatus,\n detailLog?: string,\n) => {\n const { chalk } = await import('@modern-js/utils');\n if (status === SectionTitleStatus.Success) {\n return `${chalk.bgWhite.gray.underline(str)} ${chalk.green.underline(\n 'Successful',\n )}`;\n } else if (status === SectionTitleStatus.Fail) {\n return `${chalk.bgWhite.gray.underline(str)} ${chalk.red.underline(\n 'Build Failed',\n )}`;\n }\n\n return `${chalk.bgWhite.gray.underline(str)} ${\n detailLog ? detailLog : chalk.blue.underline('Log')\n }`;\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAmC;AAE5B,MAAM,oBAAoB,CAC/B,KACA,QACA,cACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,MAAI,WAAW,8BAAmB,SAAS;AACzC,WAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KAAK,MAAM,MAAM;AAAA,MACzD;AAAA,IACF;AAAA,EACF,WAAW,WAAW,8BAAmB,MAAM;AAC7C,WAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KAAK,MAAM,IAAI;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KACxC,YAAY,YAAY,MAAM,KAAK,UAAU,KAAK;AAEtD;;;;;","names":[],"sources":["../../src/utils/log.ts"],"sourcesContent":["import { SectionTitleStatus } from '../constants/log';\n\nexport const watchSectionTitle = async (\n str: string,\n status: SectionTitleStatus,\n detailLog?: string,\n) => {\n const { chalk } = await import('@modern-js/utils');\n if (status === SectionTitleStatus.Success) {\n return `${chalk.bgWhite.gray.underline(str)} ${chalk.green.underline(\n 'Successful',\n )}`;\n } else if (status === SectionTitleStatus.Fail) {\n return `${chalk.bgWhite.gray.underline(str)} ${chalk.red.underline(\n 'Build Failed',\n )}`;\n }\n\n return `${chalk.bgWhite.gray.underline(str)} ${\n detailLog ? detailLog : chalk.blue.underline('Log')\n }`;\n};\n"]}
@@ -25,20 +25,40 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
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
+ };
28
48
  var onExit_exports = {};
29
49
  __export(onExit_exports, {
30
50
  addExitListener: () => addExitListener
31
51
  });
32
52
  module.exports = __toCommonJS(onExit_exports);
33
- const addExitListener = async (fn) => {
34
- const { default: onExit } = await Promise.resolve().then(() => __toESM(require("../../compiled/signal-exit")));
35
- onExit(async (code) => {
53
+ const addExitListener = (fn) => __async(void 0, null, function* () {
54
+ const { default: onExit } = yield Promise.resolve().then(() => __toESM(require("../../compiled/signal-exit")));
55
+ onExit((code) => __async(void 0, null, function* () {
36
56
  if (code === 0) {
37
57
  return;
38
58
  }
39
- await fn();
40
- });
41
- };
59
+ yield fn();
60
+ }));
61
+ });
42
62
  // Annotate the CommonJS export names for ESM import in node:
43
63
  0 && (module.exports = {
44
64
  addExitListener
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,kBAAkB,OAAO,OAA4B;AAChE,QAAM,EAAE,SAAS,OAAO,IAAI,MAAM,6CAAO,4BAA4B;AAErE,SAAO,OAAM,SAAQ;AACnB,QAAI,SAAS,GAAG;AACd;AAAA,IACF;AAEA,UAAM,GAAG;AAAA,EACX,CAAC;AACH;;;;;","names":[],"sources":["../../src/utils/onExit.ts"],"sourcesContent":["export const addExitListener = async (fn: () => Promise<void>) => {\n const { default: onExit } = await import('../../compiled/signal-exit');\n\n onExit(async code => {\n if (code === 0) {\n return;\n }\n\n await fn();\n });\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,kBAAkB,CAAO,OAA4B;AAChE,QAAM,EAAE,SAAS,OAAO,IAAI,MAAM,6CAAO,4BAA4B;AAErE,SAAO,CAAM,SAAQ;AACnB,QAAI,SAAS,GAAG;AACd;AAAA,IACF;AAEA,UAAM,GAAG;AAAA,EACX,EAAC;AACH;;;;;","names":[],"sources":["../../src/utils/onExit.ts"],"sourcesContent":["export const addExitListener = async (fn: () => Promise<void>) => {\n const { default: onExit } = await import('../../compiled/signal-exit');\n\n onExit(async code => {\n if (code === 0) {\n return;\n }\n\n await fn();\n });\n};\n"]}
@@ -25,16 +25,36 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
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
+ };
28
48
  var path_exports = {};
29
49
  __export(path_exports, {
30
50
  getCompiledPath: () => getCompiledPath
31
51
  });
32
52
  module.exports = __toCommonJS(path_exports);
33
53
  var import_path = __toESM(require("path"));
34
- const getCompiledPath = async (packageName) => {
35
- const { slash } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
54
+ const getCompiledPath = (packageName) => __async(void 0, null, function* () {
55
+ const { slash } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
36
56
  return slash(import_path.default.join(__dirname, "../../compiled", packageName));
37
- };
57
+ });
38
58
  // Annotate the CommonJS export names for ESM import in node:
39
59
  0 && (module.exports = {
40
60
  getCompiledPath
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEV,MAAM,kBAAkB,OAAO,gBAAwB;AAC5D,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,SAAO,MAAM,oBAAK,KAAK,WAAW,kBAAkB,WAAW,CAAC;AAClE;;;;;","names":[],"sources":["../../src/utils/path.ts"],"sourcesContent":["import path from 'path';\n\nexport const getCompiledPath = async (packageName: string) => {\n const { slash } = await import('@modern-js/utils');\n return slash(path.join(__dirname, '../../compiled', packageName));\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEV,MAAM,kBAAkB,CAAO,gBAAwB;AAC5D,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,SAAO,MAAM,oBAAK,KAAK,WAAW,kBAAkB,WAAW,CAAC;AAClE;;;;;","names":[],"sources":["../../src/utils/path.ts"],"sourcesContent":["import path from 'path';\n\nexport const getCompiledPath = async (packageName: string) => {\n const { slash } = await import('@modern-js/utils');\n return slash(path.join(__dirname, '../../compiled', packageName));\n};\n"]}