@modern-js/module-tools 2.33.1 → 2.35.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/README.md +2 -2
- package/bin/modern.js +1 -1
- package/compiled/postcss-custom-properties/index.js +1 -1
- package/compiled/postcss-flexbugs-fixes/index.js +1 -1
- package/compiled/postcss-font-variant/index.js +1 -1
- package/compiled/postcss-initial/index.js +1 -1
- package/compiled/postcss-media-minmax/index.js +1 -1
- package/compiled/postcss-nesting/index.js +1 -1
- package/compiled/postcss-page-break/index.js +1 -1
- package/compiled/rollup-plugin-dts/index.js +1 -1
- package/dist/builder/build.js +1 -1
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/dts/tsc.d.ts +1 -2
- package/dist/builder/dts/tsc.js +5 -21
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/plugins.js +2 -0
- package/dist/plugins.js.map +1 -1
- package/dist/types/dts.d.ts +3 -0
- package/dist/utils/dts.d.ts +7 -3
- package/dist/utils/dts.js +37 -12
- package/dist/utils/dts.js.map +1 -1
- package/dist/utils/tspathsTransform.js.map +1 -1
- package/package.json +22 -22
package/dist/builder/dts/tsc.js
CHANGED
|
@@ -2,18 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: all[name]
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
_export(exports, {
|
|
13
|
-
getProjectTsconfig: function() {
|
|
14
|
-
return getProjectTsconfig;
|
|
15
|
-
},
|
|
16
|
-
runTsc: function() {
|
|
5
|
+
Object.defineProperty(exports, "runTsc", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
17
8
|
return runTsc;
|
|
18
9
|
}
|
|
19
10
|
});
|
|
@@ -23,12 +14,6 @@ const _dts = require("../../utils/dts");
|
|
|
23
14
|
const _log = require("../../utils/log");
|
|
24
15
|
const _log1 = require("../../constants/log");
|
|
25
16
|
const _dts1 = require("../../constants/dts");
|
|
26
|
-
const getProjectTsconfig = async (tsconfigPath) => {
|
|
27
|
-
if (!_utils.fs.existsSync(tsconfigPath)) {
|
|
28
|
-
return {};
|
|
29
|
-
}
|
|
30
|
-
return _utils.json5.parse(_utils.fs.readFileSync(tsconfigPath, "utf-8"));
|
|
31
|
-
};
|
|
32
17
|
const resolveLog = async (childProgress, options) => {
|
|
33
18
|
var _childProgress_stdout, _childProgress_stdout1, _childProgress_stderr;
|
|
34
19
|
const { watch = false, watchFn = async () => void 0 } = options;
|
|
@@ -49,9 +34,8 @@ const resolveLog = async (childProgress, options) => {
|
|
|
49
34
|
});
|
|
50
35
|
};
|
|
51
36
|
const generatorDts = async (api, config) => {
|
|
52
|
-
const {
|
|
53
|
-
const userTsconfig = await
|
|
54
|
-
const result = await (0, _dts.generatorTsConfig)(config);
|
|
37
|
+
const { appDirectory, watch = false, abortOnError = true } = config;
|
|
38
|
+
const { userTsconfig, generatedTsconfig: result } = await (0, _dts.generatorTsConfig)(config);
|
|
55
39
|
const tscBinFile = await (0, _dts.getTscBinPath)(appDirectory);
|
|
56
40
|
const watchParams = watch ? [
|
|
57
41
|
"-w"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;+BAuGaA;;;WAAAA;;;uBAtGiB;uBACF;qBAWrB;qBAC2B;sBAI3B;sBACuB;AAE9B,MAAMC,aAAa,OACjBC,eACAC;MAYAD,uBAYAA,wBAGAA;AAtBA,QAAM,EAAEE,QAAQ,OAAOC,UAAU,YAAYC,OAAS,IAAKH;GAO3DD,sCAAcK,YAAM,QAApBL,kEAAsBM,GAAG,QAAQ,OAAMC;AACrC,QAAIL,OAAO;AACTM,oBAAOC,KACL,OAAMC,2BAAkBC,8BAAwBC,yBAAmBC,GAAG;AAExEL,oBAAOC,KAAKF,KAAKO,SAAQ;AACzB,UAAIP,KAAKO,SAAQ,EAAGC,SAASC,mBAAa,GAAG;AAC3C,cAAMb;MACR;IACF;EACF;GAEAH,uCAAcK,YAAM,QAApBL,oEAAsBM,GAAG,SAASW;AAChCT,kBAAOS,MAAMA,MAAMC,OAAO;EAC5B;GACAlB,sCAAcmB,YAAM,QAApBnB,kEAAsBM,GAAG,QAAQc;AAC/BZ,kBAAOS,MAAMG,MAAMN,SAAQ;EAC7B;AACF;AAEA,MAAMO,eAAe,OACnBC,KACAC;AAEA,QAAM,EAAEC,cAActB,QAAQ,OAAOuB,eAAe,KAAI,IAAKF;AAE7D,QAAM,EAAEG,cAAcC,mBAAmBC,OAAM,IAAK,OAAMC,2BACxDN;AAGF,QAAMO,aAAa,OAAMC,uBAAcP;AAEvC,QAAMQ,cAAc9B,QAAQ;IAAC;MAAQ;AACrC,QAAMF,iBAAgBiC,iBACpBH,YACA;IACE;IACAF,OAAOM;;IAEP;;IAEA;OACGF;KAEL;IACEG,OAAO;IACPC,KAAKZ;EACP;AAGF,QAAMa,SAASf,IAAIgB,eAAc;AACjCvC,aAAWC,eAAe;IACxBE;IACAC,SAAS;AACP,aAAMoC,sBAAahB,QAAQ;QAAE,GAAGK;QAAQF;MAAa;AACrDW,aAAOG,cAAc;QAAEC,WAAW;MAAa;IACjD;EACF;AAEA,MAAI;AACF,UAAMzC;EACR,SAAS0C,GAAP;AACA,WAAMC,+BAAsBD,GAAG;MAAEjB;MAAcgB,WAAW;IAAa;EACzE;AAEA,SAAO;IAAE,GAAGb;IAAQF;EAAa;AACnC;AAEO,MAAM5B,SAAS,OACpBwB,KACAC;AAEA,QAAMK,SAAS,MAAMP,aAAaC,KAAKC;AACvC,SAAMgB,sBAAahB,QAAQK;AAC3B,SAAMgB,uBAAYrB,OAAOsB,aAAatB,OAAOC,YAAY;AAC3D;","names":["runTsc","resolveLog","childProgress","options","watch","watchFn","undefined","stdout","on","data","logger","info","watchSectionTitle","BundlelessDtsLogPrefix","SectionTitleStatus","Log","toString","includes","watchDoneText","error","message","stderr","chunk","generatorDts","api","config","appDirectory","abortOnError","userTsconfig","generatedTsconfig","result","generatorTsConfig","tscBinFile","getTscBinPath","watchParams","execa","tempTsconfigPath","stdio","cwd","runner","useHookRunners","resolveAlias","buildWatchDts","buildType","e","printOrThrowDtsErrors","addDtsFiles","distAbsPath"],"sources":["../../../src/builder/dts/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/builder/dts/tsc.ts"],"sourcesContent":["import type { ChildProcess } from 'child_process';\nimport { execa, logger } from '@modern-js/utils';\nimport { addDtsFiles } from '../../utils/print';\nimport type {\n BundlelessGeneratorDtsConfig,\n PluginAPI,\n ModuleTools,\n} from '../../types';\nimport {\n generatorTsConfig,\n getTscBinPath,\n printOrThrowDtsErrors,\n resolveAlias,\n} from '../../utils/dts';\nimport { watchSectionTitle } from '../../utils/log';\nimport {\n BundlelessDtsLogPrefix,\n SectionTitleStatus,\n} from '../../constants/log';\nimport { watchDoneText } from '../../constants/dts';\n\nconst resolveLog = async (\n childProgress: ChildProcess,\n options: {\n watch: boolean;\n watchFn: () => Promise<void>;\n },\n) => {\n const { watch = false, watchFn = async () => undefined } = options;\n\n /**\n * tsc 所有的log信息都是从stdout data 事件中获取\n * 正常模式下,如果有报错信息,交给 resolveLog 后面的逻辑来处理\n * watch 模式下,则使用这里的信息\n */\n childProgress.stdout?.on('data', async data => {\n if (watch) {\n logger.info(\n await watchSectionTitle(BundlelessDtsLogPrefix, SectionTitleStatus.Log),\n );\n logger.info(data.toString());\n if (data.toString().includes(watchDoneText)) {\n await watchFn();\n }\n }\n });\n // 正常以下内容都不会触发,因为tsc 不会产生以下类型的log信息,不过防止意外情况\n childProgress.stdout?.on('error', error => {\n logger.error(error.message);\n });\n childProgress.stderr?.on('data', chunk => {\n logger.error(chunk.toString());\n });\n};\n\nconst generatorDts = async (\n api: PluginAPI<ModuleTools>,\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { appDirectory, watch = false, abortOnError = true } = config;\n\n const { userTsconfig, generatedTsconfig: result } = await generatorTsConfig(\n config,\n );\n\n const tscBinFile = await getTscBinPath(appDirectory);\n\n const watchParams = watch ? ['-w'] : [];\n const childProgress = execa(\n tscBinFile,\n [\n '-p',\n result.tempTsconfigPath,\n /* Required parameter, use it stdout have color */\n '--pretty',\n // https://github.com/microsoft/TypeScript/issues/21824\n '--preserveWatchOutput',\n ...watchParams,\n ],\n {\n stdio: 'pipe',\n cwd: appDirectory,\n },\n );\n\n const runner = api.useHookRunners();\n resolveLog(childProgress, {\n watch,\n watchFn: async () => {\n await resolveAlias(config, { ...result, userTsconfig });\n runner.buildWatchDts({ buildType: 'bundleless' });\n },\n });\n\n try {\n await childProgress;\n } catch (e) {\n await printOrThrowDtsErrors(e, { abortOnError, buildType: 'bundleless' });\n }\n\n return { ...result, userTsconfig };\n};\n\nexport const runTsc = async (\n api: PluginAPI<ModuleTools>,\n config: BundlelessGeneratorDtsConfig,\n) => {\n const result = await generatorDts(api, config);\n await resolveAlias(config, result);\n await addDtsFiles(config.distAbsPath, config.appDirectory);\n};\n"]}
|
package/dist/plugins.js
CHANGED
package/dist/plugins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;+BAIaA;;;WAAAA;;;iCAHmB;4BACL;AAEpB,MAAMA,aAAa,CAACC;AACzB,MAAIC,UAAuB;AAE3B,UAAQD;IACN,KAAK;AACHC,gBAAU;AACV;IACF,KAAK;AACHA,gBAAU;SAACC,2BAAU;;AACrB;IACF,KAAK;IACL,KAAK;IACL,KAAK;AACHD,gBAAU;SAACE,qCAAe;;AAC1B;IACF;AACEF,gBAAU;EACd;AAEA,SAAOA;AACT;","names":["getPlugins","runningCmd","plugins","lintPlugin","changesetPlugin"],"sources":["../src/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/plugins.ts"],"sourcesContent":["import type { CliPlugin } from '@modern-js/core';\nimport { changesetPlugin } from '@modern-js/plugin-changeset';\nimport { lintPlugin } from '@modern-js/plugin-lint';\n\nexport const getPlugins = (runningCmd: string) => {\n let plugins: CliPlugin[] = [];\n\n switch (runningCmd) {\n case 'build':\n plugins = [];\n break;\n case 'lint':\n plugins = [lintPlugin()];\n break;\n case 'change':\n case 'release':\n case 'bump':\n plugins = [changesetPlugin()];\n break;\n default:\n plugins = [];\n }\n\n return plugins;\n};\n"]}
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;+BAIaA;;;WAAAA;;;iCAHmB;4BACL;AAEpB,MAAMA,aAAa,CAACC;AACzB,MAAIC,UAAuB;AAE3B,UAAQD;IACN,KAAK;AACHC,gBAAU;AACV;IACF,KAAK;AACHA,gBAAU;SAACC,2BAAU;;AACrB;IACF,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;AACHD,gBAAU;SAACE,qCAAe;;AAC1B;IACF;AACEF,gBAAU;EACd;AAEA,SAAOA;AACT;","names":["getPlugins","runningCmd","plugins","lintPlugin","changesetPlugin"],"sources":["../src/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/plugins.ts"],"sourcesContent":["import type { CliPlugin } from '@modern-js/core';\nimport { changesetPlugin } from '@modern-js/plugin-changeset';\nimport { lintPlugin } from '@modern-js/plugin-lint';\n\nexport const getPlugins = (runningCmd: string) => {\n let plugins: CliPlugin[] = [];\n\n switch (runningCmd) {\n case 'build':\n plugins = [];\n break;\n case 'lint':\n plugins = [lintPlugin()];\n break;\n case 'change':\n case 'release':\n case 'bump':\n case 'pre':\n case 'gen-release-note':\n plugins = [changesetPlugin()];\n break;\n default:\n plugins = [];\n }\n\n return plugins;\n};\n"]}
|
package/dist/types/dts.d.ts
CHANGED
package/dist/utils/dts.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { ITsconfig, BundlelessGeneratorDtsConfig, BuildType, TsTarget } from '../types';
|
|
2
|
+
export declare const getProjectTsconfig: (tsconfigPath: string) => Promise<ITsconfig>;
|
|
2
3
|
export declare const generatorTsConfig: (config: BundlelessGeneratorDtsConfig) => Promise<{
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
userTsconfig: ITsconfig;
|
|
5
|
+
generatedTsconfig: {
|
|
6
|
+
tempTsconfigPath: string;
|
|
7
|
+
tempDistAbsRootPath: string;
|
|
8
|
+
tempDistAbsSrcPath: string;
|
|
9
|
+
};
|
|
6
10
|
}>;
|
|
7
11
|
export declare const getTscBinPath: (appDirectory: string) => Promise<string>;
|
|
8
12
|
export declare const resolveAlias: (config: BundlelessGeneratorDtsConfig, options: {
|
package/dist/utils/dts.js
CHANGED
|
@@ -10,6 +10,9 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
+
getProjectTsconfig: function() {
|
|
14
|
+
return getProjectTsconfig;
|
|
15
|
+
},
|
|
13
16
|
generatorTsConfig: function() {
|
|
14
17
|
return generatorTsConfig;
|
|
15
18
|
},
|
|
@@ -26,18 +29,36 @@ _export(exports, {
|
|
|
26
29
|
return tsTargetAtOrAboveES2022;
|
|
27
30
|
}
|
|
28
31
|
});
|
|
29
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
30
32
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
31
|
-
const _path =
|
|
33
|
+
const _path = require("path");
|
|
32
34
|
const _utils = require("@modern-js/utils");
|
|
35
|
+
const getProjectTsconfig = async (tsconfigPath) => {
|
|
36
|
+
if (!_utils.fs.existsSync(tsconfigPath)) {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
return _utils.json5.parse(_utils.fs.readFileSync(tsconfigPath, "utf-8"));
|
|
40
|
+
};
|
|
33
41
|
const generatorTsConfig = async (config) => {
|
|
34
|
-
|
|
42
|
+
var _userTsconfig_references, _userTsconfig;
|
|
35
43
|
const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
44
|
+
const userTsconfig = await getProjectTsconfig(tsconfigPath);
|
|
45
|
+
const { dtsTempDirectory } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../constants/dts")));
|
|
46
|
+
const tempDistAbsRootPath = (0, _path.join)(appDirectory, `${dtsTempDirectory}/${(0, _utils.nanoid)()}`);
|
|
47
|
+
const tempDistAbsOurDir = (0, _path.join)(tempDistAbsRootPath, (0, _path.relative)(appDirectory, absSourceDir));
|
|
48
|
+
const tempTsconfigPath = (0, _path.join)(tempDistAbsRootPath, (0, _path.basename)(tsconfigPath));
|
|
39
49
|
_utils.fs.ensureFileSync(tempTsconfigPath);
|
|
40
|
-
const extendsPath = _path.
|
|
50
|
+
const extendsPath = (0, _path.join)((0, _path.relative)((0, _path.dirname)(tempTsconfigPath), (0, _path.dirname)(tsconfigPath)), (0, _path.basename)(tempTsconfigPath));
|
|
51
|
+
const references = (_userTsconfig = userTsconfig) === null || _userTsconfig === void 0 ? void 0 : (_userTsconfig_references = _userTsconfig.references) === null || _userTsconfig_references === void 0 ? void 0 : _userTsconfig_references.map((reference) => {
|
|
52
|
+
const { path } = reference;
|
|
53
|
+
if (path) {
|
|
54
|
+
const userTsconfigDir = (0, _path.dirname)(tsconfigPath);
|
|
55
|
+
const generatedTsconfigDir = (0, _path.dirname)(tempTsconfigPath);
|
|
56
|
+
return {
|
|
57
|
+
path: (0, _path.isAbsolute)(path) ? path : (0, _path.relative)(generatedTsconfigDir, (0, _path.resolve)(userTsconfigDir, path))
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return reference;
|
|
61
|
+
});
|
|
41
62
|
const resetConfig = {
|
|
42
63
|
extends: extendsPath,
|
|
43
64
|
compilerOptions: {
|
|
@@ -50,19 +71,23 @@ const generatorTsConfig = async (config) => {
|
|
|
50
71
|
// - ./types/index.d.ts
|
|
51
72
|
// we only want to emit declarations
|
|
52
73
|
declarationDir: tempDistAbsOurDir
|
|
53
|
-
}
|
|
74
|
+
},
|
|
75
|
+
references
|
|
54
76
|
};
|
|
55
77
|
_utils.fs.writeJSONSync(tempTsconfigPath, resetConfig);
|
|
56
78
|
return {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
79
|
+
userTsconfig,
|
|
80
|
+
generatedTsconfig: {
|
|
81
|
+
tempTsconfigPath,
|
|
82
|
+
tempDistAbsRootPath,
|
|
83
|
+
tempDistAbsSrcPath: tempDistAbsOurDir
|
|
84
|
+
}
|
|
60
85
|
};
|
|
61
86
|
};
|
|
62
87
|
const getTscBinPath = async (appDirectory) => {
|
|
63
88
|
const { default: findUp, exists: pathExists } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../../compiled/find-up")));
|
|
64
89
|
const tscBinFile = await findUp(async (directory) => {
|
|
65
|
-
const targetFilePath = _path.
|
|
90
|
+
const targetFilePath = (0, _path.join)(directory, "./node_modules/.bin/tsc");
|
|
66
91
|
const hasTscBinFile = await pathExists(targetFilePath);
|
|
67
92
|
if (hasTscBinFile) {
|
|
68
93
|
return targetFilePath;
|
package/dist/utils/dts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EASaA,mBAAiB;WAAjBA;;EAkDAC,eAAa;WAAbA;;EAyBAC,cAAY;WAAZA;;EA8EAC,uBAAqB;WAArBA;;EA2BAC,yBAAuB;WAAvBA;;;;;iEA7LI;uBACiC;AAQ3C,MAAMJ,oBAAoB,OAC/BK;AAEA,QAAM,EAAEC,iBAAgB,IAAK,MAAM,iFAAO;AAE1C,QAAM,EAAEC,cAAcC,WAAWC,cAAcC,aAAY,IAAKL;AAChE,QAAMM,sBAAsBC,cAAKC,KAC/BN,cACA,GAAGD,qBAAoBQ,kBAAM,GAAI;AAEnC,QAAMC,oBAAoBH,cAAKC,KAC7BF,qBACAC,cAAKI,SAAST,cAAcE;AAG9B,QAAMQ,mBAAmBL,cAA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AAC;EACjD;AACA,aAAWa,KAAKJ,QAAQ;AACtBnC,cAAGwC,cAAcD,EAAE9C,MAAM8C,EAAEE,OAAO;EACpC;AAGA,QAAMzC,UAAG0C,UAAUd;AACnB,QAAM5B,UAAG2C,KAAKhC,oBAAoBiB;AACpC;AAgDO,MAAM5C,wBAAwB,OACnC4D,OACApB;AAEA,QAAM,EAAEqB,iBAAgB,IAAK,MAAM,iFAAO;AAC1C,QAAMC,QAAQ,MAAM,iFAAO;AAC3B,QAAM,EAAEC,cAAcC,UAAS,IAAKxB,mDAAW,CAAC;AAChD,MAAIoB,iBAAiBrB,OAAO;AAC1B,QAAIwB,cAAc;AAChB,YAAM,IAAIF,iBAAiBD,OAAO;QAChCI;MACF;IACF,OAAO;AACLC,oBAAOC,KACLC,aAAMC,eACJN,MAAMO,KAAKC,EAAER,MAAMS,WAAWC,MAAMC,IAAIV,YAAY;AAGxDE,oBAAOL,MACL,IAAIC,iBAAiBD,OAAO;QAC1BI;MACF;IAEJ;EACF;AACF;AAEO,MAAM/D,0BAA0B,CAACyE,WACtCA,WAAW,YAAYA,WAAW;","names":["generatorTsConfig","getTscBinPath","resolveAlias","printOrThrowDtsErrors","tsTargetAtOrAboveES2022","config","dtsTempDirectory","appDirectory","sourceDir","absSourceDir","tsconfigPath","tempDistAbsRootPath","path","join","nanoid","tempDistAbsOurDir","relative","tempTsconfigPath","basename","fs","ensureFileSync","extendsPath","dirname","resetConfig","extends","compilerOptions","declaration","emitDeclarationOnly","declarationDir","writeJSONSync","tempDistAbsSrcPath","default","findUp","exists","pathExists","tscBinFile","directory","targetFilePath","hasTscBinFile","undefined","cwd","existsSync","Error","options","watchFilenames","userTsconfig","transformDtsAlias","distAbsPath","dtsDistPath","dtsFilenames","length","globby","sync","absolute","result","filenames","baseUrl","paths","r","writeFileSync","content","ensureDir","copy","error","InternalDTSError","local","abortOnError","buildType","logger","warn","chalk","bgYellowBright","i18n","t","localeKeys","warns","dts","target"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/dts.ts"],"sourcesContent":["import path from 'path';\nimport { chalk, fs, globby, logger, nanoid } from '@modern-js/utils';\nimport type {\n ITsconfig,\n BundlelessGeneratorDtsConfig,\n BuildType,\n TsTarget,\n} from '../types';\n\nexport const generatorTsConfig = async (\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { dtsTempDirectory } = await import('../constants/dts');\n\n const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;\n const tempDistAbsRootPath = path.join(\n appDirectory,\n `${dtsTempDirectory}/${nanoid()}`,\n );\n const tempDistAbsOurDir = path.join(\n tempDistAbsRootPath,\n path.relative(appDirectory, absSourceDir),\n );\n\n const tempTsconfigPath = path.join(\n tempDistAbsRootPath,\n path.basename(tsconfigPath),\n );\n fs.ensureFileSync(tempTsconfigPath);\n\n const extendsPath = path.join(\n path.relative(path.dirname(tempTsconfigPath), path.dirname(tsconfigPath)),\n path.basename(tempTsconfigPath),\n );\n\n const resetConfig: ITsconfig = {\n extends: extendsPath,\n compilerOptions: {\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n // when `outDir` is './dist', `declarationDir` is `./types`\n // tsc will emit:\n // - ./dist/index.js\n // - ./types/index.d.ts\n // we only want to emit declarations\n declarationDir: tempDistAbsOurDir,\n },\n };\n\n fs.writeJSONSync(tempTsconfigPath, resetConfig);\n\n return {\n tempTsconfigPath,\n tempDistAbsRootPath,\n tempDistAbsSrcPath: tempDistAbsOurDir,\n };\n};\n\nexport const getTscBinPath = async (appDirectory: string) => {\n const { 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 { 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 // why use `ensureDir` before copy? look this: https://github.com/jprichardson/node-fs-extra/issues/957\n await fs.ensureDir(distAbsPath);\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 printOrThrowDtsErrors = async (\n error: unknown,\n options: { abortOnError?: boolean; buildType: BuildType },\n) => {\n const { InternalDTSError } = await import('../error');\n const local = await import('../locale');\n const { abortOnError, buildType } = options ?? {};\n if (error instanceof Error) {\n if (abortOnError) {\n throw new InternalDTSError(error, {\n buildType,\n });\n } else {\n logger.warn(\n chalk.bgYellowBright(\n local.i18n.t(local.localeKeys.warns.dts.abortOnError),\n ),\n );\n logger.error(\n new InternalDTSError(error, {\n buildType,\n }),\n );\n }\n }\n};\n\nexport const tsTargetAtOrAboveES2022 = (target: TsTarget) =>\n target === 'es2022' || target === 'esnext';\n"]}
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EASaA,oBAAkB;WAAlBA;;EAUAC,mBAAiB;WAAjBA;;EAkEAC,eAAa;WAAbA;;EAyBAC,cAAY;WAAZA;;EA8EAC,uBAAqB;WAArBA;;EA2BAC,yBAAuB;WAAvBA;;;;sBAvN0D;uBACd;AAQlD,MAAML,qBAAqB,OAChCM;AAEA,MAAI,CAACC,UAAGC,WAAWF,eAAe;AAChC,WAAO,CAAC;EACV;AAEA,SAAOG,aAAMC,MAAMH,UAAGI,aAAaL,cAAc;AACnD;AAEO,MAAML,oBAAoB,OAC/BW;MAuBmBC;AArBnB,QAAM,EAAEC,cAAcC,WAAWC,cAAcV,aAAY,IAAKM;AAEhE,QAAMC,eAAe,MAAMb,mBAAmBM;AAC9C,QAAM,EAAEW,iBAAgB,IAAK,MAAM,iFAAO;AAE1C,QAAMC,uBAAsBC,eAC1BL,cACA,GAAGG,qBAAoBG,kBAAM,GAAI;AAEnC,QAAMC,qBAAoBF,eACxBD,sBACAI,mBAASR,cAAcE;AAGzB,QAAMO,oBAAmBJ,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QAAM,EAAEC,YAAW,IAAK/C;AACxB,QAAMgD,cAAc,GAAGhB;AACvB,QAAMiB,eACJJ,eAAeK,SAAS,IACpBL,iBACAM,cAAOC,KAAKJ,aAAa;IAAEK,UAAU;EAAK;MAIvCpD;AAHT,QAAMqD,SAASR,kBAAkB;IAC/BS,WAAWN;IACXO,SAASlD;IACTmD,QAAOxD,oFAAayB,qBAAe,QAA5BzB,kFAA8BwD,WAAK,QAAnCxD,uFAAuC,CAAC;EACjD;AACA,aAAWyD,KAAKJ,QAAQ;AACtB3D,cAAGgE,cAAcD,EAAEvC,MAAMuC,EAAEE,OAAO;EACpC;AAGA,QAAMjE,UAAGkE,UAAUd;AACnB,QAAMpD,UAAGmE,KAAK9B,oBAAoBe;AACpC;AAgDO,MAAMvD,wBAAwB,OACnCuE,OACAnB;AAEA,QAAM,EAAEoB,iBAAgB,IAAK,MAAM,iFAAO;AAC1C,QAAMC,QAAQ,MAAM,iFAAO;AAC3B,QAAM,EAAEC,cAAcC,UAAS,IAAKvB,mDAAW,CAAC;AAChD,MAAImB,iBAAiBpB,OAAO;AAC1B,QAAIuB,cAAc;AAChB,YAAM,IAAIF,iBAAiBD,OAAO;QAChCI;MACF;IACF,OAAO;AACLC,oBAAOC,KACLC,aAAMC,eACJN,MAAMO,KAAKC,EAAER,MAAMS,WAAWC,MAAMC,IAAIV,YAAY;AAGxDE,oBAAOL,MACL,IAAIC,iBAAiBD,OAAO;QAC1BI;MACF;IAEJ;EACF;AACF;AAEO,MAAM1E,0BAA0B,CAACoF,WACtCA,WAAW,YAAYA,WAAW;","names":["getProjectTsconfig","generatorTsConfig","getTscBinPath","resolveAlias","printOrThrowDtsErrors","tsTargetAtOrAboveES2022","tsconfigPath","fs","existsSync","json5","parse","readFileSync","config","userTsconfig","appDirectory","sourceDir","absSourceDir","dtsTempDirectory","tempDistAbsRootPath","join","nanoid","tempDistAbsOurDir","relative","tempTsconfigPath","basename","ensureFileSync","extendsPath","dirname","references","map","reference","path","userTsconfigDir","generatedTsconfigDir","isAbsolute","resolve","resetConfig","extends","compilerOptions","declaration","emitDeclarationOnly","declarationDir","writeJSONSync","generatedTsconfig","tempDistAbsSrcPath","default","findUp","exists","pathExists","tscBinFile","directory","targetFilePath","hasTscBinFile","undefined","cwd","Error","options","watchFilenames","transformDtsAlias","distAbsPath","dtsDistPath","dtsFilenames","length","globby","sync","absolute","result","filenames","baseUrl","paths","r","writeFileSync","content","ensureDir","copy","error","InternalDTSError","local","abortOnError","buildType","logger","warn","chalk","bgYellowBright","i18n","t","localeKeys","warns","dts","target"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/dts.ts"],"sourcesContent":["import { join, dirname, isAbsolute, relative, resolve, basename } from 'path';\nimport { chalk, fs, globby, json5, logger, nanoid } from '@modern-js/utils';\nimport type {\n ITsconfig,\n BundlelessGeneratorDtsConfig,\n BuildType,\n TsTarget,\n} from '../types';\n\nexport const getProjectTsconfig = async (\n tsconfigPath: string,\n): Promise<ITsconfig> => {\n if (!fs.existsSync(tsconfigPath)) {\n return {};\n }\n\n return json5.parse(fs.readFileSync(tsconfigPath, 'utf-8'));\n};\n\nexport const generatorTsConfig = async (\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;\n\n const userTsconfig = await getProjectTsconfig(tsconfigPath);\n const { dtsTempDirectory } = await import('../constants/dts');\n\n const tempDistAbsRootPath = join(\n appDirectory,\n `${dtsTempDirectory}/${nanoid()}`,\n );\n const tempDistAbsOurDir = join(\n tempDistAbsRootPath,\n relative(appDirectory, absSourceDir),\n );\n\n const tempTsconfigPath = join(tempDistAbsRootPath, basename(tsconfigPath));\n fs.ensureFileSync(tempTsconfigPath);\n\n const extendsPath = join(\n relative(dirname(tempTsconfigPath), dirname(tsconfigPath)),\n basename(tempTsconfigPath),\n );\n const references = userTsconfig?.references?.map(reference => {\n const { path } = reference;\n if (path) {\n const userTsconfigDir = dirname(tsconfigPath);\n const generatedTsconfigDir = dirname(tempTsconfigPath);\n return {\n path: isAbsolute(path)\n ? path\n : relative(generatedTsconfigDir, resolve(userTsconfigDir, path)),\n };\n }\n return reference;\n });\n\n const resetConfig: ITsconfig = {\n extends: extendsPath,\n compilerOptions: {\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n // when `outDir` is './dist', `declarationDir` is `./types`\n // tsc will emit:\n // - ./dist/index.js\n // - ./types/index.d.ts\n // we only want to emit declarations\n declarationDir: tempDistAbsOurDir,\n },\n references,\n };\n\n fs.writeJSONSync(tempTsconfigPath, resetConfig);\n\n return {\n userTsconfig,\n generatedTsconfig: {\n tempTsconfigPath,\n tempDistAbsRootPath,\n tempDistAbsSrcPath: tempDistAbsOurDir,\n },\n };\n};\n\nexport const getTscBinPath = async (appDirectory: string) => {\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 = 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 { 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 // why use `ensureDir` before copy? look this: https://github.com/jprichardson/node-fs-extra/issues/957\n await fs.ensureDir(distAbsPath);\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 printOrThrowDtsErrors = async (\n error: unknown,\n options: { abortOnError?: boolean; buildType: BuildType },\n) => {\n const { InternalDTSError } = await import('../error');\n const local = await import('../locale');\n const { abortOnError, buildType } = options ?? {};\n if (error instanceof Error) {\n if (abortOnError) {\n throw new InternalDTSError(error, {\n buildType,\n });\n } else {\n logger.warn(\n chalk.bgYellowBright(\n local.i18n.t(local.localeKeys.warns.dts.abortOnError),\n ),\n );\n logger.error(\n new InternalDTSError(error, {\n buildType,\n }),\n );\n }\n }\n};\n\nexport const tsTargetAtOrAboveES2022 = (target: TsTarget) =>\n target === 'es2022' || target === 'esnext';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;+BAmHaA;;;WAAAA;;;;;kEAnHS;+BACU;uBACb;oEACK;sEACF;mEACH;qEACgB;sBACN;AAU7B,SAASC,cACPC,UACA,EAAEC,UAAUC,SAASC,MAAK,GAAmB;AAE7C,MAAI,CAACC,OAAEC,gBAAgBL,WAAW;AAChC;EACF;AAEA,QAAMM,aAAaN,SAASO,KAAKC;AACjC,QAAMC,cAAcR;AACpB,QAAMS,aAAYC,mCAChBT,SACAC,OACA;IAAC;GAAQ;AAEX,QAAMS,SAASF,UACbJ,YACAO;AACE,QAAI,CAACC,UAAGC,WAAWF,kBAAkB;AACnC,aAAOG;IACT;AACA,WAAOF,UAAGG,aAAaJ;EACzB,GACAK,cAAYJ,UAAGC,WAAWG,WAC1BC,kBAAY;AAEd,MAAIP,QAAQ;AACV,UAAMQ,eAAeC,MAAKC,SACxBD,MAAKE,QAAQd,cACbY,MAAKE,QAAQX;AAEf,UAAMY,WAAWH,MAAKI,SAASb;AAE/B,UAAMM,WAAWG,MAAKK,UACpB,GAAGN,aAAaO,WAAW,IAAI,MAAMP,gBAAgBI,UAAU;AAEjE,UAAMI,gBAAgBV,SAASW,WAAW,OAAOX,WAAW,KAAKA;AACjElB,aAAS8B,YAAY1B,OAAE2B,cAAcH;EACvC;AACF;AAgBA,MAAMI,kBACJ,CAACC,WAA4B,CAACjC;AAC5BD,gBAAcC,SAASkC,IAAI,WAAWD;AACxC;AAEF,MAAME,kBACJ,CAACF,WAA4B,CAACjC;AAC5BD,gBAAcC,SAASkC,IAAI,WAAwCD;AACrE;AAEF,MAAMG,2BAA2B,CAAC,EAChCnC,UACAC,SACAC,MAAK,MACW;AAChB,QAAMkC,aAAavB,UAAGwB,aAAarC,UAAU;AAC7C,QAAMsC,MAAMC,QAAOC,MAAMJ,YAAY;IACnCK,YAAY;IACZC,eAAe;IACfC,SAAS;MAAC;;EACZ;AACAC,yBAASN,KAAK;;;IAGZO,mBAAmBd,gBAAgB;MACjC/B;MACAC;MACAC;IACF;IACA4C,mBAAmBZ,gBAAgB;MACjClC;MACAC;MACAC;IACF;EACF;AACA,UAAO6C,uBAAUT,KAAKU;AACxB;AAOO,MAAMnD,oBAAoB,CAACmC;AAChC,QAAM,EAAEiB,YAAY,IAAIhD,SAASC,MAAK,IAAK8B;AAC3C,QAAMkB,kBAAuD;AAC7D,aAAWlD,YAAYiD,WAAW;AAChCC,oBAAgBC,KAAK;MACnB/B,MAAMpB;MACNoD,SAASjB,yBAAyB;QAAEnC;QAAUC;QAASC;MAAM;IAC/D;EACF;AACA,SAAOgD;AACT;","names":["transformDtsAlias","mapPathString","nodePath","filename","baseUrl","paths","t","isStringLiteral","sourcePath","node","value","currentFile","matchPath","createMatchPath","result","packageJsonPath","fs","existsSync","undefined","readJSONSync","filePath","dtsAliasExts","relativePath","path","relative","dirname","fileName","basename","normalize","length","replaceString","startsWith","replaceWith","stringLiteral","transformImport","option","get","transformExport","transformSingleFileAlias","sourceCode","readFileSync","ast","parser","parse","sourceType","errorRecovery","plugins","traverse","ImportDeclaration","ExportDeclaration","generator","code","filenames","transformResult","push","content"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/tspathsTransform.ts"],"sourcesContent":["import * as path from 'path';\nimport { createMatchPath } from '@modern-js/utils/tsconfig-paths';\nimport { fs } from '@modern-js/utils';\nimport * as parser from '@babel/parser';\nimport generator from '@babel/generator';\nimport * as t from '@babel/types';\nimport traverse, { NodePath } from '@babel/traverse';\nimport { dtsAliasExts } from '../constants/file';\n// import { defaultTransformedFunctions } from '../constants/dts';\n// import { matchesPattern, isImportCall } from './dts';\n\nexport interface TransformOption {\n filename: string;\n baseUrl: string;\n paths: Record<string, string[] | string>;\n}\n\nfunction mapPathString(\n nodePath: NodePath<
|
|
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ACAC;MACAC;IACF;IACA4C,mBAAmBZ,gBAAgB;MACjClC;MACAC;MACAC;IACF;EACF;AACA,UAAO6C,uBAAUT,KAAKU;AACxB;AAOO,MAAMnD,oBAAoB,CAACmC;AAChC,QAAM,EAAEiB,YAAY,IAAIhD,SAASC,MAAK,IAAK8B;AAC3C,QAAMkB,kBAAuD;AAC7D,aAAWlD,YAAYiD,WAAW;AAChCC,oBAAgBC,KAAK;MACnB/B,MAAMpB;MACNoD,SAASjB,yBAAyB;QAAEnC;QAAUC;QAASC;MAAM;IAC/D;EACF;AACA,SAAOgD;AACT;","names":["transformDtsAlias","mapPathString","nodePath","filename","baseUrl","paths","t","isStringLiteral","sourcePath","node","value","currentFile","matchPath","createMatchPath","result","packageJsonPath","fs","existsSync","undefined","readJSONSync","filePath","dtsAliasExts","relativePath","path","relative","dirname","fileName","basename","normalize","length","replaceString","startsWith","replaceWith","stringLiteral","transformImport","option","get","transformExport","transformSingleFileAlias","sourceCode","readFileSync","ast","parser","parse","sourceType","errorRecovery","plugins","traverse","ImportDeclaration","ExportDeclaration","generator","code","filenames","transformResult","push","content"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/tspathsTransform.ts"],"sourcesContent":["import * as path from 'path';\nimport { createMatchPath } from '@modern-js/utils/tsconfig-paths';\nimport { fs } from '@modern-js/utils';\nimport * as parser from '@babel/parser';\nimport generator from '@babel/generator';\nimport * as t from '@babel/types';\nimport traverse, { NodePath } from '@babel/traverse';\nimport { dtsAliasExts } from '../constants/file';\n// import { defaultTransformedFunctions } from '../constants/dts';\n// import { matchesPattern, isImportCall } from './dts';\n\nexport interface TransformOption {\n filename: string;\n baseUrl: string;\n paths: Record<string, string[] | string>;\n}\n\nfunction mapPathString(\n nodePath: NodePath<any>,\n { filename, baseUrl, paths }: TransformOption,\n) {\n if (!t.isStringLiteral(nodePath)) {\n return;\n }\n\n const sourcePath = nodePath.node.value;\n const currentFile = filename;\n const matchPath = createMatchPath(\n baseUrl,\n paths as { [key: string]: Array<string> },\n ['index'],\n );\n const result = matchPath(\n sourcePath,\n packageJsonPath => {\n if (!fs.existsSync(packageJsonPath)) {\n return undefined;\n }\n return fs.readJSONSync(packageJsonPath);\n },\n filePath => fs.existsSync(filePath),\n dtsAliasExts,\n );\n if (result) {\n const relativePath = path.relative(\n path.dirname(currentFile),\n path.dirname(result),\n );\n const fileName = path.basename(result);\n // 如果是同级文件,则返回的是 ''\n const filePath = path.normalize(\n `${relativePath.length === 0 ? '.' : relativePath}/${fileName}`,\n );\n const replaceString = filePath.startsWith('.') ? filePath : `./${filePath}`;\n nodePath.replaceWith(t.stringLiteral(replaceString));\n }\n}\n\n// const transformCall =\n// (option: TransformOption) => (nodePath: NodePath<t.CallExpression>) => {\n// const calleePath = nodePath.get('callee') as NodePath;\n// const isNormalCall = defaultTransformedFunctions.some(pattern =>\n// matchesPattern(calleePath, pattern),\n// );\n// if (isNormalCall || isImportCall(nodePath)) {\n// mapPathString(\n// nodePath.get('arguments.0') as NodePath<t.StringLiteral>,\n// option,\n// );\n// }\n// };\n\nconst transformImport =\n (option: TransformOption) => (nodePath: NodePath<t.ImportDeclaration>) => {\n mapPathString(nodePath.get('source'), option);\n };\n\nconst transformExport =\n (option: TransformOption) => (nodePath: NodePath<t.ExportDeclaration>) => {\n mapPathString(nodePath.get('source') as NodePath<t.StringLiteral>, option);\n };\n\nconst transformSingleFileAlias = ({\n filename,\n baseUrl,\n paths,\n}: TransformOption) => {\n const sourceCode = fs.readFileSync(filename, 'utf-8');\n const ast = parser.parse(sourceCode, {\n sourceType: 'module',\n errorRecovery: true, // 防止typescript不支持的语法出现而报错\n plugins: ['typescript'],\n });\n traverse(ast, {\n // d.ts file content not have callExpression which can be parsed;\n // CallExpression: transformCall({ filename, baseUrl, paths }) as any,\n ImportDeclaration: transformImport({\n filename,\n baseUrl,\n paths,\n }) as any,\n ExportDeclaration: transformExport({\n filename,\n baseUrl,\n paths,\n }) as any,\n });\n return generator(ast).code;\n};\n\ninterface TransformDtsAliasOption {\n filenames?: string[];\n baseUrl: string;\n paths: Record<string, string[] | string>;\n}\nexport const transformDtsAlias = (option: TransformDtsAliasOption) => {\n const { filenames = [], baseUrl, paths } = option;\n const transformResult: { path: string; content: string }[] = [];\n for (const filename of filenames) {\n transformResult.push({\n path: filename,\n content: transformSingleFileAlias({ filename, baseUrl, paths }),\n });\n }\n return transformResult;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"module-tools",
|
|
16
16
|
"lib-tools"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.35.0",
|
|
19
19
|
"bin": {
|
|
20
20
|
"modern": "./bin/modern.js",
|
|
21
21
|
"modern-module": "./bin/modern.js"
|
|
@@ -49,24 +49,24 @@
|
|
|
49
49
|
"node": ">=14.0.0"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@babel/parser": "^7.
|
|
53
|
-
"@babel/generator": "^7.
|
|
54
|
-
"@babel/types": "^7.
|
|
55
|
-
"@babel/traverse": "^7.
|
|
52
|
+
"@babel/parser": "^7.22.15",
|
|
53
|
+
"@babel/generator": "^7.22.15",
|
|
54
|
+
"@babel/types": "^7.22.15",
|
|
55
|
+
"@babel/traverse": "^7.22.15",
|
|
56
56
|
"postcss": "8.4.27",
|
|
57
57
|
"@swc/helpers": "0.5.1",
|
|
58
|
-
"@modern-js/core": "2.
|
|
59
|
-
"@modern-js/libuild": "2.
|
|
60
|
-
"@modern-js/libuild-plugin-svgr": "2.
|
|
61
|
-
"@modern-js/libuild-plugin-swc": "2.
|
|
62
|
-
"@modern-js/new-action": "2.
|
|
63
|
-
"@modern-js/plugin": "2.
|
|
64
|
-
"@modern-js/plugin-changeset": "2.
|
|
65
|
-
"@modern-js/plugin-i18n": "2.
|
|
66
|
-
"@modern-js/plugin-lint": "2.
|
|
67
|
-
"@modern-js/types": "2.
|
|
68
|
-
"@modern-js/upgrade": "2.
|
|
69
|
-
"@modern-js/utils": "2.
|
|
58
|
+
"@modern-js/core": "2.35.0",
|
|
59
|
+
"@modern-js/libuild": "2.35.0",
|
|
60
|
+
"@modern-js/libuild-plugin-svgr": "2.35.0",
|
|
61
|
+
"@modern-js/libuild-plugin-swc": "2.35.0",
|
|
62
|
+
"@modern-js/new-action": "2.35.0",
|
|
63
|
+
"@modern-js/plugin": "2.35.0",
|
|
64
|
+
"@modern-js/plugin-changeset": "2.35.0",
|
|
65
|
+
"@modern-js/plugin-i18n": "2.35.0",
|
|
66
|
+
"@modern-js/plugin-lint": "2.35.0",
|
|
67
|
+
"@modern-js/types": "2.35.0",
|
|
68
|
+
"@modern-js/upgrade": "2.35.0",
|
|
69
|
+
"@modern-js/utils": "2.35.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@types/babel__generator": "7.6.4",
|
|
@@ -79,12 +79,12 @@
|
|
|
79
79
|
"jest": "^29",
|
|
80
80
|
"path-browserify": "1.0.1",
|
|
81
81
|
"postcss-alias": "2.0.0",
|
|
82
|
-
"react": "
|
|
82
|
+
"react": "^18",
|
|
83
83
|
"typescript": "^5",
|
|
84
|
-
"@modern-js/builder-webpack-provider": "2.
|
|
85
|
-
"@modern-js/self": "npm:@modern-js/module-tools@2.
|
|
86
|
-
"@scripts/build": "2.
|
|
87
|
-
"@scripts/jest-config": "2.
|
|
84
|
+
"@modern-js/builder-webpack-provider": "2.35.0",
|
|
85
|
+
"@modern-js/self": "npm:@modern-js/module-tools@2.35.0",
|
|
86
|
+
"@scripts/build": "2.35.0",
|
|
87
|
+
"@scripts/jest-config": "2.35.0"
|
|
88
88
|
},
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"registry": "https://registry.npmjs.org/",
|