@modern-js/module-tools 1.0.0-alpha.3
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/CHANGELOG.md +21 -0
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/bin/modern.js +3 -0
- package/dist/js/modern/cli/build.js +9 -0
- package/dist/js/modern/cli/dev.js +8 -0
- package/dist/js/modern/cli/index.js +3 -0
- package/dist/js/modern/cli/new.js +16 -0
- package/dist/js/modern/commands/build.js +56 -0
- package/dist/js/modern/commands/dev.js +29 -0
- package/dist/js/modern/commands/index.js +2 -0
- package/dist/js/modern/features/build/build-platform.js +70 -0
- package/dist/js/modern/features/build/build-watch.js +96 -0
- package/dist/js/modern/features/build/build.js +110 -0
- package/dist/js/modern/features/build/constants.js +66 -0
- package/dist/js/modern/features/build/index.js +29 -0
- package/dist/js/modern/features/build/logger/index.js +2 -0
- package/dist/js/modern/features/build/logger/logText.js +63 -0
- package/dist/js/modern/features/build/logger/loggerManager.js +101 -0
- package/dist/js/modern/features/build/utils.js +198 -0
- package/dist/js/modern/features/dev/index.js +41 -0
- package/dist/js/modern/index.js +46 -0
- package/dist/js/modern/locale/en.js +23 -0
- package/dist/js/modern/locale/index.js +10 -0
- package/dist/js/modern/locale/zh.js +23 -0
- package/dist/js/modern/schema/index.js +3 -0
- package/dist/js/modern/schema/output.js +29 -0
- package/dist/js/modern/schema/source.js +15 -0
- package/dist/js/modern/tasks/build-source-code.js +213 -0
- package/dist/js/modern/tasks/build-style.js +152 -0
- package/dist/js/modern/tasks/build-watch-source-code.js +144 -0
- package/dist/js/modern/tasks/build-watch-style.js +213 -0
- package/dist/js/modern/tasks/constants.js +1 -0
- package/dist/js/modern/tasks/copy-assets.js +108 -0
- package/dist/js/modern/tasks/generator-dts.js +220 -0
- package/dist/js/modern/types.js +0 -0
- package/dist/js/modern/utils/babel.js +85 -0
- package/dist/js/modern/utils/color.js +2 -0
- package/dist/js/modern/utils/copy.js +80 -0
- package/dist/js/modern/utils/json.js +13 -0
- package/dist/js/modern/utils/language.js +6 -0
- package/dist/js/modern/utils/logger.js +110 -0
- package/dist/js/modern/utils/readline.js +19 -0
- package/dist/js/modern/utils/tsconfig.js +15 -0
- package/dist/js/modern/utils/tspaths-transform/constants.js +3 -0
- package/dist/js/modern/utils/tspaths-transform/index.js +130 -0
- package/dist/js/modern/utils/tspaths-transform/utils.js +21 -0
- package/dist/js/modern/utils/valide.js +28 -0
- package/dist/js/node/cli/build.js +21 -0
- package/dist/js/node/cli/dev.js +20 -0
- package/dist/js/node/cli/index.js +44 -0
- package/dist/js/node/cli/new.js +28 -0
- package/dist/js/node/commands/build.js +76 -0
- package/dist/js/node/commands/dev.js +49 -0
- package/dist/js/node/commands/index.js +21 -0
- package/dist/js/node/features/build/build-platform.js +84 -0
- package/dist/js/node/features/build/build-watch.js +118 -0
- package/dist/js/node/features/build/build.js +133 -0
- package/dist/js/node/features/build/constants.js +79 -0
- package/dist/js/node/features/build/index.js +41 -0
- package/dist/js/node/features/build/logger/index.js +31 -0
- package/dist/js/node/features/build/logger/logText.js +79 -0
- package/dist/js/node/features/build/logger/loggerManager.js +111 -0
- package/dist/js/node/features/build/utils.js +231 -0
- package/dist/js/node/features/dev/index.js +60 -0
- package/dist/js/node/index.js +64 -0
- package/dist/js/node/locale/en.js +30 -0
- package/dist/js/node/locale/index.js +22 -0
- package/dist/js/node/locale/zh.js +30 -0
- package/dist/js/node/schema/index.js +14 -0
- package/dist/js/node/schema/output.js +36 -0
- package/dist/js/node/schema/source.js +22 -0
- package/dist/js/node/tasks/build-source-code.js +240 -0
- package/dist/js/node/tasks/build-style.js +168 -0
- package/dist/js/node/tasks/build-watch-source-code.js +156 -0
- package/dist/js/node/tasks/build-watch-style.js +231 -0
- package/dist/js/node/tasks/constants.js +8 -0
- package/dist/js/node/tasks/copy-assets.js +126 -0
- package/dist/js/node/tasks/generator-dts.js +243 -0
- package/dist/js/node/types.js +0 -0
- package/dist/js/node/utils/babel.js +99 -0
- package/dist/js/node/utils/color.js +12 -0
- package/dist/js/node/utils/copy.js +99 -0
- package/dist/js/node/utils/json.js +22 -0
- package/dist/js/node/utils/language.js +15 -0
- package/dist/js/node/utils/logger.js +133 -0
- package/dist/js/node/utils/readline.js +33 -0
- package/dist/js/node/utils/tsconfig.js +30 -0
- package/dist/js/node/utils/tspaths-transform/constants.js +10 -0
- package/dist/js/node/utils/tspaths-transform/index.js +155 -0
- package/dist/js/node/utils/tspaths-transform/utils.js +32 -0
- package/dist/js/node/utils/valide.js +41 -0
- package/dist/types/cli/build.d.ts +2 -0
- package/dist/types/cli/dev.d.ts +2 -0
- package/dist/types/cli/index.d.ts +3 -0
- package/dist/types/cli/new.d.ts +2 -0
- package/dist/types/commands/build.d.ts +16 -0
- package/dist/types/commands/dev.d.ts +4 -0
- package/dist/types/commands/index.d.ts +2 -0
- package/dist/types/features/build/build-platform.d.ts +6 -0
- package/dist/types/features/build/build-watch.d.ts +3 -0
- package/dist/types/features/build/build.d.ts +3 -0
- package/dist/types/features/build/constants.d.ts +14 -0
- package/dist/types/features/build/index.d.ts +3 -0
- package/dist/types/features/build/logger/index.d.ts +2 -0
- package/dist/types/features/build/logger/logText.d.ts +39 -0
- package/dist/types/features/build/logger/loggerManager.d.ts +39 -0
- package/dist/types/features/build/utils.d.ts +58 -0
- package/dist/types/features/dev/index.d.ts +7 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/locale/en.d.ts +23 -0
- package/dist/types/locale/index.d.ts +47 -0
- package/dist/types/locale/zh.d.ts +23 -0
- package/dist/types/schema/index.d.ts +36 -0
- package/dist/types/schema/output.d.ts +22 -0
- package/dist/types/schema/source.d.ts +15 -0
- package/dist/types/tasks/build-source-code.d.ts +42 -0
- package/dist/types/tasks/build-style.d.ts +1 -0
- package/dist/types/tasks/build-watch-source-code.d.ts +1 -0
- package/dist/types/tasks/build-watch-style.d.ts +1 -0
- package/dist/types/tasks/constants.d.ts +1 -0
- package/dist/types/tasks/copy-assets.d.ts +1 -0
- package/dist/types/tasks/generator-dts.d.ts +1 -0
- package/dist/types/types.d.ts +48 -0
- package/dist/types/utils/babel.d.ts +8 -0
- package/dist/types/utils/color.d.ts +2 -0
- package/dist/types/utils/copy.d.ts +5 -0
- package/dist/types/utils/json.d.ts +4 -0
- package/dist/types/utils/language.d.ts +1 -0
- package/dist/types/utils/logger.d.ts +56 -0
- package/dist/types/utils/readline.d.ts +9 -0
- package/dist/types/utils/tsconfig.d.ts +16 -0
- package/dist/types/utils/tspaths-transform/constants.d.ts +1 -0
- package/dist/types/utils/tspaths-transform/index.d.ts +15 -0
- package/dist/types/utils/tspaths-transform/utils.d.ts +4 -0
- package/dist/types/utils/valide.d.ts +12 -0
- package/modern.config.js +6 -0
- package/package.json +95 -0
- package/src/.eslintrc.json +5 -0
- package/src/cli/build.ts +39 -0
- package/src/cli/dev.ts +24 -0
- package/src/cli/index.ts +3 -0
- package/src/cli/new.ts +32 -0
- package/src/commands/build.ts +81 -0
- package/src/commands/dev.ts +41 -0
- package/src/commands/index.ts +2 -0
- package/src/features/build/build-platform.ts +76 -0
- package/src/features/build/build-watch.ts +93 -0
- package/src/features/build/build.ts +111 -0
- package/src/features/build/constants.ts +52 -0
- package/src/features/build/index.ts +36 -0
- package/src/features/build/logger/index.ts +2 -0
- package/src/features/build/logger/logText.ts +80 -0
- package/src/features/build/logger/loggerManager.ts +132 -0
- package/src/features/build/utils.ts +250 -0
- package/src/features/dev/index.ts +62 -0
- package/src/index.ts +55 -0
- package/src/locale/en.ts +21 -0
- package/src/locale/index.ts +15 -0
- package/src/locale/zh.ts +21 -0
- package/src/schema/index.ts +4 -0
- package/src/schema/output.ts +34 -0
- package/src/schema/schema.d.ts +13 -0
- package/src/schema/source.ts +16 -0
- package/src/tasks/build-source-code.ts +245 -0
- package/src/tasks/build-style.ts +175 -0
- package/src/tasks/build-watch-source-code.ts +185 -0
- package/src/tasks/build-watch-style.ts +260 -0
- package/src/tasks/constants.ts +1 -0
- package/src/tasks/copy-assets.ts +117 -0
- package/src/tasks/generator-dts.ts +277 -0
- package/src/type.d.ts +1 -0
- package/src/types.ts +63 -0
- package/src/utils/babel.ts +100 -0
- package/src/utils/color.ts +3 -0
- package/src/utils/copy.ts +70 -0
- package/src/utils/json.ts +13 -0
- package/src/utils/language.ts +9 -0
- package/src/utils/logger.ts +144 -0
- package/src/utils/readline.ts +28 -0
- package/src/utils/tsconfig.ts +37 -0
- package/src/utils/tspaths-transform/constants.ts +19 -0
- package/src/utils/tspaths-transform/index.ts +139 -0
- package/src/utils/tspaths-transform/utils.ts +25 -0
- package/src/utils/valide.ts +37 -0
- package/tsconfig.json +13 -0
- package/types.d.ts +1 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as readline from 'readline';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
4
|
+
export class ReadlineUtils {
|
|
5
|
+
static clearPrevLine(
|
|
6
|
+
output: NodeJS.WriteStream & {
|
|
7
|
+
fd: 1;
|
|
8
|
+
},
|
|
9
|
+
) {
|
|
10
|
+
ReadlineUtils.clearLine(output, 1);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static clearLine(
|
|
14
|
+
output: NodeJS.WriteStream & {
|
|
15
|
+
fd: 1;
|
|
16
|
+
},
|
|
17
|
+
n = 1,
|
|
18
|
+
dir: 1 | -1 = -1,
|
|
19
|
+
) {
|
|
20
|
+
// -1 向上,1 向下
|
|
21
|
+
const dx = dir === 1 ? 1 : -1;
|
|
22
|
+
for (let i = 0; i < n; i++) {
|
|
23
|
+
readline.moveCursor(output, 0, dx);
|
|
24
|
+
readline.clearLine(output, 0);
|
|
25
|
+
readline.cursorTo(output, 0);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { fs, Import } from '@modern-js/utils';
|
|
2
|
+
|
|
3
|
+
const json5: typeof import('json5') = Import.lazy('json5', require);
|
|
4
|
+
|
|
5
|
+
export interface ITsconfig {
|
|
6
|
+
compilerOptions?:
|
|
7
|
+
| {
|
|
8
|
+
rootDir?: string;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
declaration?: boolean;
|
|
11
|
+
emitDeclarationOnly?: boolean;
|
|
12
|
+
isolatedModules?: boolean;
|
|
13
|
+
allowJs?: boolean;
|
|
14
|
+
outDir?: string;
|
|
15
|
+
paths?: Record<string, string[]>;
|
|
16
|
+
}
|
|
17
|
+
| undefined;
|
|
18
|
+
include?: string[];
|
|
19
|
+
exclude?: string[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const readTsConfig = <T extends null | ITsconfig>(
|
|
23
|
+
tsconfigPath: string,
|
|
24
|
+
noExistReturn: T = null as T,
|
|
25
|
+
): ITsconfig | T => {
|
|
26
|
+
// 如果不存在,则返回 noExistReturn
|
|
27
|
+
if (!fs.existsSync(tsconfigPath)) {
|
|
28
|
+
return noExistReturn;
|
|
29
|
+
}
|
|
30
|
+
const content = fs.readFileSync(tsconfigPath, 'utf-8');
|
|
31
|
+
return json5.parse(content);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const existTsConfigFile = (tsconfigAbsolutePath: string) => {
|
|
35
|
+
const tsconfig = readTsConfig(tsconfigAbsolutePath);
|
|
36
|
+
return Boolean(tsconfig);
|
|
37
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const defaultTransformedFunctions = [
|
|
2
|
+
'require',
|
|
3
|
+
'require.resolve',
|
|
4
|
+
'System.import',
|
|
5
|
+
|
|
6
|
+
// Jest methods
|
|
7
|
+
'jest.genMockFromModule',
|
|
8
|
+
'jest.mock',
|
|
9
|
+
'jest.unmock',
|
|
10
|
+
'jest.doMock',
|
|
11
|
+
'jest.dontMock',
|
|
12
|
+
'jest.setMock',
|
|
13
|
+
'jest.requireActual',
|
|
14
|
+
'jest.requireMock',
|
|
15
|
+
|
|
16
|
+
// Older Jest methods
|
|
17
|
+
'require.requireActual',
|
|
18
|
+
'require.requireMock',
|
|
19
|
+
];
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as parser from '@babel/parser';
|
|
3
|
+
import traverse, { NodePath } from '@babel/traverse';
|
|
4
|
+
import generator from '@babel/generator';
|
|
5
|
+
import * as t from '@babel/types';
|
|
6
|
+
import { createMatchPath } from 'tsconfig-paths';
|
|
7
|
+
import { fs } from '@modern-js/utils';
|
|
8
|
+
import { defaultTransformedFunctions } from './constants';
|
|
9
|
+
import { matchesPattern, isImportCall } from './utils';
|
|
10
|
+
|
|
11
|
+
export interface TransformOption {
|
|
12
|
+
filename: string;
|
|
13
|
+
baseUrl: string;
|
|
14
|
+
paths: Record<string, string[] | string>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const getPathsMap = (
|
|
18
|
+
paths: Record<string, string | string[]>,
|
|
19
|
+
sourceDirName = 'src',
|
|
20
|
+
) => {
|
|
21
|
+
const pathKeys = Object.keys(paths);
|
|
22
|
+
const pathsMap: Record<string, string[]> = {};
|
|
23
|
+
const replaceSrcToTypes = (s: string) => s.replace(sourceDirName, 'types');
|
|
24
|
+
for (const key of pathKeys) {
|
|
25
|
+
const p = paths[key];
|
|
26
|
+
if (typeof p === 'string') {
|
|
27
|
+
pathsMap[key] = [replaceSrcToTypes(p)];
|
|
28
|
+
} else {
|
|
29
|
+
pathsMap[key] = (paths[key] as string[]).map(sp => replaceSrcToTypes(sp));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return pathsMap;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function mapPathString(
|
|
36
|
+
nodePath: NodePath<t.StringLiteral>,
|
|
37
|
+
{ filename, baseUrl, paths }: TransformOption,
|
|
38
|
+
) {
|
|
39
|
+
if (!t.isStringLiteral(nodePath)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const sourcePath = nodePath.node.value;
|
|
44
|
+
const currentFile = filename;
|
|
45
|
+
const pathsMap = getPathsMap(paths);
|
|
46
|
+
const matchPath = createMatchPath(baseUrl, pathsMap, ['index']);
|
|
47
|
+
const result = matchPath(
|
|
48
|
+
sourcePath,
|
|
49
|
+
packageJsonPath => {
|
|
50
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
return fs.readJSONSync(packageJsonPath);
|
|
54
|
+
},
|
|
55
|
+
filePath => fs.existsSync(filePath),
|
|
56
|
+
['.d.ts'],
|
|
57
|
+
);
|
|
58
|
+
if (result) {
|
|
59
|
+
const relativePath = path.relative(
|
|
60
|
+
path.dirname(currentFile),
|
|
61
|
+
path.dirname(result),
|
|
62
|
+
);
|
|
63
|
+
const fileName = path.basename(result);
|
|
64
|
+
// 如果是同级文件,则返回的是 ''
|
|
65
|
+
const filePath = path.normalize(
|
|
66
|
+
`${relativePath.length === 0 ? '.' : relativePath}/${fileName}`,
|
|
67
|
+
);
|
|
68
|
+
const replaceString = filePath.startsWith('.') ? filePath : `./${filePath}`;
|
|
69
|
+
nodePath.replaceWith(t.stringLiteral(replaceString));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const transformCall =
|
|
74
|
+
(option: TransformOption) => (nodePath: NodePath<t.CallExpression>) => {
|
|
75
|
+
const calleePath = nodePath.get('callee') as NodePath;
|
|
76
|
+
const isNormalCall = defaultTransformedFunctions.some(pattern =>
|
|
77
|
+
matchesPattern(calleePath, pattern),
|
|
78
|
+
);
|
|
79
|
+
if (isNormalCall || isImportCall(nodePath)) {
|
|
80
|
+
mapPathString(
|
|
81
|
+
nodePath.get('arguments.0') as NodePath<t.StringLiteral>,
|
|
82
|
+
option,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const transformImport =
|
|
88
|
+
(option: TransformOption) => (nodePath: NodePath<t.ImportDeclaration>) => {
|
|
89
|
+
mapPathString(nodePath.get('source'), option);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const transformExport =
|
|
93
|
+
(option: TransformOption) => (nodePath: NodePath<t.ExportDeclaration>) => {
|
|
94
|
+
mapPathString(nodePath.get('source') as NodePath<t.StringLiteral>, option);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const transfromSingleFileAlias = ({
|
|
98
|
+
filename,
|
|
99
|
+
baseUrl,
|
|
100
|
+
paths,
|
|
101
|
+
}: TransformOption) => {
|
|
102
|
+
const sourceCode = fs.readFileSync(filename, 'utf-8');
|
|
103
|
+
const ast = parser.parse(sourceCode, {
|
|
104
|
+
sourceType: 'module',
|
|
105
|
+
errorRecovery: true, // 防止typescript不支持的语法出现而报错
|
|
106
|
+
plugins: ['typescript'],
|
|
107
|
+
});
|
|
108
|
+
traverse(ast as any, {
|
|
109
|
+
CallExpression: transformCall({ filename, baseUrl, paths }) as any,
|
|
110
|
+
ImportDeclaration: transformImport({
|
|
111
|
+
filename,
|
|
112
|
+
baseUrl,
|
|
113
|
+
paths,
|
|
114
|
+
}) as any,
|
|
115
|
+
ExportDeclaration: transformExport({
|
|
116
|
+
filename,
|
|
117
|
+
baseUrl,
|
|
118
|
+
paths,
|
|
119
|
+
}) as any,
|
|
120
|
+
});
|
|
121
|
+
return generator(ast as any).code;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
interface TransformDtsAlaisOption {
|
|
125
|
+
filenames?: string[];
|
|
126
|
+
baseUrl: string;
|
|
127
|
+
paths: Record<string, string[] | string>;
|
|
128
|
+
}
|
|
129
|
+
export const transformDtsAlias = (option: TransformDtsAlaisOption) => {
|
|
130
|
+
const { filenames = [], baseUrl, paths } = option;
|
|
131
|
+
const transformResult: { path: string; content: string }[] = [];
|
|
132
|
+
for (const filename of filenames) {
|
|
133
|
+
transformResult.push({
|
|
134
|
+
path: filename,
|
|
135
|
+
content: transfromSingleFileAlias({ filename, baseUrl, paths }),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return transformResult;
|
|
139
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Import } from '@modern-js/utils';
|
|
2
|
+
import type * as tt from '@babel/types';
|
|
3
|
+
import type { NodePath } from '@babel/traverse';
|
|
4
|
+
|
|
5
|
+
const t: typeof import('@babel/types') = Import.lazy('@babel/types', require);
|
|
6
|
+
|
|
7
|
+
export function matchesPattern(calleePath: NodePath, pattern: string) {
|
|
8
|
+
const { node } = calleePath;
|
|
9
|
+
|
|
10
|
+
if (t.isMemberExpression(node)) {
|
|
11
|
+
return calleePath.matchesPattern(pattern);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (!t.isIdentifier(node) || pattern.includes('.')) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const name = pattern.split('.')[0];
|
|
19
|
+
|
|
20
|
+
return node.name === name;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function isImportCall(calleePath: NodePath<tt.CallExpression>) {
|
|
24
|
+
return t.isImport(calleePath.node.callee);
|
|
25
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { validAlias } from '@modern-js/utils';
|
|
2
|
+
import type { NormalizedConfig } from '@modern-js/core';
|
|
3
|
+
|
|
4
|
+
export interface IValideOption {
|
|
5
|
+
modernConfig: NormalizedConfig;
|
|
6
|
+
tsconfigPath: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const valideBeforeTask = ({
|
|
10
|
+
modernConfig,
|
|
11
|
+
tsconfigPath,
|
|
12
|
+
}: IValideOption) => {
|
|
13
|
+
const modernConfigValidResult = modernConfigValid(modernConfig, {
|
|
14
|
+
tsconfigPath,
|
|
15
|
+
});
|
|
16
|
+
if (modernConfigValidResult) {
|
|
17
|
+
console.error(modernConfigValidResult);
|
|
18
|
+
// eslint-disable-next-line no-process-exit
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const modernConfigValid = (
|
|
24
|
+
modernConfig: NormalizedConfig,
|
|
25
|
+
option: { tsconfigPath: string },
|
|
26
|
+
) => {
|
|
27
|
+
const valids = [validAlias];
|
|
28
|
+
|
|
29
|
+
for (const validFn of valids) {
|
|
30
|
+
const result = validFn(modernConfig, option);
|
|
31
|
+
if (result) {
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return null;
|
|
37
|
+
};
|
package/tsconfig.json
ADDED
package/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module '@modern-js/runtime/*' {}
|