@modern-js/module-tools 2.42.2 → 2.44.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.
- package/dist/builder/build.js +3 -2
- package/dist/builder/clear.js +23 -14
- package/dist/builder/dts/tsc.js +8 -7
- package/dist/builder/esbuild/adapter.js +1 -1
- package/dist/builder/feature/asset.d.ts +2 -3
- package/dist/builder/feature/asset.js +22 -37
- package/dist/builder/feature/redirect.js +6 -7
- package/dist/builder/feature/style/lessAliasPlugin.js +2 -3
- package/dist/builder/feature/style/postcssUrlPlugin.js +4 -1
- package/dist/builder/feature/style/utils.js +8 -15
- package/dist/constants/build.js +2 -1
- package/dist/types/config/index.d.ts +6 -0
- package/dist/types/dts.d.ts +4 -0
- package/dist/utils/dts.js +23 -7
- package/package.json +18 -18
package/dist/builder/build.js
CHANGED
|
@@ -76,7 +76,7 @@ const generatorDts = async (config, api, options) => {
|
|
|
76
76
|
const { watch, dts } = options;
|
|
77
77
|
const { buildType, input, sourceDir, alias, externals, tsconfig, footer: { dts: footer }, banner: { dts: banner }, format, autoExtension } = config;
|
|
78
78
|
const { appDirectory } = api.useAppContext();
|
|
79
|
-
const { distPath, abortOnError, respectExternal } = dts;
|
|
79
|
+
const { distPath, abortOnError, respectExternal, enableTscBuild } = dts;
|
|
80
80
|
var _dts_tsconfigPath;
|
|
81
81
|
const tsconfigPath = (_dts_tsconfigPath = dts.tsconfigPath) !== null && _dts_tsconfigPath !== void 0 ? _dts_tsconfigPath : tsconfig;
|
|
82
82
|
const { dtsExtension } = (0, import_utils2.getDefaultOutExtension)({
|
|
@@ -99,7 +99,8 @@ const generatorDts = async (config, api, options) => {
|
|
|
99
99
|
alias,
|
|
100
100
|
sourceDir,
|
|
101
101
|
dtsExtension,
|
|
102
|
-
userTsconfig
|
|
102
|
+
userTsconfig,
|
|
103
|
+
enableTscBuild
|
|
103
104
|
};
|
|
104
105
|
const prevTime = Date.now();
|
|
105
106
|
(0, import_debug.debug)(`${(0, import_debug.label)("dts")} Build Start`);
|
package/dist/builder/clear.js
CHANGED
|
@@ -21,9 +21,11 @@ __export(clear_exports, {
|
|
|
21
21
|
clearBuildConfigPaths: () => clearBuildConfigPaths
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(clear_exports);
|
|
24
|
+
var import_path = require("path");
|
|
24
25
|
var import_utils = require("@modern-js/utils");
|
|
25
26
|
var import_locale = require("../locale");
|
|
26
27
|
var import_utils2 = require("../utils");
|
|
28
|
+
var import_debug = require("../debug");
|
|
27
29
|
const clearBuildConfigPaths = async (configs, projectAbsRootPath) => {
|
|
28
30
|
for (const config of configs) {
|
|
29
31
|
if (projectAbsRootPath === config.outDir) {
|
|
@@ -31,20 +33,27 @@ const clearBuildConfigPaths = async (configs, projectAbsRootPath) => {
|
|
|
31
33
|
} else {
|
|
32
34
|
await import_utils.fs.remove(config.outDir);
|
|
33
35
|
}
|
|
34
|
-
if (config.buildType === "bundleless" && config.dts
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
if (config.buildType === "bundleless" && config.dts) {
|
|
37
|
+
const { compilerOptions } = await (0, import_utils2.getProjectTsconfig)(config.tsconfig);
|
|
38
|
+
const { composite, incremental, rootDir, outDir, tsBuildInfoFile = ".tsbuildinfo" } = compilerOptions || {};
|
|
39
|
+
if (!composite && !incremental) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const tsconfigDir = (0, import_path.dirname)(config.tsconfig);
|
|
43
|
+
let tsbuildInfoFilePath = `${(0, import_path.basename)(config.tsconfig, ".json")}${tsBuildInfoFile}`;
|
|
44
|
+
if (outDir) {
|
|
45
|
+
if (rootDir) {
|
|
46
|
+
tsbuildInfoFilePath = (0, import_path.join)(outDir, (0, import_path.relative)((0, import_path.resolve)(tsconfigDir, rootDir), tsconfigDir), tsbuildInfoFilePath);
|
|
47
|
+
} else {
|
|
48
|
+
tsbuildInfoFilePath = (0, import_path.join)(outDir, tsbuildInfoFilePath);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const tsbuildInfoFileAbsPath = (0, import_path.resolve)(tsconfigDir, tsbuildInfoFilePath);
|
|
52
|
+
(0, import_debug.debug)("clear tsbuildinfo");
|
|
53
|
+
if (await import_utils.fs.pathExists(tsbuildInfoFileAbsPath)) {
|
|
54
|
+
await import_utils.fs.remove(tsbuildInfoFileAbsPath);
|
|
55
|
+
} else {
|
|
56
|
+
(0, import_debug.debug)(`${tsbuildInfoFileAbsPath} doesn't exist`);
|
|
48
57
|
}
|
|
49
58
|
}
|
|
50
59
|
}
|
package/dist/builder/dts/tsc.js
CHANGED
|
@@ -57,22 +57,23 @@ const resolveLog = async (childProgress, options) => {
|
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
59
|
const runTscBin = async (api, config) => {
|
|
60
|
-
const { appDirectory, watch = false, abortOnError = true, tsconfigPath, userTsconfig, distPath } = config;
|
|
60
|
+
const { appDirectory, watch = false, abortOnError = true, tsconfigPath, userTsconfig, distPath, enableTscBuild } = config;
|
|
61
61
|
const tscBinFile = await (0, import_utils2.getTscBinPath)(appDirectory);
|
|
62
62
|
const params = [];
|
|
63
|
-
if (
|
|
63
|
+
if (enableTscBuild) {
|
|
64
64
|
params.push("-b", tsconfigPath);
|
|
65
65
|
var _userTsconfig_compilerOptions;
|
|
66
|
-
const { baseUrl = ".", outDir, emitDeclarationOnly, declaration } = (_userTsconfig_compilerOptions = userTsconfig.compilerOptions) !== null && _userTsconfig_compilerOptions !== void 0 ? _userTsconfig_compilerOptions : {};
|
|
66
|
+
const { baseUrl = ".", outDir, emitDeclarationOnly, declaration, declarationDir } = (_userTsconfig_compilerOptions = userTsconfig.compilerOptions) !== null && _userTsconfig_compilerOptions !== void 0 ? _userTsconfig_compilerOptions : {};
|
|
67
67
|
const abosultBaseUrl = import_path.default.isAbsolute(baseUrl) ? baseUrl : import_path.default.join(import_path.default.dirname(tsconfigPath), baseUrl);
|
|
68
|
-
if (!outDir || import_path.default.resolve(abosultBaseUrl, outDir) !== distPath) {
|
|
68
|
+
if ((!outDir || import_path.default.resolve(abosultBaseUrl, outDir) !== distPath) && (!declarationDir || import_path.default.resolve(abosultBaseUrl, declarationDir) !== distPath)) {
|
|
69
69
|
const correctOutDir = import_path.default.relative(abosultBaseUrl, distPath);
|
|
70
|
-
|
|
70
|
+
const info = outDir && !declarationDir ? "outDir" : "declarationDir";
|
|
71
|
+
import_utils.logger.error(`Please set ${info}: "${correctOutDir}" in ${import_utils.chalk.underline(tsconfigPath)} to keep it same as buildConfig.`);
|
|
71
72
|
}
|
|
72
73
|
const tsVersion = await (0, import_utils2.detectTSVersion)(appDirectory);
|
|
73
74
|
if (tsVersion !== 5) {
|
|
74
75
|
if (!declaration || !emitDeclarationOnly) {
|
|
75
|
-
|
|
76
|
+
import_utils.logger.error(`Please set declaration: true and emitDeclarationOnly: true in ${import_utils.chalk.underline(tsconfigPath)}`);
|
|
76
77
|
}
|
|
77
78
|
} else {
|
|
78
79
|
params.push("--declaration", "--emitDeclarationOnly");
|
|
@@ -82,7 +83,7 @@ const runTscBin = async (api, config) => {
|
|
|
82
83
|
"-p",
|
|
83
84
|
tsconfigPath,
|
|
84
85
|
// Same as dts.distPath
|
|
85
|
-
"--
|
|
86
|
+
"--declarationDir",
|
|
86
87
|
distPath,
|
|
87
88
|
// Only emit d.ts files
|
|
88
89
|
"--declaration",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { ICompiler
|
|
2
|
+
import { ICompiler } from '../../types';
|
|
3
3
|
export declare const asset: {
|
|
4
4
|
name: string;
|
|
5
5
|
apply(compiler: ICompiler): void;
|
|
@@ -14,6 +14,5 @@ export declare const asset: {
|
|
|
14
14
|
*/
|
|
15
15
|
export declare function getAssetContents(this: ICompiler, assetPath: string, rebaseFrom: string, calledOnLoad?: boolean): Promise<{
|
|
16
16
|
contents: string | Buffer;
|
|
17
|
-
loader: "copy" | "text";
|
|
17
|
+
loader: "copy" | "jsx" | "text";
|
|
18
18
|
}>;
|
|
19
|
-
export declare function loadSvgr(path: string, options: boolean | SvgrOptions): Promise<LoadResult | undefined>;
|
|
@@ -29,8 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var asset_exports = {};
|
|
30
30
|
__export(asset_exports, {
|
|
31
31
|
asset: () => asset,
|
|
32
|
-
getAssetContents: () => getAssetContents
|
|
33
|
-
loadSvgr: () => loadSvgr
|
|
32
|
+
getAssetContents: () => getAssetContents
|
|
34
33
|
});
|
|
35
34
|
module.exports = __toCommonJS(asset_exports);
|
|
36
35
|
var import_path = require("path");
|
|
@@ -50,11 +49,7 @@ const asset = {
|
|
|
50
49
|
name
|
|
51
50
|
}, async (args) => {
|
|
52
51
|
if (import_file.assetExt.find((ext) => ext === (0, import_path.extname)(args.path))) {
|
|
53
|
-
const { buildType, outDir, sourceDir
|
|
54
|
-
const svgrResult = await loadSvgr(args.path, asset2.svgr);
|
|
55
|
-
if (svgrResult) {
|
|
56
|
-
return svgrResult;
|
|
57
|
-
}
|
|
52
|
+
const { buildType, outDir, sourceDir } = compiler.config;
|
|
58
53
|
const rebaseFrom = buildType === "bundle" ? outDir : (0, import_path.join)(outDir, (0, import_path.relative)(sourceDir, (0, import_path.dirname)(args.path)));
|
|
59
54
|
const { contents, loader } = await getAssetContents.apply(compiler, [
|
|
60
55
|
args.path,
|
|
@@ -75,7 +70,7 @@ function encodeSVG(buffer) {
|
|
|
75
70
|
async function getAssetContents(assetPath, rebaseFrom, calledOnLoad) {
|
|
76
71
|
const fileContent = await import_fs.default.promises.readFile(assetPath);
|
|
77
72
|
const { buildType, format, outDir } = this.config;
|
|
78
|
-
const { limit, path, publicPath } = this.config.asset;
|
|
73
|
+
const { limit, path, publicPath, svgr } = this.config.asset;
|
|
79
74
|
const hash = (0, import_utils.getHash)(fileContent, null).slice(0, 8);
|
|
80
75
|
const outputFileName = (0, import_path.basename)(assetPath).split(".").join(`.${hash}.`);
|
|
81
76
|
const outputFilePath = (0, import_path.resolve)(outDir, path, outputFileName);
|
|
@@ -85,7 +80,24 @@ async function getAssetContents(assetPath, rebaseFrom, calledOnLoad) {
|
|
|
85
80
|
let emitAsset = true;
|
|
86
81
|
let contents = normalizedPublicPath;
|
|
87
82
|
let loader = "text";
|
|
88
|
-
|
|
83
|
+
const config = typeof svgr === "boolean" ? {} : svgr;
|
|
84
|
+
const filter = (0, import_pluginutils.createFilter)(config.include || SVG_REGEXP, config.exclude);
|
|
85
|
+
if (svgr && filter(assetPath)) {
|
|
86
|
+
const previousExport = config.exportType === "named" ? `export default "${normalizedPublicPath}"` : null;
|
|
87
|
+
contents = await (0, import_core.transform)(fileContent.toString(), config, {
|
|
88
|
+
filePath: assetPath,
|
|
89
|
+
caller: {
|
|
90
|
+
name: "svgr",
|
|
91
|
+
defaultPlugins: [
|
|
92
|
+
import_plugin_svgo.default,
|
|
93
|
+
import_plugin_jsx.default
|
|
94
|
+
],
|
|
95
|
+
previousExport
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
loader = "jsx";
|
|
99
|
+
emitAsset = false;
|
|
100
|
+
} else if (buildType === "bundle") {
|
|
89
101
|
if (fileContent.length <= limit) {
|
|
90
102
|
const mimetype = (await Promise.resolve().then(() => __toESM(require("@modern-js/utils/mime-types")))).default.lookup(assetPath);
|
|
91
103
|
const isSVG = mimetype === "image/svg+xml";
|
|
@@ -115,35 +127,8 @@ async function getAssetContents(assetPath, rebaseFrom, calledOnLoad) {
|
|
|
115
127
|
loader
|
|
116
128
|
};
|
|
117
129
|
}
|
|
118
|
-
async function loadSvgr(path, options) {
|
|
119
|
-
if (!options) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const config = typeof options === "boolean" ? {} : options;
|
|
123
|
-
const filter = (0, import_pluginutils.createFilter)(config.include || SVG_REGEXP, config.exclude);
|
|
124
|
-
if (!filter(path)) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const loader = "jsx";
|
|
128
|
-
const text = import_fs.default.readFileSync(path, "utf8");
|
|
129
|
-
const jsCode = await (0, import_core.transform)(text, config, {
|
|
130
|
-
filePath: path,
|
|
131
|
-
caller: {
|
|
132
|
-
name: "svgr",
|
|
133
|
-
defaultPlugins: [
|
|
134
|
-
import_plugin_svgo.default,
|
|
135
|
-
import_plugin_jsx.default
|
|
136
|
-
]
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
return {
|
|
140
|
-
contents: jsCode,
|
|
141
|
-
loader
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
130
|
// Annotate the CommonJS export names for ESM import in node:
|
|
145
131
|
0 && (module.exports = {
|
|
146
132
|
asset,
|
|
147
|
-
getAssetContents
|
|
148
|
-
loadSvgr
|
|
133
|
+
getAssetContents
|
|
149
134
|
});
|
|
@@ -55,7 +55,7 @@ async function redirectImport(compiler, code, modules, aliasRecord, filePath, ou
|
|
|
55
55
|
const { start, end } = module2;
|
|
56
56
|
let { name: name2 } = module2;
|
|
57
57
|
const ext = (0, import_path.extname)(name2);
|
|
58
|
-
const { redirect: redirect2
|
|
58
|
+
const { redirect: redirect2 } = compiler.config;
|
|
59
59
|
const { alias, style } = redirect2;
|
|
60
60
|
if (alias) {
|
|
61
61
|
let absoluteImportPath = matchPath ? matchPath(name2, void 0, void 0, extensions) : void 0;
|
|
@@ -119,16 +119,15 @@ async function redirectImport(compiler, code, modules, aliasRecord, filePath, ou
|
|
|
119
119
|
if (redirect2.asset) {
|
|
120
120
|
if (import_file.assetExt.filter((ext2) => name2.endsWith(ext2)).length) {
|
|
121
121
|
const absPath = (0, import_path.resolve)((0, import_path.dirname)(filePath), name2);
|
|
122
|
-
const
|
|
123
|
-
|
|
122
|
+
const { contents: relativeImportPath, loader } = await import_asset.getAssetContents.apply(compiler, [
|
|
123
|
+
absPath,
|
|
124
|
+
outputDir
|
|
125
|
+
]);
|
|
126
|
+
if (loader === "jsx") {
|
|
124
127
|
const ext2 = (0, import_path.extname)(name2);
|
|
125
128
|
const outputName = `${name2.slice(0, -ext2.length)}.js`;
|
|
126
129
|
str.overwrite(start, end, outputName);
|
|
127
130
|
} else {
|
|
128
|
-
const { contents: relativeImportPath } = await import_asset.getAssetContents.apply(compiler, [
|
|
129
|
-
absPath,
|
|
130
|
-
outputDir
|
|
131
|
-
]);
|
|
132
131
|
str.overwrite(start, end, `${relativeImportPath}`);
|
|
133
132
|
}
|
|
134
133
|
}
|
|
@@ -34,8 +34,7 @@ module.exports = __toCommonJS(lessAliasPlugin_exports);
|
|
|
34
34
|
var import_define_property = require("@swc/helpers/_/_define_property");
|
|
35
35
|
var import_fs = __toESM(require("fs"));
|
|
36
36
|
var import_utils = require("./utils");
|
|
37
|
-
|
|
38
|
-
LessAliasesPlugin = class LessAliasesPlugin2 {
|
|
37
|
+
class LessAliasesPlugin {
|
|
39
38
|
install(less, pluginManager) {
|
|
40
39
|
const getResolve = (filename, currentDirectory) => {
|
|
41
40
|
return this.compiler.css_resolve(filename, currentDirectory || this.stdinDir);
|
|
@@ -68,4 +67,4 @@ LessAliasesPlugin = class LessAliasesPlugin2 {
|
|
|
68
67
|
this.compiler = options.compiler;
|
|
69
68
|
this.stdinDir = options.stdinDir;
|
|
70
69
|
}
|
|
71
|
-
}
|
|
70
|
+
}
|
|
@@ -33,8 +33,11 @@ const postcssUrlPlugin = (options) => {
|
|
|
33
33
|
postcssPlugin: "postcss-url",
|
|
34
34
|
async Declaration(decl) {
|
|
35
35
|
const isProcessed = decl[Processed];
|
|
36
|
+
if (isProcessed) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
36
39
|
decl.value = await (0, import_utils.rewriteCssUrls)(decl.value, false, async (URL) => {
|
|
37
|
-
if (URL && !HTTP_PATTERNS.test(URL) && !HASH_PATTERNS.test(URL) && !DATAURL_PATTERNS.test(URL)
|
|
40
|
+
if (URL && !HTTP_PATTERNS.test(URL) && !HASH_PATTERNS.test(URL) && !DATAURL_PATTERNS.test(URL)) {
|
|
38
41
|
let filePath = URL;
|
|
39
42
|
const { outDir, sourceDir, buildType } = options.compilation.config;
|
|
40
43
|
const { css_resolve } = options.compilation;
|
|
@@ -94,8 +94,12 @@ async function rebaseUrls(filepath, rootDir, resolver) {
|
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
function rewriteCssUrls(css, type, replacer) {
|
|
98
|
-
|
|
97
|
+
async function rewriteCssUrls(css, type, replacer) {
|
|
98
|
+
let match;
|
|
99
|
+
let remaining = css;
|
|
100
|
+
let rewritten = "";
|
|
101
|
+
while (match = cssUrlRE.exec(remaining)) {
|
|
102
|
+
rewritten += remaining.slice(0, match.index);
|
|
99
103
|
const matched = match[0];
|
|
100
104
|
let rawUrl = match[1];
|
|
101
105
|
let wrap = "";
|
|
@@ -104,19 +108,8 @@ function rewriteCssUrls(css, type, replacer) {
|
|
|
104
108
|
wrap = first;
|
|
105
109
|
rawUrl = rawUrl.slice(1, -1);
|
|
106
110
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
return `url(${wrap}${(0, import_utils.normalizeSlashes)(await replacer(rawUrl))}${wrap})`;
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
async function asyncReplace(input, re, replacer) {
|
|
114
|
-
let match;
|
|
115
|
-
let remaining = input;
|
|
116
|
-
let rewritten = "";
|
|
117
|
-
while (match = re.exec(remaining)) {
|
|
118
|
-
rewritten += remaining.slice(0, match.index);
|
|
119
|
-
rewritten += await replacer(match);
|
|
111
|
+
const result = type === "less" && rawUrl.startsWith("@") || (type === "sass" || type === "scss") && rawUrl.startsWith("$") || isExternalUrl(rawUrl) || isDataUrl(rawUrl) || rawUrl.startsWith("#") ? matched : `url(${wrap}${(0, import_utils.normalizeSlashes)(await replacer(rawUrl))}${wrap})`;
|
|
112
|
+
rewritten += result;
|
|
120
113
|
remaining = remaining.slice(match.index + match[0].length);
|
|
121
114
|
}
|
|
122
115
|
rewritten += remaining;
|
package/dist/constants/build.js
CHANGED
|
@@ -41,6 +41,12 @@ export type Redirect = {
|
|
|
41
41
|
export type DTSOptions = {
|
|
42
42
|
abortOnError: boolean;
|
|
43
43
|
distPath: string;
|
|
44
|
+
/**
|
|
45
|
+
* Build one or more projects and their dependencies, if out of date
|
|
46
|
+
* The same as 'tsc --build'
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
enableTscBuild: boolean;
|
|
44
50
|
only: boolean;
|
|
45
51
|
/**
|
|
46
52
|
* @deprecated
|
package/dist/types/dts.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface GeneratorDtsConfig {
|
|
|
14
14
|
respectExternal: boolean;
|
|
15
15
|
dtsExtension: string;
|
|
16
16
|
userTsconfig: ITsconfig;
|
|
17
|
+
enableTscBuild: boolean;
|
|
17
18
|
}
|
|
18
19
|
export interface GeneratedDtsInfo {
|
|
19
20
|
userTsconfig: ITsconfig;
|
|
@@ -36,6 +37,9 @@ export interface ITsconfig {
|
|
|
36
37
|
paths?: Record<string, string[]>;
|
|
37
38
|
target?: TsTarget;
|
|
38
39
|
useDefineForClassFields?: boolean;
|
|
40
|
+
composite?: boolean;
|
|
41
|
+
incremental?: boolean;
|
|
42
|
+
tsBuildInfoFile?: string;
|
|
39
43
|
} | undefined;
|
|
40
44
|
include?: string[];
|
|
41
45
|
exclude?: string[];
|
package/dist/utils/dts.js
CHANGED
|
@@ -123,7 +123,12 @@ const processDtsFilesAfterTsc = async (config) => {
|
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
125
|
const { start, end, name } = module2;
|
|
126
|
-
const absoluteImportPath = matchPath(name
|
|
126
|
+
const absoluteImportPath = matchPath(name, void 0, void 0, [
|
|
127
|
+
".jsx",
|
|
128
|
+
".tsx",
|
|
129
|
+
".js",
|
|
130
|
+
".ts"
|
|
131
|
+
]);
|
|
127
132
|
if (absoluteImportPath) {
|
|
128
133
|
const relativePath = (0, import_path.relative)((0, import_path.dirname)(originalFilePath), absoluteImportPath);
|
|
129
134
|
const relativeImportPath = (0, import_builder.normalizeSlashes)(relativePath.startsWith("..") ? relativePath : `./${relativePath}`);
|
|
@@ -144,12 +149,23 @@ ${footer}
|
|
|
144
149
|
// users need to set esbuild out-extensions like { '.js': '.mjs' }
|
|
145
150
|
filePath.replace(/\.d\.ts/, dtsExtension)
|
|
146
151
|
);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
const writeTask = () => {
|
|
153
|
+
return import_utils.fs.writeFile(
|
|
154
|
+
// only replace .d.ts, if tsc generate .d.m(c)ts, keep.
|
|
155
|
+
finalPath,
|
|
156
|
+
content
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
const removeTask = () => {
|
|
160
|
+
return import_utils.fs.remove(filePath);
|
|
161
|
+
};
|
|
162
|
+
return dtsExtension === ".d.ts" ? [
|
|
163
|
+
writeTask()
|
|
164
|
+
] : [
|
|
165
|
+
writeTask(),
|
|
166
|
+
removeTask()
|
|
167
|
+
];
|
|
168
|
+
}).flat());
|
|
153
169
|
};
|
|
154
170
|
const printOrThrowDtsErrors = async (error, options) => {
|
|
155
171
|
const { InternalDTSError } = await Promise.resolve().then(() => __toESM(require("../error")));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/module-tools",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.44.0",
|
|
4
4
|
"description": "Simple, powerful, high-performance modern npm package development solution.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"modern",
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@ampproject/remapping": "^2.2.1",
|
|
50
50
|
"@ast-grep/napi": "0.12.0",
|
|
51
|
-
"@modern-js/swc-plugins": "0.6.
|
|
51
|
+
"@modern-js/swc-plugins": "0.6.6",
|
|
52
52
|
"@rollup/pluginutils": "4.1.1",
|
|
53
|
-
"@svgr/core": "8.
|
|
54
|
-
"@svgr/plugin-jsx": "8.0
|
|
55
|
-
"@svgr/plugin-svgo": "8.0
|
|
53
|
+
"@svgr/core": "8.1.0",
|
|
54
|
+
"@svgr/plugin-jsx": "8.1.0",
|
|
55
|
+
"@svgr/plugin-svgo": "8.1.0",
|
|
56
56
|
"@swc/helpers": "0.5.3",
|
|
57
57
|
"convert-source-map": "1.8.0",
|
|
58
58
|
"enhanced-resolve": "5.12.0",
|
|
@@ -67,24 +67,24 @@
|
|
|
67
67
|
"tapable": "2.2.1",
|
|
68
68
|
"terser": "5.19.2",
|
|
69
69
|
"tsconfig-paths-webpack-plugin": "4.1.0",
|
|
70
|
-
"@modern-js/core": "2.
|
|
71
|
-
"@modern-js/
|
|
72
|
-
"@modern-js/plugin
|
|
73
|
-
"@modern-js/plugin-
|
|
74
|
-
"@modern-js/
|
|
75
|
-
"@modern-js/plugin-lint": "2.
|
|
76
|
-
"@modern-js/types": "2.
|
|
77
|
-
"@modern-js/
|
|
78
|
-
"@modern-js/
|
|
70
|
+
"@modern-js/core": "2.44.0",
|
|
71
|
+
"@modern-js/new-action": "2.44.0",
|
|
72
|
+
"@modern-js/plugin": "2.44.0",
|
|
73
|
+
"@modern-js/plugin-changeset": "2.44.0",
|
|
74
|
+
"@modern-js/plugin-i18n": "2.44.0",
|
|
75
|
+
"@modern-js/plugin-lint": "2.44.0",
|
|
76
|
+
"@modern-js/types": "2.44.0",
|
|
77
|
+
"@modern-js/upgrade": "2.44.0",
|
|
78
|
+
"@modern-js/utils": "2.44.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@types/convert-source-map": "1.5.2",
|
|
82
82
|
"@types/node": "^14",
|
|
83
83
|
"typescript": "^5",
|
|
84
|
-
"@modern-js/builder-webpack-provider": "2.
|
|
85
|
-
"@
|
|
86
|
-
"@
|
|
87
|
-
"@scripts/vitest-config": "2.
|
|
84
|
+
"@modern-js/builder-webpack-provider": "2.44.0",
|
|
85
|
+
"@scripts/build": "2.44.0",
|
|
86
|
+
"@modern-js/self": "npm:@modern-js/module-tools@2.44.0",
|
|
87
|
+
"@scripts/vitest-config": "2.44.0"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
90
|
"typescript": "^4 || ^5"
|