@modern-js/module-tools 2.41.0 → 2.42.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.
- package/dist/build.d.ts +1 -1
- package/dist/builder/build.d.ts +7 -7
- package/dist/builder/build.js +3 -1
- package/dist/builder/clear.d.ts +1 -2
- package/dist/builder/clear.js +2 -8
- package/dist/builder/copy.d.ts +9 -9
- package/dist/builder/dts/index.d.ts +1 -1
- package/dist/builder/dts/rollup.d.ts +1 -13
- package/dist/builder/dts/tsc.d.ts +1 -1
- package/dist/builder/dts/tsc.js +38 -17
- package/dist/builder/esbuild/adapter.d.ts +1 -1
- package/dist/builder/esbuild/hook.d.ts +1 -1
- package/dist/builder/esbuild/index.d.ts +28 -28
- package/dist/builder/esbuild/resolve.d.ts +9 -9
- package/dist/builder/esbuild/sourcemap.d.ts +14 -14
- package/dist/builder/esbuild/transform.d.ts +4 -4
- package/dist/builder/esbuild/watch.d.ts +1 -1
- package/dist/builder/esbuild/write-file.d.ts +1 -1
- package/dist/builder/feature/asset.d.ts +5 -5
- package/dist/builder/feature/format-cjs.d.ts +3 -3
- package/dist/builder/feature/index.d.ts +1 -1
- package/dist/builder/feature/json.d.ts +3 -3
- package/dist/builder/feature/redirect.d.ts +3 -3
- package/dist/builder/feature/style/index.d.ts +3 -3
- package/dist/builder/feature/style/lessAliasPlugin.d.ts +7 -7
- package/dist/builder/feature/style/lessRender.d.ts +1 -1
- package/dist/builder/feature/style/postcssTransformer.d.ts +3 -3
- package/dist/builder/feature/style/postcssUrlPlugin.d.ts +3 -3
- package/dist/builder/feature/style/sassRender.d.ts +1 -1
- package/dist/builder/feature/style/transformStyle.d.ts +7 -7
- package/dist/builder/feature/style/utils.d.ts +3 -3
- package/dist/builder/feature/swc.d.ts +5 -5
- package/dist/builder/feature/terser.d.ts +3 -3
- package/dist/builder/index.d.ts +4 -4
- package/dist/builder/index.js +0 -1
- package/dist/builder/platform.d.ts +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/command.d.ts +1 -1
- package/dist/config/defineConfig.d.ts +1 -1
- package/dist/config/merge.d.ts +4 -4
- package/dist/config/normalize.d.ts +3 -3
- package/dist/config/transformLegacyConfig.d.ts +1 -1
- package/dist/config/valid.d.ts +1 -1
- package/dist/constants/build.d.ts +1 -1
- package/dist/constants/color.d.ts +1 -1
- package/dist/constants/dts.d.ts +0 -1
- package/dist/constants/dts.js +0 -3
- package/dist/constants/file.d.ts +1 -1
- package/dist/constants/legacy-preset.d.ts +11 -11
- package/dist/constants/loader.d.ts +1 -1
- package/dist/constants/log.d.ts +1 -1
- package/dist/constants/preset.d.ts +5 -5
- package/dist/debug.d.ts +1 -1
- package/dist/dev.d.ts +1 -1
- package/dist/error.d.ts +19 -19
- package/dist/hooks/build.d.ts +16 -16
- package/dist/hooks/dev.d.ts +11 -11
- package/dist/hooks/index.d.ts +29 -29
- package/dist/hooks/misc.d.ts +11 -11
- package/dist/index.d.ts +1 -1
- package/dist/locale/en.d.ts +40 -40
- package/dist/locale/index.d.ts +79 -79
- package/dist/locale/zh.d.ts +40 -40
- package/dist/plugins.d.ts +1 -1
- package/dist/types/color.d.ts +1 -1
- package/dist/types/command.d.ts +9 -9
- package/dist/types/config/copy.d.ts +10 -10
- package/dist/types/config/dev.d.ts +4 -4
- package/dist/types/config/index.d.ts +106 -106
- package/dist/types/config/style.d.ts +37 -37
- package/dist/types/context.d.ts +4 -4
- package/dist/types/dts.d.ts +39 -38
- package/dist/types/esbuild.d.ts +77 -77
- package/dist/types/hooks.d.ts +14 -14
- package/dist/types/index.d.ts +7 -7
- package/dist/types/legacyConfig/index.d.ts +8 -8
- package/dist/types/legacyConfig/output.d.ts +44 -44
- package/dist/types/legacyConfig/source.d.ts +10 -10
- package/dist/types/legacyConfig/tools.d.ts +39 -39
- package/dist/utils/assert.d.ts +1 -1
- package/dist/utils/builder.d.ts +9 -9
- package/dist/utils/common.d.ts +1 -1
- package/dist/utils/dts.d.ts +4 -34
- package/dist/utils/dts.js +71 -93
- package/dist/utils/hash.d.ts +1 -1
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.js +0 -2
- package/dist/utils/input.d.ts +5 -8
- package/dist/utils/log.d.ts +1 -1
- package/dist/utils/map.d.ts +5 -5
- package/dist/utils/onExit.d.ts +1 -1
- package/dist/utils/outExtension.d.ts +6 -6
- package/dist/utils/print.d.ts +3 -3
- package/dist/utils/style.d.ts +7 -7
- package/package.json +14 -20
- package/dist/utils/tspath.d.ts +0 -15
- package/dist/utils/tspath.js +0 -114
package/dist/utils/dts.js
CHANGED
|
@@ -28,69 +28,25 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var dts_exports = {};
|
|
30
30
|
__export(dts_exports, {
|
|
31
|
-
addBannerAndFooter: () => addBannerAndFooter,
|
|
32
|
-
generateDtsInfo: () => generateDtsInfo,
|
|
33
31
|
getProjectTsconfig: () => getProjectTsconfig,
|
|
34
32
|
getTscBinPath: () => getTscBinPath,
|
|
35
33
|
printOrThrowDtsErrors: () => printOrThrowDtsErrors,
|
|
36
|
-
|
|
37
|
-
tsTargetAtOrAboveES2022: () => tsTargetAtOrAboveES2022
|
|
38
|
-
writeDtsFiles: () => writeDtsFiles
|
|
34
|
+
processDtsFilesAfterTsc: () => processDtsFilesAfterTsc,
|
|
35
|
+
tsTargetAtOrAboveES2022: () => tsTargetAtOrAboveES2022
|
|
39
36
|
});
|
|
40
37
|
module.exports = __toCommonJS(dts_exports);
|
|
41
38
|
var import_path = require("path");
|
|
42
39
|
var import_utils = require("@modern-js/utils");
|
|
43
40
|
var import_magic_string = __toESM(require("magic-string"));
|
|
41
|
+
var import_tsconfig_paths = require("@modern-js/utils/tsconfig-paths");
|
|
42
|
+
var import_napi = require("@ast-grep/napi");
|
|
43
|
+
var import_builder = require("./builder");
|
|
44
44
|
const getProjectTsconfig = async (tsconfigPath) => {
|
|
45
45
|
if (!import_utils.fs.existsSync(tsconfigPath)) {
|
|
46
46
|
return {};
|
|
47
47
|
}
|
|
48
48
|
return import_utils.json5.parse(import_utils.fs.readFileSync(tsconfigPath, "utf-8"));
|
|
49
49
|
};
|
|
50
|
-
const generateDtsInfo = async (config) => {
|
|
51
|
-
var _userTsconfig_references;
|
|
52
|
-
const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;
|
|
53
|
-
const userTsconfig = await getProjectTsconfig(tsconfigPath);
|
|
54
|
-
const { dtsTempDirectory } = await Promise.resolve().then(() => __toESM(require("../constants/dts")));
|
|
55
|
-
const tempDistAbsRootPath = (0, import_path.join)(appDirectory, `${dtsTempDirectory}/${(0, import_utils.nanoid)()}`);
|
|
56
|
-
const tempDistAbsOurDir = (0, import_path.join)(tempDistAbsRootPath, (0, import_path.relative)(appDirectory, absSourceDir));
|
|
57
|
-
const tempTsconfigPath = (0, import_path.join)(tempDistAbsRootPath, (0, import_path.basename)(tsconfigPath));
|
|
58
|
-
import_utils.fs.ensureFileSync(tempTsconfigPath);
|
|
59
|
-
const extendsPath = (0, import_path.join)((0, import_path.relative)((0, import_path.dirname)(tempTsconfigPath), (0, import_path.dirname)(tsconfigPath)), (0, import_path.basename)(tempTsconfigPath));
|
|
60
|
-
const references = userTsconfig === null || userTsconfig === void 0 ? void 0 : (_userTsconfig_references = userTsconfig.references) === null || _userTsconfig_references === void 0 ? void 0 : _userTsconfig_references.map((reference) => {
|
|
61
|
-
const { path } = reference;
|
|
62
|
-
if (path) {
|
|
63
|
-
const userTsconfigDir = (0, import_path.dirname)(tsconfigPath);
|
|
64
|
-
const generatedTsconfigDir = (0, import_path.dirname)(tempTsconfigPath);
|
|
65
|
-
return {
|
|
66
|
-
path: (0, import_path.isAbsolute)(path) ? path : (0, import_path.relative)(generatedTsconfigDir, (0, import_path.resolve)(userTsconfigDir, path))
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
return reference;
|
|
70
|
-
});
|
|
71
|
-
const resetConfig = {
|
|
72
|
-
extends: extendsPath,
|
|
73
|
-
compilerOptions: {
|
|
74
|
-
// Ensure that .d.ts files are created by tsc, but not .js files
|
|
75
|
-
declaration: true,
|
|
76
|
-
emitDeclarationOnly: true,
|
|
77
|
-
// when `outDir` is './dist', `declarationDir` is `./types`
|
|
78
|
-
// tsc will emit:
|
|
79
|
-
// - ./dist/index.js
|
|
80
|
-
// - ./types/index.d.ts
|
|
81
|
-
// we only want to emit declarations
|
|
82
|
-
declarationDir: tempDistAbsOurDir
|
|
83
|
-
},
|
|
84
|
-
references
|
|
85
|
-
};
|
|
86
|
-
import_utils.fs.writeJSONSync(tempTsconfigPath, resetConfig);
|
|
87
|
-
return {
|
|
88
|
-
userTsconfig,
|
|
89
|
-
tempTsconfigPath,
|
|
90
|
-
tempDistAbsRootPath,
|
|
91
|
-
tempDistAbsSrcPath: tempDistAbsOurDir
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
50
|
const getTscBinPath = async (appDirectory) => {
|
|
95
51
|
const { default: findUp, exists: pathExists } = await Promise.resolve().then(() => __toESM(require("../../compiled/find-up")));
|
|
96
52
|
const tscBinFile = await findUp(async (directory) => {
|
|
@@ -108,58 +64,83 @@ const getTscBinPath = async (appDirectory) => {
|
|
|
108
64
|
}
|
|
109
65
|
return tscBinFile;
|
|
110
66
|
};
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const dtsFilenames = watchFilenames.length > 0 ? watchFilenames : import_utils.globby.sync(dtsDistPath, {
|
|
117
|
-
absolute: true
|
|
118
|
-
});
|
|
119
|
-
var _userTsconfig_compilerOptions_paths;
|
|
120
|
-
const result = transformDtsAlias({
|
|
121
|
-
filenames: dtsFilenames,
|
|
122
|
-
baseUrl: tempDistAbsRootPath,
|
|
123
|
-
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 : {}
|
|
67
|
+
const processDtsFilesAfterTsc = async (config) => {
|
|
68
|
+
const { distPath, tsconfigPath, userTsconfig, dtsExtension, banner, footer } = config;
|
|
69
|
+
const dtsFilesPath = await (0, import_utils.globby)("**/*.d.ts", {
|
|
70
|
+
absolute: true,
|
|
71
|
+
cwd: distPath
|
|
124
72
|
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
73
|
+
const result = (0, import_tsconfig_paths.loadConfig)(tsconfigPath);
|
|
74
|
+
if (result.resultType === "failed") {
|
|
75
|
+
import_utils.logger.error(result.message);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const { absoluteBaseUrl, paths, mainFields, addMatchAll } = result;
|
|
79
|
+
const matchPath = (0, import_tsconfig_paths.createMatchPath)(absoluteBaseUrl, paths, mainFields, addMatchAll);
|
|
80
|
+
const Pattern = [
|
|
81
|
+
`import $VAR from '$MATCH'`,
|
|
82
|
+
`import $VAR from "$MATCH"`,
|
|
83
|
+
`export {$$$VAR} from '$MATCH'`,
|
|
84
|
+
`export {$$$VAR} from "$MATCH"`,
|
|
85
|
+
`export * from '$MATCH'`,
|
|
86
|
+
`export * from "$MATCH"`,
|
|
87
|
+
`export * as $VAR from '$MATCH'`,
|
|
88
|
+
`export * as $VAR from "$MATCH"`,
|
|
89
|
+
`import('$MATCH')`,
|
|
90
|
+
`import("$MATCH")`
|
|
91
|
+
];
|
|
92
|
+
await Promise.all(dtsFilesPath.map((filePath) => {
|
|
93
|
+
var _userTsconfig_compilerOptions;
|
|
94
|
+
const code = import_utils.fs.readFileSync(filePath, "utf8");
|
|
95
|
+
let matchModule = [];
|
|
96
|
+
try {
|
|
97
|
+
const sgNode = import_napi.ts.parse(code).root();
|
|
98
|
+
matchModule = Pattern.map((p) => sgNode.findAll(p)).flat().map((node) => {
|
|
99
|
+
const matchNode = node.getMatch("MATCH");
|
|
100
|
+
return {
|
|
101
|
+
name: matchNode.text(),
|
|
102
|
+
start: matchNode.range().start.index,
|
|
103
|
+
end: matchNode.range().end.index
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
} catch (e) {
|
|
107
|
+
import_utils.logger.error("[parse error]", e);
|
|
108
|
+
}
|
|
109
|
+
const str = new import_magic_string.default(code);
|
|
110
|
+
const originalFilePath = (0, import_path.resolve)(absoluteBaseUrl, (userTsconfig === null || userTsconfig === void 0 ? void 0 : (_userTsconfig_compilerOptions = userTsconfig.compilerOptions) === null || _userTsconfig_compilerOptions === void 0 ? void 0 : _userTsconfig_compilerOptions.rootDir) || "src", (0, import_path.relative)(distPath, filePath));
|
|
111
|
+
matchModule.forEach((module2) => {
|
|
112
|
+
if (!module2.name) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const { start, end, name } = module2;
|
|
116
|
+
const absoluteImportPath = matchPath(name);
|
|
117
|
+
if (absoluteImportPath) {
|
|
118
|
+
const relativePath = (0, import_path.relative)((0, import_path.dirname)(originalFilePath), absoluteImportPath);
|
|
119
|
+
const relativeImportPath = (0, import_builder.normalizeSlashes)(relativePath.startsWith("..") ? relativePath : `./${relativePath}`);
|
|
120
|
+
str.overwrite(start, end, relativeImportPath);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
banner && str.prepend(`${banner}
|
|
124
|
+
`);
|
|
125
|
+
footer && str.append(`
|
|
126
|
+
${footer}
|
|
127
|
+
`);
|
|
128
|
+
const content = str.toString();
|
|
129
|
+
const finalPath = (
|
|
134
130
|
// We confirm that users will not mix ts and c(m)ts files in their projects.
|
|
135
131
|
// If a mix is required, please configure separate buildConfig to handle different inputs.
|
|
136
132
|
// So we don't replace .d.(c|m)ts that generated by tsc directly, this can confirm that
|
|
137
133
|
// users can use c(m)ts directly rather than enable autoExtension, in this condition,
|
|
138
134
|
// users need to set esbuild out-extensions like { '.js': '.mjs' }
|
|
139
|
-
|
|
135
|
+
filePath.replace(/\.d\.ts/, dtsExtension)
|
|
140
136
|
);
|
|
141
|
-
import_utils.fs.ensureFileSync(filepath);
|
|
142
137
|
return import_utils.fs.writeFile(
|
|
143
138
|
// only replace .d.ts, if tsc generate .d.m(c)ts, keep.
|
|
144
|
-
|
|
139
|
+
finalPath,
|
|
145
140
|
content
|
|
146
141
|
);
|
|
147
142
|
}));
|
|
148
143
|
};
|
|
149
|
-
const addBannerAndFooter = (result, banner, footer) => {
|
|
150
|
-
return result.map(({ path, content }) => {
|
|
151
|
-
const ms = new import_magic_string.default(content);
|
|
152
|
-
banner && ms.prepend(`${banner}
|
|
153
|
-
`);
|
|
154
|
-
footer && ms.append(`
|
|
155
|
-
${footer}
|
|
156
|
-
`);
|
|
157
|
-
return {
|
|
158
|
-
path,
|
|
159
|
-
content: ms.toString()
|
|
160
|
-
};
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
144
|
const printOrThrowDtsErrors = async (error, options) => {
|
|
164
145
|
const { InternalDTSError } = await Promise.resolve().then(() => __toESM(require("../error")));
|
|
165
146
|
const local = await Promise.resolve().then(() => __toESM(require("../locale")));
|
|
@@ -180,12 +161,9 @@ const printOrThrowDtsErrors = async (error, options) => {
|
|
|
180
161
|
const tsTargetAtOrAboveES2022 = (target) => target === "es2022" || target === "esnext";
|
|
181
162
|
// Annotate the CommonJS export names for ESM import in node:
|
|
182
163
|
0 && (module.exports = {
|
|
183
|
-
addBannerAndFooter,
|
|
184
|
-
generateDtsInfo,
|
|
185
164
|
getProjectTsconfig,
|
|
186
165
|
getTscBinPath,
|
|
187
166
|
printOrThrowDtsErrors,
|
|
188
|
-
|
|
189
|
-
tsTargetAtOrAboveES2022
|
|
190
|
-
writeDtsFiles
|
|
167
|
+
processDtsFilesAfterTsc,
|
|
168
|
+
tsTargetAtOrAboveES2022
|
|
191
169
|
});
|
package/dist/utils/hash.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
export declare function getHash(content: Buffer | string, encoding: any, type?: string): string;
|
|
2
|
+
export declare function getHash(content: Buffer | string, encoding: any, type?: string): string;
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -25,7 +25,6 @@ __reExport(utils_exports, require("./log"), module.exports);
|
|
|
25
25
|
__reExport(utils_exports, require("./map"), module.exports);
|
|
26
26
|
__reExport(utils_exports, require("./print"), module.exports);
|
|
27
27
|
__reExport(utils_exports, require("./style"), module.exports);
|
|
28
|
-
__reExport(utils_exports, require("./tspath"), module.exports);
|
|
29
28
|
__reExport(utils_exports, require("./outExtension"), module.exports);
|
|
30
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
31
30
|
0 && (module.exports = {
|
|
@@ -39,6 +38,5 @@ __reExport(utils_exports, require("./outExtension"), module.exports);
|
|
|
39
38
|
...require("./map"),
|
|
40
39
|
...require("./print"),
|
|
41
40
|
...require("./style"),
|
|
42
|
-
...require("./tspath"),
|
|
43
41
|
...require("./outExtension")
|
|
44
42
|
});
|
package/dist/utils/input.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Input } from '../types';
|
|
2
|
-
export declare const getDefaultIndexEntry: ({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}: {
|
|
6
|
-
isTsProject: boolean;
|
|
7
|
-
appDirectory: string;
|
|
2
|
+
export declare const getDefaultIndexEntry: ({ isTsProject, appDirectory, }: {
|
|
3
|
+
isTsProject: boolean;
|
|
4
|
+
appDirectory: string;
|
|
8
5
|
}) => Promise<string[]>;
|
|
9
6
|
export declare const normalizeInput: (input: Input, appDirectory: string, enableSvgr: boolean) => Promise<string[] | {
|
|
10
|
-
|
|
11
|
-
}>;
|
|
7
|
+
[name: string]: string;
|
|
8
|
+
}>;
|
package/dist/utils/log.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const withLogTitle: (titleText: string, message: string) => string;
|
|
1
|
+
export declare const withLogTitle: (titleText: string, message: string) => string;
|
package/dist/utils/map.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { RawSourceMap } from '@ampproject/remapping/dist/types/types';
|
|
2
2
|
import type { SourceMap } from '../types';
|
|
3
3
|
interface Options {
|
|
4
|
-
|
|
4
|
+
needSourceMap: boolean;
|
|
5
5
|
}
|
|
6
6
|
export declare function normalizeSourceMap(map: string | RawSourceMap | undefined, opts?: Options): SourceMap | undefined;
|
|
7
7
|
export type MergeMapResult = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
toString: () => string;
|
|
9
|
+
toMap: () => SourceMap;
|
|
10
|
+
toComment: () => string;
|
|
11
11
|
};
|
|
12
12
|
export declare function mergeMaps(mapList: SourceMap[]): MergeMapResult;
|
|
13
|
-
export {};
|
|
13
|
+
export {};
|
package/dist/utils/onExit.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const addExitListener: (fn: () => Promise<void>) => Promise<void>;
|
|
1
|
+
export declare const addExitListener: (fn: () => Promise<void>) => Promise<void>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Format } from '../types';
|
|
2
2
|
export declare const getDefaultOutExtension: (options: {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
format: Format;
|
|
4
|
+
root: string;
|
|
5
|
+
autoExtension: boolean;
|
|
6
6
|
}) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
7
|
+
jsExtension: string;
|
|
8
|
+
dtsExtension: string;
|
|
9
|
+
};
|
package/dist/utils/print.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { RollupOutput } from '../../compiled/rollup/types/rollup';
|
|
2
2
|
import { Chunk } from '../types';
|
|
3
3
|
type Files = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
name: string;
|
|
5
|
+
size: number;
|
|
6
6
|
};
|
|
7
7
|
export declare const bundleFiles: Files[];
|
|
8
8
|
export declare const bundlelessFiles: Files[];
|
|
@@ -11,4 +11,4 @@ export declare const addRollupChunk: (rollupOutput: RollupOutput, appDirectory:
|
|
|
11
11
|
export declare const addDtsFiles: (distDir: string, appDirectory: string) => Promise<void>;
|
|
12
12
|
export declare const printFileSize: () => void;
|
|
13
13
|
export declare const printSucceed: (totalDuration: number) => void;
|
|
14
|
-
export {};
|
|
14
|
+
export {};
|
package/dist/utils/style.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ import type { PartialBaseBuildConfig, PostcssOptions, LessOptions, SassOptions }
|
|
|
2
2
|
export declare const getLessConfig: (config: PartialBaseBuildConfig) => Promise<LessOptions>;
|
|
3
3
|
export declare const getSassConfig: (config: PartialBaseBuildConfig) => Promise<SassOptions>;
|
|
4
4
|
export declare const getPostcssConfig: (config: PartialBaseBuildConfig) => Promise<PostcssOptions & {
|
|
5
|
-
|
|
5
|
+
$$tools?: string | undefined;
|
|
6
6
|
}>;
|
|
7
7
|
export declare const getStyleConfig: (config: PartialBaseBuildConfig) => Promise<{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}>;
|
|
8
|
+
less: LessOptions;
|
|
9
|
+
sass: SassOptions;
|
|
10
|
+
postcss: PostcssOptions & {
|
|
11
|
+
$$tools?: string | undefined;
|
|
12
|
+
};
|
|
13
|
+
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/module-tools",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.42.1",
|
|
4
4
|
"description": "Simple, powerful, high-performance modern npm package development solution.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"modern",
|
|
@@ -48,10 +48,6 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@ampproject/remapping": "1.0.2",
|
|
50
50
|
"@ast-grep/napi": "0.12.0",
|
|
51
|
-
"@babel/generator": "^7.22.15",
|
|
52
|
-
"@babel/parser": "^7.22.15",
|
|
53
|
-
"@babel/traverse": "^7.23.2",
|
|
54
|
-
"@babel/types": "^7.22.15",
|
|
55
51
|
"@modern-js/swc-plugins": "0.6.5",
|
|
56
52
|
"@rollup/pluginutils": "4.1.1",
|
|
57
53
|
"@svgr/core": "8.0.0",
|
|
@@ -71,26 +67,24 @@
|
|
|
71
67
|
"tapable": "2.2.1",
|
|
72
68
|
"terser": "5.19.2",
|
|
73
69
|
"tsconfig-paths-webpack-plugin": "4.1.0",
|
|
74
|
-
"@modern-js/
|
|
75
|
-
"@modern-js/
|
|
76
|
-
"@modern-js/plugin
|
|
77
|
-
"@modern-js/plugin": "2.
|
|
78
|
-
"@modern-js/plugin-
|
|
79
|
-
"@modern-js/
|
|
80
|
-
"@modern-js/
|
|
81
|
-
"@modern-js/utils": "2.
|
|
82
|
-
"@modern-js/
|
|
70
|
+
"@modern-js/core": "2.42.1",
|
|
71
|
+
"@modern-js/new-action": "2.42.1",
|
|
72
|
+
"@modern-js/plugin": "2.42.1",
|
|
73
|
+
"@modern-js/plugin-i18n": "2.42.1",
|
|
74
|
+
"@modern-js/plugin-changeset": "2.42.1",
|
|
75
|
+
"@modern-js/types": "2.42.1",
|
|
76
|
+
"@modern-js/upgrade": "2.42.1",
|
|
77
|
+
"@modern-js/utils": "2.42.1",
|
|
78
|
+
"@modern-js/plugin-lint": "2.42.1"
|
|
83
79
|
},
|
|
84
80
|
"devDependencies": {
|
|
85
|
-
"@types/babel__generator": "7.6.4",
|
|
86
|
-
"@types/babel__traverse": "7.18.5",
|
|
87
81
|
"@types/convert-source-map": "1.5.2",
|
|
88
82
|
"@types/node": "^14",
|
|
89
83
|
"typescript": "^5",
|
|
90
|
-
"@modern-js/
|
|
91
|
-
"@modern-js/
|
|
92
|
-
"@scripts/
|
|
93
|
-
"@scripts/
|
|
84
|
+
"@modern-js/self": "npm:@modern-js/module-tools@2.42.1",
|
|
85
|
+
"@modern-js/builder-webpack-provider": "2.42.1",
|
|
86
|
+
"@scripts/build": "2.42.1",
|
|
87
|
+
"@scripts/vitest-config": "2.42.1"
|
|
94
88
|
},
|
|
95
89
|
"peerDependencies": {
|
|
96
90
|
"typescript": "^4 || ^5"
|
package/dist/utils/tspath.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface TransformOption {
|
|
2
|
-
filename: string;
|
|
3
|
-
baseUrl: string;
|
|
4
|
-
paths: Record<string, string[] | string>;
|
|
5
|
-
}
|
|
6
|
-
interface TransformDtsAliasOption {
|
|
7
|
-
filenames?: string[];
|
|
8
|
-
baseUrl: string;
|
|
9
|
-
paths: Record<string, string[] | string>;
|
|
10
|
-
}
|
|
11
|
-
export declare const transformDtsAlias: (option: TransformDtsAliasOption) => {
|
|
12
|
-
path: string;
|
|
13
|
-
content: string;
|
|
14
|
-
}[];
|
|
15
|
-
export {};
|
package/dist/utils/tspath.js
DELETED
|
@@ -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
|
-
});
|