@modern-js/module-tools 2.40.0 → 2.42.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 (102) hide show
  1. package/dist/build.d.ts +1 -1
  2. package/dist/build.js +6 -4
  3. package/dist/builder/build.d.ts +7 -7
  4. package/dist/builder/build.js +3 -1
  5. package/dist/builder/clear.d.ts +1 -2
  6. package/dist/builder/clear.js +2 -8
  7. package/dist/builder/copy.d.ts +9 -9
  8. package/dist/builder/dts/index.d.ts +1 -1
  9. package/dist/builder/dts/rollup.d.ts +1 -13
  10. package/dist/builder/dts/tsc.d.ts +1 -1
  11. package/dist/builder/dts/tsc.js +20 -15
  12. package/dist/builder/esbuild/adapter.d.ts +1 -1
  13. package/dist/builder/esbuild/hook.d.ts +1 -1
  14. package/dist/builder/esbuild/index.d.ts +28 -28
  15. package/dist/builder/esbuild/resolve.d.ts +9 -9
  16. package/dist/builder/esbuild/sourcemap.d.ts +14 -14
  17. package/dist/builder/esbuild/transform.d.ts +4 -4
  18. package/dist/builder/esbuild/watch.d.ts +1 -1
  19. package/dist/builder/esbuild/write-file.d.ts +1 -1
  20. package/dist/builder/feature/asset.d.ts +5 -5
  21. package/dist/builder/feature/format-cjs.d.ts +3 -3
  22. package/dist/builder/feature/index.d.ts +1 -1
  23. package/dist/builder/feature/json.d.ts +3 -3
  24. package/dist/builder/feature/redirect.d.ts +3 -3
  25. package/dist/builder/feature/style/index.d.ts +3 -3
  26. package/dist/builder/feature/style/lessAliasPlugin.d.ts +7 -7
  27. package/dist/builder/feature/style/lessAliasPlugin.js +3 -2
  28. package/dist/builder/feature/style/lessRender.d.ts +1 -1
  29. package/dist/builder/feature/style/postcssTransformer.d.ts +3 -3
  30. package/dist/builder/feature/style/postcssUrlPlugin.d.ts +3 -3
  31. package/dist/builder/feature/style/sassRender.d.ts +1 -1
  32. package/dist/builder/feature/style/transformStyle.d.ts +7 -7
  33. package/dist/builder/feature/style/utils.d.ts +3 -3
  34. package/dist/builder/feature/swc.d.ts +5 -5
  35. package/dist/builder/feature/terser.d.ts +3 -3
  36. package/dist/builder/index.d.ts +4 -4
  37. package/dist/builder/index.js +5 -6
  38. package/dist/builder/platform.d.ts +1 -1
  39. package/dist/cli.d.ts +1 -1
  40. package/dist/command.d.ts +1 -1
  41. package/dist/config/defineConfig.d.ts +1 -1
  42. package/dist/config/merge.d.ts +4 -4
  43. package/dist/config/normalize.d.ts +5 -6
  44. package/dist/config/normalize.js +2 -2
  45. package/dist/config/transformLegacyConfig.d.ts +1 -1
  46. package/dist/config/valid.d.ts +1 -1
  47. package/dist/constants/build.d.ts +1 -1
  48. package/dist/constants/color.d.ts +1 -1
  49. package/dist/constants/dts.d.ts +0 -1
  50. package/dist/constants/dts.js +0 -3
  51. package/dist/constants/file.d.ts +1 -1
  52. package/dist/constants/legacy-preset.d.ts +11 -11
  53. package/dist/constants/loader.d.ts +1 -1
  54. package/dist/constants/log.d.ts +1 -1
  55. package/dist/constants/preset.d.ts +5 -5
  56. package/dist/debug.d.ts +1 -1
  57. package/dist/dev.d.ts +1 -1
  58. package/dist/error.d.ts +19 -19
  59. package/dist/hooks/build.d.ts +17 -17
  60. package/dist/hooks/dev.d.ts +11 -11
  61. package/dist/hooks/index.d.ts +29 -28
  62. package/dist/hooks/misc.d.ts +12 -7
  63. package/dist/hooks/misc.js +4 -0
  64. package/dist/index.d.ts +1 -1
  65. package/dist/locale/en.d.ts +40 -40
  66. package/dist/locale/index.d.ts +79 -79
  67. package/dist/locale/zh.d.ts +40 -40
  68. package/dist/plugins.d.ts +1 -1
  69. package/dist/types/color.d.ts +1 -1
  70. package/dist/types/command.d.ts +9 -9
  71. package/dist/types/config/copy.d.ts +10 -10
  72. package/dist/types/config/dev.d.ts +4 -4
  73. package/dist/types/config/index.d.ts +106 -106
  74. package/dist/types/config/style.d.ts +37 -37
  75. package/dist/types/context.d.ts +4 -4
  76. package/dist/types/dts.d.ts +39 -38
  77. package/dist/types/esbuild.d.ts +77 -77
  78. package/dist/types/hooks.d.ts +14 -14
  79. package/dist/types/index.d.ts +7 -7
  80. package/dist/types/legacyConfig/index.d.ts +8 -8
  81. package/dist/types/legacyConfig/output.d.ts +44 -44
  82. package/dist/types/legacyConfig/source.d.ts +10 -10
  83. package/dist/types/legacyConfig/tools.d.ts +39 -39
  84. package/dist/utils/assert.d.ts +1 -1
  85. package/dist/utils/builder.d.ts +9 -9
  86. package/dist/utils/common.d.ts +1 -1
  87. package/dist/utils/dts.d.ts +4 -34
  88. package/dist/utils/dts.js +71 -93
  89. package/dist/utils/hash.d.ts +1 -1
  90. package/dist/utils/index.d.ts +1 -2
  91. package/dist/utils/index.js +0 -2
  92. package/dist/utils/input.d.ts +5 -8
  93. package/dist/utils/log.d.ts +1 -1
  94. package/dist/utils/map.d.ts +5 -5
  95. package/dist/utils/onExit.d.ts +1 -1
  96. package/dist/utils/outExtension.d.ts +6 -6
  97. package/dist/utils/print.d.ts +3 -3
  98. package/dist/utils/style.d.ts +7 -7
  99. package/lib/types.d.ts +0 -1
  100. package/package.json +18 -24
  101. package/dist/utils/tspath.d.ts +0 -15
  102. package/dist/utils/tspath.js +0 -114
@@ -1,114 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var tspath_exports = {};
30
- __export(tspath_exports, {
31
- transformDtsAlias: () => transformDtsAlias
32
- });
33
- module.exports = __toCommonJS(tspath_exports);
34
- var path = __toESM(require("path"));
35
- var import_tsconfig_paths = require("@modern-js/utils/tsconfig-paths");
36
- var import_utils = require("@modern-js/utils");
37
- var parser = __toESM(require("@babel/parser"));
38
- var import_generator = __toESM(require("@babel/generator"));
39
- var t = __toESM(require("@babel/types"));
40
- var import_traverse = __toESM(require("@babel/traverse"));
41
- var import_file = require("../constants/file");
42
- function mapPathString(nodePath, { filename, baseUrl, paths }) {
43
- if (!t.isStringLiteral(nodePath)) {
44
- return;
45
- }
46
- const sourcePath = nodePath.node.value;
47
- const currentFile = filename;
48
- const matchPath = (0, import_tsconfig_paths.createMatchPath)(baseUrl, paths, [
49
- "index"
50
- ]);
51
- const result = matchPath(sourcePath, (packageJsonPath) => {
52
- if (!import_utils.fs.existsSync(packageJsonPath)) {
53
- return void 0;
54
- }
55
- return import_utils.fs.readJSONSync(packageJsonPath);
56
- }, (filePath) => import_utils.fs.existsSync(filePath), import_file.dtsAliasExts);
57
- if (result) {
58
- const relativePath = path.relative(path.dirname(currentFile), path.dirname(result));
59
- const fileName = path.basename(result);
60
- const filePath = path.normalize(`${relativePath.length === 0 ? "." : relativePath}/${fileName}`);
61
- const replaceString = filePath.startsWith(".") ? filePath : `./${filePath}`;
62
- nodePath.replaceWith(t.stringLiteral(replaceString));
63
- }
64
- }
65
- const transformImport = (option) => (nodePath) => {
66
- mapPathString(nodePath.get("source"), option);
67
- };
68
- const transformExport = (option) => (nodePath) => {
69
- mapPathString(nodePath.get("source"), option);
70
- };
71
- const transformSingleFileAlias = ({ filename, baseUrl, paths }) => {
72
- const sourceCode = import_utils.fs.readFileSync(filename, "utf-8");
73
- const ast = parser.parse(sourceCode, {
74
- sourceType: "module",
75
- errorRecovery: true,
76
- plugins: [
77
- "typescript"
78
- ]
79
- });
80
- (0, import_traverse.default)(ast, {
81
- // d.ts file content not have callExpression which can be parsed;
82
- // CallExpression: transformCall({ filename, baseUrl, paths }) as any,
83
- ImportDeclaration: transformImport({
84
- filename,
85
- baseUrl,
86
- paths
87
- }),
88
- ExportDeclaration: transformExport({
89
- filename,
90
- baseUrl,
91
- paths
92
- })
93
- });
94
- return (0, import_generator.default)(ast).code;
95
- };
96
- const transformDtsAlias = (option) => {
97
- const { filenames = [], baseUrl, paths } = option;
98
- const transformResult = [];
99
- for (const filename of filenames) {
100
- transformResult.push({
101
- path: filename,
102
- content: transformSingleFileAlias({
103
- filename,
104
- baseUrl,
105
- paths
106
- })
107
- });
108
- }
109
- return transformResult;
110
- };
111
- // Annotate the CommonJS export names for ESM import in node:
112
- 0 && (module.exports = {
113
- transformDtsAlias
114
- });