@modern-js/module-tools 1.3.2 → 1.4.2
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 +61 -0
- package/dist/js/modern/commands/build.js +1 -1
- package/dist/js/modern/features/dev/index.js +1 -1
- package/dist/js/modern/schema/output.js +0 -5
- package/dist/js/modern/tasks/build-source-code.js +2 -1
- package/dist/js/modern/tasks/build-watch-source-code.js +2 -1
- package/dist/js/modern/tasks/generator-dts/index.js +144 -0
- package/dist/js/modern/tasks/generator-dts/utils.js +82 -0
- package/dist/js/modern/utils/babel.js +10 -3
- package/dist/js/node/commands/build.js +1 -1
- package/dist/js/node/features/dev/index.js +1 -1
- package/dist/js/node/schema/output.js +0 -5
- package/dist/js/node/tasks/build-source-code.js +2 -1
- package/dist/js/node/tasks/build-watch-source-code.js +2 -1
- package/dist/js/node/tasks/generator-dts/index.js +158 -0
- package/dist/js/node/tasks/{generator-dts.js → generator-dts/utils.js} +11 -151
- package/dist/js/node/utils/babel.js +9 -2
- package/dist/types/tasks/{generator-dts.d.ts → generator-dts/index.d.ts} +0 -0
- package/dist/types/tasks/generator-dts/utils.d.ts +23 -0
- package/jest.config.js +2 -0
- package/lib/types.d.ts +92 -0
- package/package.json +12 -13
- package/tests/dev-feature.test.ts +17 -1
- package/tests/generator-dts-utils.test.ts +10 -0
- package/tests/generator-dts.test.ts +48 -0
- package/dist/js/modern/tasks/generator-dts.js +0 -226
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
1
|
# @modern-js/module-tools
|
|
2
2
|
|
|
3
|
+
## 1.4.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4b5d4bf4: feat: add img resource's inline and url type declaration
|
|
8
|
+
- 969f172f: support tools.styledComponents for module-tools,support close tsc process with disbaleTsChecker
|
|
9
|
+
- 55e18278: chore: remove unused dependencies and devDependencies
|
|
10
|
+
- edc3bd3d: fix: @modern-js/core package not found
|
|
11
|
+
- Updated dependencies [969f172f]
|
|
12
|
+
- Updated dependencies [4c792f68]
|
|
13
|
+
- Updated dependencies [83059b93]
|
|
14
|
+
- Updated dependencies [4b5d4bf4]
|
|
15
|
+
- Updated dependencies [62f5b8c8]
|
|
16
|
+
- Updated dependencies [55e18278]
|
|
17
|
+
- Updated dependencies [4499a674]
|
|
18
|
+
- Updated dependencies [403f5169]
|
|
19
|
+
- Updated dependencies [a7f42f48]
|
|
20
|
+
- Updated dependencies [83059b93]
|
|
21
|
+
- @modern-js/core@1.4.4
|
|
22
|
+
- @modern-js/utils@1.3.3
|
|
23
|
+
- @modern-js/new-action@1.3.3
|
|
24
|
+
- @modern-js/babel-compiler@1.2.2
|
|
25
|
+
|
|
26
|
+
## 1.4.1
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- 02ff289d: Modify the type of error text and display log messages
|
|
31
|
+
- 54786e58: add ts check
|
|
32
|
+
- 6668a1bf: feat: upgrade @modern-js/codesmith-api-app version
|
|
33
|
+
- fab92861: fix: @modern-js/core phantom dep
|
|
34
|
+
- Updated dependencies [deeaa602]
|
|
35
|
+
- Updated dependencies [54786e58]
|
|
36
|
+
- Updated dependencies [6668a1bf]
|
|
37
|
+
- Updated dependencies [6668a1bf]
|
|
38
|
+
- Updated dependencies [fab92861]
|
|
39
|
+
- @modern-js/plugin-analyze@1.3.3
|
|
40
|
+
- @modern-js/utils@1.3.2
|
|
41
|
+
- @modern-js/core@1.4.3
|
|
42
|
+
- @modern-js/new-action@1.3.2
|
|
43
|
+
- @modern-js/plugin-changeset@1.2.2
|
|
44
|
+
- @modern-js/module-tools-hooks@1.2.2
|
|
45
|
+
|
|
46
|
+
## 1.4.0
|
|
47
|
+
|
|
48
|
+
### Minor Changes
|
|
49
|
+
|
|
50
|
+
- 67503500: add alais subCmd
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- Updated dependencies [118da5b4]
|
|
55
|
+
- Updated dependencies [b376c8d6]
|
|
56
|
+
- Updated dependencies [e62c4efd]
|
|
57
|
+
- Updated dependencies [6891e4c2]
|
|
58
|
+
- Updated dependencies [e2a8233f]
|
|
59
|
+
- @modern-js/css-config@1.2.2
|
|
60
|
+
- @modern-js/style-compiler@1.2.2
|
|
61
|
+
- @modern-js/core@1.4.2
|
|
62
|
+
- @modern-js/plugin-analyze@1.3.2
|
|
63
|
+
|
|
3
64
|
## 1.3.2
|
|
4
65
|
|
|
5
66
|
### Patch Changes
|
|
@@ -19,7 +19,7 @@ export const build = async ({
|
|
|
19
19
|
const tsconfigPath = path.join(appDirectory, tsconfigName);
|
|
20
20
|
dotenv.config();
|
|
21
21
|
const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
|
|
22
|
-
const enableTscCompiler = isTsProject && tsc;
|
|
22
|
+
const enableTscCompiler = isTsProject && tsc && !modernConfig.output.disableTsChecker;
|
|
23
23
|
valid.valideBeforeTask({
|
|
24
24
|
modernConfig,
|
|
25
25
|
tsconfigPath
|
|
@@ -41,7 +41,7 @@ export const devStorybook = async config => {
|
|
|
41
41
|
};
|
|
42
42
|
export const runSubCmd = async (subCmd, config) => {
|
|
43
43
|
const metas = await core.mountHook().moduleToolsMenu(undefined);
|
|
44
|
-
const devMeta = metas.find(meta => meta.value === subCmd);
|
|
44
|
+
const devMeta = metas.find(meta => meta.value === subCmd || Array.isArray(meta.aliasValues) && meta.aliasValues.includes(subCmd));
|
|
45
45
|
|
|
46
46
|
if (devMeta) {
|
|
47
47
|
await devMeta.runTask(config);
|
|
@@ -66,7 +66,8 @@ const runBabelCompiler = async (config, modernConfig) => {
|
|
|
66
66
|
rootDir: config.srcRootDir,
|
|
67
67
|
distDir: config.distDir,
|
|
68
68
|
watchDir: config.srcRootDir,
|
|
69
|
-
extensions: getExts(isTs)
|
|
69
|
+
extensions: getExts(isTs),
|
|
70
|
+
ignore: ['*.d.ts']
|
|
70
71
|
}, _objectSpread(_objectSpread({}, babelConfig), {}, {
|
|
71
72
|
sourceMaps: config.sourceMaps
|
|
72
73
|
}));
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { Import, fs } from '@modern-js/utils';
|
|
3
|
+
const core = Import.lazy('@modern-js/core', require);
|
|
4
|
+
const execa = Import.lazy('execa', require);
|
|
5
|
+
const JSON5 = Import.lazy('json5', require);
|
|
6
|
+
const argv = Import.lazy('process.argv', require);
|
|
7
|
+
const utils = Import.lazy('./utils', require);
|
|
8
|
+
let removeTsconfigPath = '';
|
|
9
|
+
|
|
10
|
+
const getProjectTsconfig = tsconfigPath => {
|
|
11
|
+
if (!tsconfigPath || !fs.existsSync(tsconfigPath)) {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return JSON5.parse(fs.readFileSync(tsconfigPath, 'utf-8'));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const resolveLog = (childProgress, {
|
|
19
|
+
tsCheck: _tsCheck = false,
|
|
20
|
+
watch: _watch = false
|
|
21
|
+
} = {}) => {
|
|
22
|
+
var _childProgress$stdout, _childProgress$stdout2, _childProgress$stderr;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* tsc 所有的log信息都是从stdout data 事件中获取
|
|
26
|
+
* 正常模式下,如果有报错信息,交给 resolveLog 后面的逻辑来处理
|
|
27
|
+
* watch 模式下,则使用这里的信息
|
|
28
|
+
*/
|
|
29
|
+
(_childProgress$stdout = childProgress.stdout) === null || _childProgress$stdout === void 0 ? void 0 : _childProgress$stdout.on('data', data => {
|
|
30
|
+
if (!_tsCheck) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (_watch) {
|
|
35
|
+
console.info(data.toString());
|
|
36
|
+
}
|
|
37
|
+
}); // 正常以下内容都不会触发,因为tsc 不会产生以下类型的log信息,不过防止意外情况
|
|
38
|
+
|
|
39
|
+
(_childProgress$stdout2 = childProgress.stdout) === null || _childProgress$stdout2 === void 0 ? void 0 : _childProgress$stdout2.on('error', error => {
|
|
40
|
+
console.error(error.message);
|
|
41
|
+
});
|
|
42
|
+
(_childProgress$stderr = childProgress.stderr) === null || _childProgress$stderr === void 0 ? void 0 : _childProgress$stderr.on('data', chunk => {
|
|
43
|
+
console.error(chunk.toString());
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const generatorDts = async (_, config) => {
|
|
48
|
+
const {
|
|
49
|
+
tsconfigPath,
|
|
50
|
+
distDir,
|
|
51
|
+
sourceDirName = 'src',
|
|
52
|
+
projectData: {
|
|
53
|
+
appDirectory
|
|
54
|
+
},
|
|
55
|
+
tsCheck = false,
|
|
56
|
+
watch = false
|
|
57
|
+
} = config;
|
|
58
|
+
const userTsconfig = getProjectTsconfig(tsconfigPath);
|
|
59
|
+
const willDeleteTsconfigPath = utils.generatorTsConfig(userTsconfig, {
|
|
60
|
+
appDirectory,
|
|
61
|
+
distDir,
|
|
62
|
+
sourceDir: sourceDirName
|
|
63
|
+
});
|
|
64
|
+
removeTsconfigPath = willDeleteTsconfigPath;
|
|
65
|
+
const tscBinFile = path.join(appDirectory, './node_modules/.bin/tsc');
|
|
66
|
+
const watchParams = watch ? ['-w'] : [];
|
|
67
|
+
const childProgress = execa(tscBinFile, ['-p', willDeleteTsconfigPath, ...watchParams], {
|
|
68
|
+
stdio: 'pipe',
|
|
69
|
+
cwd: appDirectory
|
|
70
|
+
});
|
|
71
|
+
resolveLog(childProgress, {
|
|
72
|
+
tsCheck,
|
|
73
|
+
watch
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
await childProgress;
|
|
78
|
+
console.info('[Tsc Compiler]: Successfully');
|
|
79
|
+
} catch (e) {
|
|
80
|
+
if (!tsCheck) {
|
|
81
|
+
console.info(`There are some type warnings, which can be checked by configuring 'output.disableTsChecker = false'`);
|
|
82
|
+
} else {
|
|
83
|
+
const isRecord = input => typeof input === 'object'; // 通过使用 execa,可以将tsc 的 data 类型的报错信息变为异常错误信息
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
if (isRecord(e)) {
|
|
87
|
+
console.error(e.stdout);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
fs.removeSync(willDeleteTsconfigPath);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const taskMain = async ({
|
|
96
|
+
modernConfig
|
|
97
|
+
}) => {
|
|
98
|
+
const processArgv = argv(process.argv.slice(2));
|
|
99
|
+
const config = processArgv({
|
|
100
|
+
appDirectory: process.cwd(),
|
|
101
|
+
srcDir: 'src',
|
|
102
|
+
distDir: 'dist/types',
|
|
103
|
+
tsconfigPath: './tsconfig.json',
|
|
104
|
+
sourceDirName: 'src'
|
|
105
|
+
});
|
|
106
|
+
const option = {
|
|
107
|
+
srcDir: config.srcDir,
|
|
108
|
+
distDir: config.distDir,
|
|
109
|
+
projectData: {
|
|
110
|
+
appDirectory: config.appDirectory
|
|
111
|
+
},
|
|
112
|
+
tsconfigPath: config.tsconfigPath,
|
|
113
|
+
watch: config.watch,
|
|
114
|
+
tsCheck: config.tsCheck,
|
|
115
|
+
sourceDirName: config.sourceDirName
|
|
116
|
+
};
|
|
117
|
+
await generatorDts(modernConfig, option); // // TODO: watch 模式下无法转换
|
|
118
|
+
|
|
119
|
+
utils.resolveAlias(modernConfig, option);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
(async () => {
|
|
123
|
+
let options;
|
|
124
|
+
|
|
125
|
+
if (process.env.CORE_INIT_OPTION_FILE) {
|
|
126
|
+
({
|
|
127
|
+
options
|
|
128
|
+
} = require(process.env.CORE_INIT_OPTION_FILE));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const {
|
|
132
|
+
resolved
|
|
133
|
+
} = await core.cli.init([], options);
|
|
134
|
+
await core.manager.run(async () => {
|
|
135
|
+
try {
|
|
136
|
+
await taskMain({
|
|
137
|
+
modernConfig: resolved
|
|
138
|
+
});
|
|
139
|
+
} catch (e) {
|
|
140
|
+
console.error(e.message);
|
|
141
|
+
fs.removeSync(removeTsconfigPath);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
})();
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
7
|
+
import * as path from 'path';
|
|
8
|
+
import { Import, fs } from '@modern-js/utils';
|
|
9
|
+
const glob = Import.lazy('glob', require);
|
|
10
|
+
const babel = Import.lazy('../../utils/babel', require);
|
|
11
|
+
const tsPathsTransform = Import.lazy('../../utils/tspaths-transform', require);
|
|
12
|
+
const constants = Import.lazy('../constants', require);
|
|
13
|
+
const deepMerge = Import.lazy('lodash.merge', require);
|
|
14
|
+
export const generatorTsConfig = (projectTsconfig, {
|
|
15
|
+
appDirectory,
|
|
16
|
+
distDir,
|
|
17
|
+
sourceDir: _sourceDir = 'src'
|
|
18
|
+
}) => {
|
|
19
|
+
var _projectTsconfig$comp, _projectTsconfig$comp2, _projectTsconfig$incl, _projectTsconfig$excl;
|
|
20
|
+
|
|
21
|
+
const tempPath = path.resolve(appDirectory, './node_modules');
|
|
22
|
+
const resolvePath = path.relative(tempPath, appDirectory); // const rootDir = projectTsconfig.compilerOptions?.rootDir
|
|
23
|
+
// ? path.join(resolvePath, projectTsconfig.compilerOptions?.rootDir)
|
|
24
|
+
// : resolvePath;
|
|
25
|
+
// 目前限制 rootDir 的路径为 sourceDir
|
|
26
|
+
|
|
27
|
+
const rootDir = path.join(resolvePath, _sourceDir);
|
|
28
|
+
const baseUrl = (_projectTsconfig$comp = projectTsconfig.compilerOptions) !== null && _projectTsconfig$comp !== void 0 && _projectTsconfig$comp.baseUrl ? path.join(appDirectory, (_projectTsconfig$comp2 = projectTsconfig.compilerOptions) === null || _projectTsconfig$comp2 === void 0 ? void 0 : _projectTsconfig$comp2.baseUrl) : appDirectory; // if include = ['src'], final include should be ['../src']
|
|
29
|
+
|
|
30
|
+
const include = (_projectTsconfig$incl = projectTsconfig.include) === null || _projectTsconfig$incl === void 0 ? void 0 : _projectTsconfig$incl.map(includePath => path.join(resolvePath, includePath));
|
|
31
|
+
const exclude = (_projectTsconfig$excl = projectTsconfig.exclude) === null || _projectTsconfig$excl === void 0 ? void 0 : _projectTsconfig$excl.map(excludePath => path.join(resolvePath, excludePath));
|
|
32
|
+
const resetConfig = {
|
|
33
|
+
compilerOptions: {
|
|
34
|
+
rootDir,
|
|
35
|
+
baseUrl,
|
|
36
|
+
// Ensure that .d.ts files are created by tsc, but not .js files
|
|
37
|
+
declaration: true,
|
|
38
|
+
emitDeclarationOnly: true,
|
|
39
|
+
outDir: distDir
|
|
40
|
+
},
|
|
41
|
+
include,
|
|
42
|
+
exclude
|
|
43
|
+
};
|
|
44
|
+
const recommendOption = {
|
|
45
|
+
// Ensure that Babel can safely transpile files in the TypeScript project
|
|
46
|
+
compilerOptions: {
|
|
47
|
+
isolatedModules: true
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const tempTsconfigPath = path.join(tempPath, constants.tempTsconfigName);
|
|
51
|
+
fs.ensureFileSync(tempTsconfigPath);
|
|
52
|
+
fs.writeJSONSync(tempTsconfigPath, deepMerge(recommendOption, projectTsconfig, // 此处是必须要覆盖用户默认配置
|
|
53
|
+
resetConfig));
|
|
54
|
+
return tempTsconfigPath;
|
|
55
|
+
};
|
|
56
|
+
export const resolveAlias = (modernConfig, config, watchFilenames = []) => {
|
|
57
|
+
const {
|
|
58
|
+
output
|
|
59
|
+
} = modernConfig;
|
|
60
|
+
const defaultPaths = {
|
|
61
|
+
'@': ['./src']
|
|
62
|
+
};
|
|
63
|
+
const dtsDistPath = `${config.distDir}/**/*.d.ts`;
|
|
64
|
+
const dtsFilenames = watchFilenames.length > 0 ? watchFilenames : glob.sync(dtsDistPath, {
|
|
65
|
+
absolute: true
|
|
66
|
+
});
|
|
67
|
+
const alias = babel.getFinalAlias(modernConfig, {
|
|
68
|
+
appDirectory: config.projectData.appDirectory,
|
|
69
|
+
tsconfigPath: config.tsconfigPath || path.join(config.projectData.appDirectory, './tsconfig.json'),
|
|
70
|
+
sourceAbsDir: config.distDir
|
|
71
|
+
});
|
|
72
|
+
const mergedPaths = alias.isTsPath ? alias.paths || {} : _objectSpread(_objectSpread({}, defaultPaths), alias.paths || {});
|
|
73
|
+
const result = tsPathsTransform.transformDtsAlias({
|
|
74
|
+
filenames: dtsFilenames,
|
|
75
|
+
baseUrl: path.join(config.projectData.appDirectory, output.path || 'dist'),
|
|
76
|
+
paths: mergedPaths
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
for (const r of result) {
|
|
80
|
+
fs.writeFileSync(r.path, r.content);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
@@ -5,7 +5,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
7
|
import { getBabelConfig, getModuleBabelChain } from '@modern-js/babel-preset-module';
|
|
8
|
-
import { applyOptionsChain, getAlias } from '@modern-js/utils';
|
|
8
|
+
import { applyOptionsChain, getAlias, isUseSSRBundle } from '@modern-js/utils';
|
|
9
9
|
export const getFinalAlias = (modernConfig, option) => {
|
|
10
10
|
const aliasConfig = getAlias(modernConfig.source.alias, option); // 排除内部别名,因为不需要处理
|
|
11
11
|
|
|
@@ -36,7 +36,8 @@ export const resolveBabelConfig = (appDirectory, modernConfig, option) => {
|
|
|
36
36
|
importStyle
|
|
37
37
|
},
|
|
38
38
|
tools: {
|
|
39
|
-
lodash: userLodashOption
|
|
39
|
+
lodash: userLodashOption,
|
|
40
|
+
styledComponents
|
|
40
41
|
}
|
|
41
42
|
} = modernConfig; // alias config
|
|
42
43
|
|
|
@@ -58,7 +59,13 @@ export const resolveBabelConfig = (appDirectory, modernConfig, option) => {
|
|
|
58
59
|
globalVars,
|
|
59
60
|
lodashOptions,
|
|
60
61
|
jsxTransformRuntime,
|
|
61
|
-
importStyle
|
|
62
|
+
importStyle,
|
|
63
|
+
styledComponentsOptions: applyOptionsChain({
|
|
64
|
+
pure: true,
|
|
65
|
+
displayName: true,
|
|
66
|
+
ssr: isUseSSRBundle(modernConfig),
|
|
67
|
+
transpileTemplateLiterals: true
|
|
68
|
+
}, styledComponents)
|
|
62
69
|
}, {
|
|
63
70
|
type: option.type,
|
|
64
71
|
syntax: option.syntax
|
|
@@ -37,7 +37,7 @@ const build = async ({
|
|
|
37
37
|
const tsconfigPath = path.join(appDirectory, tsconfigName);
|
|
38
38
|
dotenv.config();
|
|
39
39
|
const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
|
|
40
|
-
const enableTscCompiler = isTsProject && tsc;
|
|
40
|
+
const enableTscCompiler = isTsProject && tsc && !modernConfig.output.disableTsChecker;
|
|
41
41
|
valid.valideBeforeTask({
|
|
42
42
|
modernConfig,
|
|
43
43
|
tsconfigPath
|
|
@@ -61,7 +61,7 @@ exports.devStorybook = devStorybook;
|
|
|
61
61
|
|
|
62
62
|
const runSubCmd = async (subCmd, config) => {
|
|
63
63
|
const metas = await core.mountHook().moduleToolsMenu(undefined);
|
|
64
|
-
const devMeta = metas.find(meta => meta.value === subCmd);
|
|
64
|
+
const devMeta = metas.find(meta => meta.value === subCmd || Array.isArray(meta.aliasValues) && meta.aliasValues.includes(subCmd));
|
|
65
65
|
|
|
66
66
|
if (devMeta) {
|
|
67
67
|
await devMeta.runTask(config);
|
|
@@ -78,7 +78,8 @@ const runBabelCompiler = async (config, modernConfig) => {
|
|
|
78
78
|
rootDir: config.srcRootDir,
|
|
79
79
|
distDir: config.distDir,
|
|
80
80
|
watchDir: config.srcRootDir,
|
|
81
|
-
extensions: getExts(isTs)
|
|
81
|
+
extensions: getExts(isTs),
|
|
82
|
+
ignore: ['*.d.ts']
|
|
82
83
|
}, _objectSpread(_objectSpread({}, babelConfig), {}, {
|
|
83
84
|
sourceMaps: config.sourceMaps
|
|
84
85
|
}));
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var path = _interopRequireWildcard(require("path"));
|
|
4
|
+
|
|
5
|
+
var _utils = require("@modern-js/utils");
|
|
6
|
+
|
|
7
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
8
|
+
|
|
9
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
|
+
|
|
11
|
+
const core = _utils.Import.lazy('@modern-js/core', require);
|
|
12
|
+
|
|
13
|
+
const execa = _utils.Import.lazy('execa', require);
|
|
14
|
+
|
|
15
|
+
const JSON5 = _utils.Import.lazy('json5', require);
|
|
16
|
+
|
|
17
|
+
const argv = _utils.Import.lazy('process.argv', require);
|
|
18
|
+
|
|
19
|
+
const utils = _utils.Import.lazy('./utils', require);
|
|
20
|
+
|
|
21
|
+
let removeTsconfigPath = '';
|
|
22
|
+
|
|
23
|
+
const getProjectTsconfig = tsconfigPath => {
|
|
24
|
+
if (!tsconfigPath || !_utils.fs.existsSync(tsconfigPath)) {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return JSON5.parse(_utils.fs.readFileSync(tsconfigPath, 'utf-8'));
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const resolveLog = (childProgress, {
|
|
32
|
+
tsCheck: _tsCheck = false,
|
|
33
|
+
watch: _watch = false
|
|
34
|
+
} = {}) => {
|
|
35
|
+
var _childProgress$stdout, _childProgress$stdout2, _childProgress$stderr;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* tsc 所有的log信息都是从stdout data 事件中获取
|
|
39
|
+
* 正常模式下,如果有报错信息,交给 resolveLog 后面的逻辑来处理
|
|
40
|
+
* watch 模式下,则使用这里的信息
|
|
41
|
+
*/
|
|
42
|
+
(_childProgress$stdout = childProgress.stdout) === null || _childProgress$stdout === void 0 ? void 0 : _childProgress$stdout.on('data', data => {
|
|
43
|
+
if (!_tsCheck) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (_watch) {
|
|
48
|
+
console.info(data.toString());
|
|
49
|
+
}
|
|
50
|
+
}); // 正常以下内容都不会触发,因为tsc 不会产生以下类型的log信息,不过防止意外情况
|
|
51
|
+
|
|
52
|
+
(_childProgress$stdout2 = childProgress.stdout) === null || _childProgress$stdout2 === void 0 ? void 0 : _childProgress$stdout2.on('error', error => {
|
|
53
|
+
console.error(error.message);
|
|
54
|
+
});
|
|
55
|
+
(_childProgress$stderr = childProgress.stderr) === null || _childProgress$stderr === void 0 ? void 0 : _childProgress$stderr.on('data', chunk => {
|
|
56
|
+
console.error(chunk.toString());
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const generatorDts = async (_, config) => {
|
|
61
|
+
const {
|
|
62
|
+
tsconfigPath,
|
|
63
|
+
distDir,
|
|
64
|
+
sourceDirName = 'src',
|
|
65
|
+
projectData: {
|
|
66
|
+
appDirectory
|
|
67
|
+
},
|
|
68
|
+
tsCheck = false,
|
|
69
|
+
watch = false
|
|
70
|
+
} = config;
|
|
71
|
+
const userTsconfig = getProjectTsconfig(tsconfigPath);
|
|
72
|
+
const willDeleteTsconfigPath = utils.generatorTsConfig(userTsconfig, {
|
|
73
|
+
appDirectory,
|
|
74
|
+
distDir,
|
|
75
|
+
sourceDir: sourceDirName
|
|
76
|
+
});
|
|
77
|
+
removeTsconfigPath = willDeleteTsconfigPath;
|
|
78
|
+
const tscBinFile = path.join(appDirectory, './node_modules/.bin/tsc');
|
|
79
|
+
const watchParams = watch ? ['-w'] : [];
|
|
80
|
+
const childProgress = execa(tscBinFile, ['-p', willDeleteTsconfigPath, ...watchParams], {
|
|
81
|
+
stdio: 'pipe',
|
|
82
|
+
cwd: appDirectory
|
|
83
|
+
});
|
|
84
|
+
resolveLog(childProgress, {
|
|
85
|
+
tsCheck,
|
|
86
|
+
watch
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
await childProgress;
|
|
91
|
+
console.info('[Tsc Compiler]: Successfully');
|
|
92
|
+
} catch (e) {
|
|
93
|
+
if (!tsCheck) {
|
|
94
|
+
console.info(`There are some type warnings, which can be checked by configuring 'output.disableTsChecker = false'`);
|
|
95
|
+
} else {
|
|
96
|
+
const isRecord = input => typeof input === 'object'; // 通过使用 execa,可以将tsc 的 data 类型的报错信息变为异常错误信息
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
if (isRecord(e)) {
|
|
100
|
+
console.error(e.stdout);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_utils.fs.removeSync(willDeleteTsconfigPath);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const taskMain = async ({
|
|
109
|
+
modernConfig
|
|
110
|
+
}) => {
|
|
111
|
+
const processArgv = argv(process.argv.slice(2));
|
|
112
|
+
const config = processArgv({
|
|
113
|
+
appDirectory: process.cwd(),
|
|
114
|
+
srcDir: 'src',
|
|
115
|
+
distDir: 'dist/types',
|
|
116
|
+
tsconfigPath: './tsconfig.json',
|
|
117
|
+
sourceDirName: 'src'
|
|
118
|
+
});
|
|
119
|
+
const option = {
|
|
120
|
+
srcDir: config.srcDir,
|
|
121
|
+
distDir: config.distDir,
|
|
122
|
+
projectData: {
|
|
123
|
+
appDirectory: config.appDirectory
|
|
124
|
+
},
|
|
125
|
+
tsconfigPath: config.tsconfigPath,
|
|
126
|
+
watch: config.watch,
|
|
127
|
+
tsCheck: config.tsCheck,
|
|
128
|
+
sourceDirName: config.sourceDirName
|
|
129
|
+
};
|
|
130
|
+
await generatorDts(modernConfig, option); // // TODO: watch 模式下无法转换
|
|
131
|
+
|
|
132
|
+
utils.resolveAlias(modernConfig, option);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
(async () => {
|
|
136
|
+
let options;
|
|
137
|
+
|
|
138
|
+
if (process.env.CORE_INIT_OPTION_FILE) {
|
|
139
|
+
({
|
|
140
|
+
options
|
|
141
|
+
} = require(process.env.CORE_INIT_OPTION_FILE));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const {
|
|
145
|
+
resolved
|
|
146
|
+
} = await core.cli.init([], options);
|
|
147
|
+
await core.manager.run(async () => {
|
|
148
|
+
try {
|
|
149
|
+
await taskMain({
|
|
150
|
+
modernConfig: resolved
|
|
151
|
+
});
|
|
152
|
+
} catch (e) {
|
|
153
|
+
console.error(e.message);
|
|
154
|
+
|
|
155
|
+
_utils.fs.removeSync(removeTsconfigPath);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
})();
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.resolveAlias = exports.generatorTsConfig = void 0;
|
|
4
7
|
|
|
5
|
-
var
|
|
8
|
+
var path = _interopRequireWildcard(require("path"));
|
|
6
9
|
|
|
7
10
|
var _utils = require("@modern-js/utils");
|
|
8
11
|
|
|
@@ -16,26 +19,16 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
16
19
|
|
|
17
20
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
21
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const babel = _utils.Import.lazy('../utils/babel', require);
|
|
22
|
-
|
|
23
|
-
const constants = _utils.Import.lazy('./constants', require);
|
|
24
|
-
|
|
25
|
-
const core = _utils.Import.lazy('@modern-js/core', require);
|
|
22
|
+
const glob = _utils.Import.lazy('glob', require);
|
|
26
23
|
|
|
27
|
-
const
|
|
24
|
+
const babel = _utils.Import.lazy('../../utils/babel', require);
|
|
28
25
|
|
|
29
|
-
const
|
|
26
|
+
const tsPathsTransform = _utils.Import.lazy('../../utils/tspaths-transform', require);
|
|
30
27
|
|
|
31
|
-
const
|
|
28
|
+
const constants = _utils.Import.lazy('../constants', require);
|
|
32
29
|
|
|
33
30
|
const deepMerge = _utils.Import.lazy('lodash.merge', require);
|
|
34
31
|
|
|
35
|
-
const glob = _utils.Import.lazy('glob', require);
|
|
36
|
-
|
|
37
|
-
let removeTsconfigPath = '';
|
|
38
|
-
|
|
39
32
|
const generatorTsConfig = (projectTsconfig, {
|
|
40
33
|
appDirectory,
|
|
41
34
|
distDir,
|
|
@@ -82,90 +75,7 @@ const generatorTsConfig = (projectTsconfig, {
|
|
|
82
75
|
return tempTsconfigPath;
|
|
83
76
|
};
|
|
84
77
|
|
|
85
|
-
|
|
86
|
-
if (!tsconfigPath || !_utils.fs.existsSync(tsconfigPath)) {
|
|
87
|
-
return {};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return JSON5.parse(_utils.fs.readFileSync(tsconfigPath, 'utf-8'));
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const resolveLog = (childProgress, {
|
|
94
|
-
tsCheck: _tsCheck = false,
|
|
95
|
-
watch: _watch = false
|
|
96
|
-
} = {}) => {
|
|
97
|
-
var _childProgress$stdout, _childProgress$stdout2, _childProgress$stderr;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* tsc 所有的log信息都是从stdout data 事件中获取
|
|
101
|
-
* 正常模式下,如果有报错信息,交给 resolveLog 后面的逻辑来处理
|
|
102
|
-
* watch 模式下,则使用这里的信息
|
|
103
|
-
*/
|
|
104
|
-
(_childProgress$stdout = childProgress.stdout) === null || _childProgress$stdout === void 0 ? void 0 : _childProgress$stdout.on('data', data => {
|
|
105
|
-
if (!_tsCheck) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (_watch) {
|
|
110
|
-
console.info(data.toString());
|
|
111
|
-
}
|
|
112
|
-
}); // 正常以下内容都不会触发,因为tsc 不会产生以下类型的log信息,不过防止意外情况
|
|
113
|
-
|
|
114
|
-
(_childProgress$stdout2 = childProgress.stdout) === null || _childProgress$stdout2 === void 0 ? void 0 : _childProgress$stdout2.on('error', error => {
|
|
115
|
-
console.error(error.message);
|
|
116
|
-
});
|
|
117
|
-
(_childProgress$stderr = childProgress.stderr) === null || _childProgress$stderr === void 0 ? void 0 : _childProgress$stderr.on('data', chunk => {
|
|
118
|
-
console.error(chunk.toString());
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const generatorDts = async (_, config) => {
|
|
123
|
-
const {
|
|
124
|
-
tsconfigPath,
|
|
125
|
-
distDir,
|
|
126
|
-
sourceDirName = 'src',
|
|
127
|
-
projectData: {
|
|
128
|
-
appDirectory
|
|
129
|
-
},
|
|
130
|
-
tsCheck = false,
|
|
131
|
-
watch = false
|
|
132
|
-
} = config;
|
|
133
|
-
const userTsconfig = getProjectTsconfig(tsconfigPath);
|
|
134
|
-
const willDeleteTsconfigPath = generatorTsConfig(userTsconfig, {
|
|
135
|
-
appDirectory,
|
|
136
|
-
distDir,
|
|
137
|
-
sourceDir: sourceDirName
|
|
138
|
-
});
|
|
139
|
-
removeTsconfigPath = willDeleteTsconfigPath;
|
|
140
|
-
const tscBinFile = path.join(appDirectory, './node_modules/.bin/tsc');
|
|
141
|
-
const watchParams = watch ? ['-w'] : [];
|
|
142
|
-
const childProgress = execa(tscBinFile, ['-p', willDeleteTsconfigPath, ...watchParams], {
|
|
143
|
-
stdio: 'pipe',
|
|
144
|
-
cwd: appDirectory
|
|
145
|
-
});
|
|
146
|
-
resolveLog(childProgress, {
|
|
147
|
-
tsCheck,
|
|
148
|
-
watch
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
try {
|
|
152
|
-
await childProgress;
|
|
153
|
-
console.info('[Tsc Compiler]: Successfully');
|
|
154
|
-
} catch (e) {
|
|
155
|
-
if (!tsCheck) {
|
|
156
|
-
console.warn(`There are some type issues, which can be checked by configuring 'source.enableTsChecker = true' ${os.EOL} in modern.config.js`);
|
|
157
|
-
} else {
|
|
158
|
-
const isRecord = input => typeof input === 'object'; // 通过使用 execa,可以将tsc 的 data 类型的报错信息变为异常错误信息
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (isRecord(e)) {
|
|
162
|
-
console.error(e.stdout);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
_utils.fs.removeSync(willDeleteTsconfigPath);
|
|
168
|
-
};
|
|
78
|
+
exports.generatorTsConfig = generatorTsConfig;
|
|
169
79
|
|
|
170
80
|
const resolveAlias = (modernConfig, config, watchFilenames = []) => {
|
|
171
81
|
const {
|
|
@@ -195,54 +105,4 @@ const resolveAlias = (modernConfig, config, watchFilenames = []) => {
|
|
|
195
105
|
}
|
|
196
106
|
};
|
|
197
107
|
|
|
198
|
-
|
|
199
|
-
modernConfig
|
|
200
|
-
}) => {
|
|
201
|
-
const processArgv = argv(process.argv.slice(2));
|
|
202
|
-
const config = processArgv({
|
|
203
|
-
appDirectory: process.cwd(),
|
|
204
|
-
srcDir: 'src',
|
|
205
|
-
distDir: 'dist/types',
|
|
206
|
-
tsconfigPath: './tsconfig.json',
|
|
207
|
-
sourceDirName: 'src'
|
|
208
|
-
});
|
|
209
|
-
const option = {
|
|
210
|
-
srcDir: config.srcDir,
|
|
211
|
-
distDir: config.distDir,
|
|
212
|
-
projectData: {
|
|
213
|
-
appDirectory: config.appDirectory
|
|
214
|
-
},
|
|
215
|
-
tsconfigPath: config.tsconfigPath,
|
|
216
|
-
watch: config.watch,
|
|
217
|
-
tsCheck: config.tsCheck,
|
|
218
|
-
sourceDirName: config.sourceDirName
|
|
219
|
-
};
|
|
220
|
-
await generatorDts(modernConfig, option); // TODO: watch 模式下无法转换
|
|
221
|
-
|
|
222
|
-
resolveAlias(modernConfig, option);
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
(async () => {
|
|
226
|
-
let options;
|
|
227
|
-
|
|
228
|
-
if (process.env.CORE_INIT_OPTION_FILE) {
|
|
229
|
-
({
|
|
230
|
-
options
|
|
231
|
-
} = require(process.env.CORE_INIT_OPTION_FILE));
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const {
|
|
235
|
-
resolved
|
|
236
|
-
} = await core.cli.init([], options);
|
|
237
|
-
await core.manager.run(async () => {
|
|
238
|
-
try {
|
|
239
|
-
await taskMain({
|
|
240
|
-
modernConfig: resolved
|
|
241
|
-
});
|
|
242
|
-
} catch (e) {
|
|
243
|
-
console.error(e.message);
|
|
244
|
-
|
|
245
|
-
_utils.fs.removeSync(removeTsconfigPath);
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
})();
|
|
108
|
+
exports.resolveAlias = resolveAlias;
|
|
@@ -48,7 +48,8 @@ const resolveBabelConfig = (appDirectory, modernConfig, option) => {
|
|
|
48
48
|
importStyle
|
|
49
49
|
},
|
|
50
50
|
tools: {
|
|
51
|
-
lodash: userLodashOption
|
|
51
|
+
lodash: userLodashOption,
|
|
52
|
+
styledComponents
|
|
52
53
|
}
|
|
53
54
|
} = modernConfig; // alias config
|
|
54
55
|
|
|
@@ -70,7 +71,13 @@ const resolveBabelConfig = (appDirectory, modernConfig, option) => {
|
|
|
70
71
|
globalVars,
|
|
71
72
|
lodashOptions,
|
|
72
73
|
jsxTransformRuntime,
|
|
73
|
-
importStyle
|
|
74
|
+
importStyle,
|
|
75
|
+
styledComponentsOptions: (0, _utils.applyOptionsChain)({
|
|
76
|
+
pure: true,
|
|
77
|
+
displayName: true,
|
|
78
|
+
ssr: (0, _utils.isUseSSRBundle)(modernConfig),
|
|
79
|
+
transpileTemplateLiterals: true
|
|
80
|
+
}, styledComponents)
|
|
74
81
|
}, {
|
|
75
82
|
type: option.type,
|
|
76
83
|
syntax: option.syntax
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { NormalizedConfig } from '@modern-js/core';
|
|
2
|
+
import type { ITsconfig } from '../../types';
|
|
3
|
+
export interface IGeneratorConfig {
|
|
4
|
+
sourceDirName?: string;
|
|
5
|
+
srcDir: string;
|
|
6
|
+
distDir: string;
|
|
7
|
+
projectData: {
|
|
8
|
+
appDirectory: string;
|
|
9
|
+
};
|
|
10
|
+
tsconfigPath?: string;
|
|
11
|
+
tsCheck?: boolean;
|
|
12
|
+
watch?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const generatorTsConfig: (projectTsconfig: ITsconfig, {
|
|
15
|
+
appDirectory,
|
|
16
|
+
distDir,
|
|
17
|
+
sourceDir
|
|
18
|
+
}: {
|
|
19
|
+
appDirectory: string;
|
|
20
|
+
distDir: string;
|
|
21
|
+
sourceDir?: string | undefined;
|
|
22
|
+
}) => string;
|
|
23
|
+
export declare const resolveAlias: (modernConfig: NormalizedConfig, config: IGeneratorConfig, watchFilenames?: string[]) => void;
|
package/jest.config.js
CHANGED
package/lib/types.d.ts
CHANGED
|
@@ -55,6 +55,98 @@ declare module '*.svg' {
|
|
|
55
55
|
export default src;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
declare module '*.bmp?inline' {
|
|
59
|
+
const src: string;
|
|
60
|
+
export default src;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare module '*.gif?inline' {
|
|
64
|
+
const src: string;
|
|
65
|
+
export default src;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
declare module '*.jpg?inline' {
|
|
69
|
+
const src: string;
|
|
70
|
+
export default src;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
declare module '*.jpeg?inline' {
|
|
74
|
+
const src: string;
|
|
75
|
+
export default src;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
declare module '*.png?inline' {
|
|
79
|
+
const src: string;
|
|
80
|
+
export default src;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare module '*.ico?inline' {
|
|
84
|
+
const src: string;
|
|
85
|
+
export default src;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
declare module '*.webp?inline' {
|
|
89
|
+
const src: string;
|
|
90
|
+
export default src;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare module '*.svg?inline' {
|
|
94
|
+
import * as React from 'react';
|
|
95
|
+
|
|
96
|
+
export const ReactComponent: React.FunctionComponent<
|
|
97
|
+
React.SVGProps<SVGSVGElement>
|
|
98
|
+
>;
|
|
99
|
+
|
|
100
|
+
const src: string;
|
|
101
|
+
export default src;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare module '*.bmp?url' {
|
|
105
|
+
const src: string;
|
|
106
|
+
export default src;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
declare module '*.gif?url' {
|
|
110
|
+
const src: string;
|
|
111
|
+
export default src;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
declare module '*.jpg?url' {
|
|
115
|
+
const src: string;
|
|
116
|
+
export default src;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
declare module '*.jpeg?url' {
|
|
120
|
+
const src: string;
|
|
121
|
+
export default src;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare module '*.png?url' {
|
|
125
|
+
const src: string;
|
|
126
|
+
export default src;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
declare module '*.ico?url' {
|
|
130
|
+
const src: string;
|
|
131
|
+
export default src;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
declare module '*.webp?url' {
|
|
135
|
+
const src: string;
|
|
136
|
+
export default src;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
declare module '*.svg?url' {
|
|
140
|
+
import * as React from 'react';
|
|
141
|
+
|
|
142
|
+
export const ReactComponent: React.FunctionComponent<
|
|
143
|
+
React.SVGProps<SVGSVGElement>
|
|
144
|
+
>;
|
|
145
|
+
|
|
146
|
+
const src: string;
|
|
147
|
+
export default src;
|
|
148
|
+
}
|
|
149
|
+
|
|
58
150
|
declare module '*.css' {
|
|
59
151
|
const classes: { readonly [key: string]: string };
|
|
60
152
|
export default classes;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.4.2",
|
|
15
15
|
"bin": {
|
|
16
16
|
"modern": "./bin/modern.js"
|
|
17
17
|
},
|
|
@@ -46,26 +46,25 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
+
"@modern-js/core": "^1.4.4",
|
|
49
50
|
"@babel/generator": "^7.15.0",
|
|
50
51
|
"@babel/parser": "^7.15.2",
|
|
51
52
|
"@babel/runtime": "^7",
|
|
52
53
|
"@babel/traverse": "^7.15.0",
|
|
53
54
|
"@babel/types": "^7.15.0",
|
|
54
|
-
"@modern-js/babel-compiler": "^1.2.
|
|
55
|
+
"@modern-js/babel-compiler": "^1.2.2",
|
|
55
56
|
"@modern-js/babel-preset-module": "^1.3.1",
|
|
56
|
-
"@modern-js/
|
|
57
|
-
"@modern-js/css-config": "^1.2.1",
|
|
57
|
+
"@modern-js/css-config": "^1.2.2",
|
|
58
58
|
"@modern-js/i18n-cli-language-detector": "^1.2.1",
|
|
59
|
-
"@modern-js/module-tools-hooks": "^1.2.
|
|
60
|
-
"@modern-js/new-action": "^1.3.
|
|
61
|
-
"@modern-js/plugin-analyze": "^1.3.
|
|
62
|
-
"@modern-js/plugin-changeset": "^1.2.
|
|
59
|
+
"@modern-js/module-tools-hooks": "^1.2.2",
|
|
60
|
+
"@modern-js/new-action": "^1.3.3",
|
|
61
|
+
"@modern-js/plugin-analyze": "^1.3.3",
|
|
62
|
+
"@modern-js/plugin-changeset": "^1.2.2",
|
|
63
63
|
"@modern-js/plugin-fast-refresh": "^1.2.1",
|
|
64
64
|
"@modern-js/plugin-i18n": "^1.2.1",
|
|
65
|
-
"@modern-js/style-compiler": "^1.2.
|
|
66
|
-
"@modern-js/utils": "^1.3.
|
|
65
|
+
"@modern-js/style-compiler": "^1.2.2",
|
|
66
|
+
"@modern-js/utils": "^1.3.3",
|
|
67
67
|
"chalk": "^4.1.2",
|
|
68
|
-
"chokidar": "^3.5.2",
|
|
69
68
|
"dotenv": "^10.0.0",
|
|
70
69
|
"execa": "^5.1.1",
|
|
71
70
|
"fast-glob": "^3.2.5",
|
|
@@ -77,7 +76,6 @@
|
|
|
77
76
|
"normalize-path": "^3.0.0",
|
|
78
77
|
"p-map": "^4",
|
|
79
78
|
"process.argv": "^0.6.0",
|
|
80
|
-
"signale": "^1.4.0",
|
|
81
79
|
"tsconfig-paths": "^3.10.1"
|
|
82
80
|
},
|
|
83
81
|
"devDependencies": {
|
|
@@ -92,11 +90,12 @@
|
|
|
92
90
|
"@types/lodash.merge": "^4.6.6",
|
|
93
91
|
"@types/node": "^14",
|
|
94
92
|
"@types/normalize-path": "^3.0.0",
|
|
95
|
-
"@types/signale": "^1.4.2",
|
|
96
93
|
"commander": "^8.1.0",
|
|
97
94
|
"typescript": "^4",
|
|
98
95
|
"@scripts/build": "0.0.0",
|
|
99
96
|
"jest": "^27",
|
|
97
|
+
"@types/react": "^17",
|
|
98
|
+
"@types/react-dom": "^17",
|
|
100
99
|
"@scripts/jest-config": "0.0.0"
|
|
101
100
|
},
|
|
102
101
|
"sideEffects": false,
|
|
@@ -12,7 +12,7 @@ jest.mock('@modern-js/core', () => ({
|
|
|
12
12
|
|
|
13
13
|
describe('dev feature with subCmd', () => {
|
|
14
14
|
beforeEach(() => {
|
|
15
|
-
|
|
15
|
+
jest.clearAllMocks();
|
|
16
16
|
});
|
|
17
17
|
it('should run task with "storybook" params when storybook plugin exist', async () => {
|
|
18
18
|
mockModuleToolsMenu.mockReturnValue([
|
|
@@ -27,4 +27,20 @@ describe('dev feature with subCmd', () => {
|
|
|
27
27
|
await runSubCmd('storybook', { isTsProject: true, appDirectory: '' });
|
|
28
28
|
expect(exit).toHaveBeenCalled();
|
|
29
29
|
});
|
|
30
|
+
|
|
31
|
+
it('should run task with alias name "story" params when storybook plugin exist', async () => {
|
|
32
|
+
mockModuleToolsMenu.mockReturnValue([
|
|
33
|
+
{ value: 'storybook', aliasValues: ['story'], runTask: mockDevMeta },
|
|
34
|
+
]);
|
|
35
|
+
await runSubCmd('story', { isTsProject: true, appDirectory: '' });
|
|
36
|
+
expect(mockDevMeta.mock.calls.length).toBe(1);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should run task with alias name "story1" params when storybook plugin exist', async () => {
|
|
40
|
+
mockModuleToolsMenu.mockReturnValue([
|
|
41
|
+
{ value: 'storybook', aliasValues: ['story'], runTask: mockDevMeta },
|
|
42
|
+
]);
|
|
43
|
+
await runSubCmd('story1', { isTsProject: true, appDirectory: '' });
|
|
44
|
+
expect(mockDevMeta.mock.calls.length).toBe(0);
|
|
45
|
+
});
|
|
30
46
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { generatorTsConfig } from '../src/tasks/generator-dts/utils';
|
|
3
|
+
|
|
4
|
+
describe('test generator dts utils', () => {
|
|
5
|
+
it('test generatorTsConfig', () => {
|
|
6
|
+
const appDir = path.join(__dirname, './fixtures/tsconfig');
|
|
7
|
+
const ret = generatorTsConfig({}, { appDirectory: appDir, distDir: '' });
|
|
8
|
+
expect(ret).toContain('tsconfig.temp.json');
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
jest.mock('@modern-js/core', () => ({
|
|
2
|
+
manager: {
|
|
3
|
+
run: async (fn: any) => {
|
|
4
|
+
await fn();
|
|
5
|
+
},
|
|
6
|
+
},
|
|
7
|
+
cli: {
|
|
8
|
+
init: () => ({}),
|
|
9
|
+
},
|
|
10
|
+
}));
|
|
11
|
+
jest.mock('process.argv', () => () => (o: any) => ({ ...o, tsCheck: false }));
|
|
12
|
+
jest.mock('execa', () => () => {
|
|
13
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
14
|
+
const fn = Promise.reject('error');
|
|
15
|
+
(fn as any).stdout = {
|
|
16
|
+
on: () => 0,
|
|
17
|
+
};
|
|
18
|
+
(fn as any).stderr = {
|
|
19
|
+
on: () => 0,
|
|
20
|
+
};
|
|
21
|
+
return fn;
|
|
22
|
+
});
|
|
23
|
+
jest.mock('../src/tasks/generator-dts/utils');
|
|
24
|
+
jest.mock('@modern-js/utils', () => {
|
|
25
|
+
const originalModule = jest.requireActual('@modern-js/utils');
|
|
26
|
+
return {
|
|
27
|
+
__esModule: true, // Use it when dealing with esModules
|
|
28
|
+
...originalModule,
|
|
29
|
+
fs: {
|
|
30
|
+
...originalModule.fs,
|
|
31
|
+
removeSync: jest.fn(),
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
process.argv = [];
|
|
36
|
+
|
|
37
|
+
describe('generator dts test', () => {
|
|
38
|
+
it('test tsCheck is true', () => {
|
|
39
|
+
console.info = jest.fn(str => {
|
|
40
|
+
expect(str).toBe(
|
|
41
|
+
"There are some type warnings, which can be checked by configuring 'output.disableTsChecker = false'",
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
require('../src/tasks/generator-dts');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export {};
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
|
-
import * as path from 'path';
|
|
8
|
-
import * as os from 'os';
|
|
9
|
-
import { Import, fs } from '@modern-js/utils';
|
|
10
|
-
const tsPathsTransform = Import.lazy('../utils/tspaths-transform', require);
|
|
11
|
-
const babel = Import.lazy('../utils/babel', require);
|
|
12
|
-
const constants = Import.lazy('./constants', require);
|
|
13
|
-
const core = Import.lazy('@modern-js/core', require);
|
|
14
|
-
const execa = Import.lazy('execa', require);
|
|
15
|
-
const JSON5 = Import.lazy('json5', require);
|
|
16
|
-
const argv = Import.lazy('process.argv', require);
|
|
17
|
-
const deepMerge = Import.lazy('lodash.merge', require);
|
|
18
|
-
const glob = Import.lazy('glob', require);
|
|
19
|
-
let removeTsconfigPath = '';
|
|
20
|
-
|
|
21
|
-
const generatorTsConfig = (projectTsconfig, {
|
|
22
|
-
appDirectory,
|
|
23
|
-
distDir,
|
|
24
|
-
sourceDir: _sourceDir = 'src'
|
|
25
|
-
}) => {
|
|
26
|
-
var _projectTsconfig$comp, _projectTsconfig$comp2, _projectTsconfig$incl, _projectTsconfig$excl;
|
|
27
|
-
|
|
28
|
-
const tempPath = path.resolve(appDirectory, './node_modules');
|
|
29
|
-
const resolvePath = path.relative(tempPath, appDirectory); // const rootDir = projectTsconfig.compilerOptions?.rootDir
|
|
30
|
-
// ? path.join(resolvePath, projectTsconfig.compilerOptions?.rootDir)
|
|
31
|
-
// : resolvePath;
|
|
32
|
-
// 目前限制 rootDir 的路径为 sourceDir
|
|
33
|
-
|
|
34
|
-
const rootDir = path.join(resolvePath, _sourceDir);
|
|
35
|
-
const baseUrl = (_projectTsconfig$comp = projectTsconfig.compilerOptions) !== null && _projectTsconfig$comp !== void 0 && _projectTsconfig$comp.baseUrl ? path.join(appDirectory, (_projectTsconfig$comp2 = projectTsconfig.compilerOptions) === null || _projectTsconfig$comp2 === void 0 ? void 0 : _projectTsconfig$comp2.baseUrl) : appDirectory; // if include = ['src'], final include should be ['../src']
|
|
36
|
-
|
|
37
|
-
const include = (_projectTsconfig$incl = projectTsconfig.include) === null || _projectTsconfig$incl === void 0 ? void 0 : _projectTsconfig$incl.map(includePath => path.join(resolvePath, includePath));
|
|
38
|
-
const exclude = (_projectTsconfig$excl = projectTsconfig.exclude) === null || _projectTsconfig$excl === void 0 ? void 0 : _projectTsconfig$excl.map(excludePath => path.join(resolvePath, excludePath));
|
|
39
|
-
const resetConfig = {
|
|
40
|
-
compilerOptions: {
|
|
41
|
-
rootDir,
|
|
42
|
-
baseUrl,
|
|
43
|
-
// Ensure that .d.ts files are created by tsc, but not .js files
|
|
44
|
-
declaration: true,
|
|
45
|
-
emitDeclarationOnly: true,
|
|
46
|
-
outDir: distDir
|
|
47
|
-
},
|
|
48
|
-
include,
|
|
49
|
-
exclude
|
|
50
|
-
};
|
|
51
|
-
const recommendOption = {
|
|
52
|
-
// Ensure that Babel can safely transpile files in the TypeScript project
|
|
53
|
-
compilerOptions: {
|
|
54
|
-
isolatedModules: true
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const tempTsconfigPath = path.join(tempPath, constants.tempTsconfigName);
|
|
58
|
-
fs.ensureFileSync(tempTsconfigPath);
|
|
59
|
-
fs.writeJSONSync(tempTsconfigPath, deepMerge(recommendOption, projectTsconfig, // 此处是必须要覆盖用户默认配置
|
|
60
|
-
resetConfig));
|
|
61
|
-
return tempTsconfigPath;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const getProjectTsconfig = tsconfigPath => {
|
|
65
|
-
if (!tsconfigPath || !fs.existsSync(tsconfigPath)) {
|
|
66
|
-
return {};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return JSON5.parse(fs.readFileSync(tsconfigPath, 'utf-8'));
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const resolveLog = (childProgress, {
|
|
73
|
-
tsCheck: _tsCheck = false,
|
|
74
|
-
watch: _watch = false
|
|
75
|
-
} = {}) => {
|
|
76
|
-
var _childProgress$stdout, _childProgress$stdout2, _childProgress$stderr;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* tsc 所有的log信息都是从stdout data 事件中获取
|
|
80
|
-
* 正常模式下,如果有报错信息,交给 resolveLog 后面的逻辑来处理
|
|
81
|
-
* watch 模式下,则使用这里的信息
|
|
82
|
-
*/
|
|
83
|
-
(_childProgress$stdout = childProgress.stdout) === null || _childProgress$stdout === void 0 ? void 0 : _childProgress$stdout.on('data', data => {
|
|
84
|
-
if (!_tsCheck) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (_watch) {
|
|
89
|
-
console.info(data.toString());
|
|
90
|
-
}
|
|
91
|
-
}); // 正常以下内容都不会触发,因为tsc 不会产生以下类型的log信息,不过防止意外情况
|
|
92
|
-
|
|
93
|
-
(_childProgress$stdout2 = childProgress.stdout) === null || _childProgress$stdout2 === void 0 ? void 0 : _childProgress$stdout2.on('error', error => {
|
|
94
|
-
console.error(error.message);
|
|
95
|
-
});
|
|
96
|
-
(_childProgress$stderr = childProgress.stderr) === null || _childProgress$stderr === void 0 ? void 0 : _childProgress$stderr.on('data', chunk => {
|
|
97
|
-
console.error(chunk.toString());
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const generatorDts = async (_, config) => {
|
|
102
|
-
const {
|
|
103
|
-
tsconfigPath,
|
|
104
|
-
distDir,
|
|
105
|
-
sourceDirName = 'src',
|
|
106
|
-
projectData: {
|
|
107
|
-
appDirectory
|
|
108
|
-
},
|
|
109
|
-
tsCheck = false,
|
|
110
|
-
watch = false
|
|
111
|
-
} = config;
|
|
112
|
-
const userTsconfig = getProjectTsconfig(tsconfigPath);
|
|
113
|
-
const willDeleteTsconfigPath = generatorTsConfig(userTsconfig, {
|
|
114
|
-
appDirectory,
|
|
115
|
-
distDir,
|
|
116
|
-
sourceDir: sourceDirName
|
|
117
|
-
});
|
|
118
|
-
removeTsconfigPath = willDeleteTsconfigPath;
|
|
119
|
-
const tscBinFile = path.join(appDirectory, './node_modules/.bin/tsc');
|
|
120
|
-
const watchParams = watch ? ['-w'] : [];
|
|
121
|
-
const childProgress = execa(tscBinFile, ['-p', willDeleteTsconfigPath, ...watchParams], {
|
|
122
|
-
stdio: 'pipe',
|
|
123
|
-
cwd: appDirectory
|
|
124
|
-
});
|
|
125
|
-
resolveLog(childProgress, {
|
|
126
|
-
tsCheck,
|
|
127
|
-
watch
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
try {
|
|
131
|
-
await childProgress;
|
|
132
|
-
console.info('[Tsc Compiler]: Successfully');
|
|
133
|
-
} catch (e) {
|
|
134
|
-
if (!tsCheck) {
|
|
135
|
-
console.warn(`There are some type issues, which can be checked by configuring 'source.enableTsChecker = true' ${os.EOL} in modern.config.js`);
|
|
136
|
-
} else {
|
|
137
|
-
const isRecord = input => typeof input === 'object'; // 通过使用 execa,可以将tsc 的 data 类型的报错信息变为异常错误信息
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (isRecord(e)) {
|
|
141
|
-
console.error(e.stdout);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
fs.removeSync(willDeleteTsconfigPath);
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
const resolveAlias = (modernConfig, config, watchFilenames = []) => {
|
|
150
|
-
const {
|
|
151
|
-
output
|
|
152
|
-
} = modernConfig;
|
|
153
|
-
const defaultPaths = {
|
|
154
|
-
'@': ['./src']
|
|
155
|
-
};
|
|
156
|
-
const dtsDistPath = `${config.distDir}/**/*.d.ts`;
|
|
157
|
-
const dtsFilenames = watchFilenames.length > 0 ? watchFilenames : glob.sync(dtsDistPath, {
|
|
158
|
-
absolute: true
|
|
159
|
-
});
|
|
160
|
-
const alias = babel.getFinalAlias(modernConfig, {
|
|
161
|
-
appDirectory: config.projectData.appDirectory,
|
|
162
|
-
tsconfigPath: config.tsconfigPath || path.join(config.projectData.appDirectory, './tsconfig.json'),
|
|
163
|
-
sourceAbsDir: config.distDir
|
|
164
|
-
});
|
|
165
|
-
const mergedPaths = alias.isTsPath ? alias.paths || {} : _objectSpread(_objectSpread({}, defaultPaths), alias.paths || {});
|
|
166
|
-
const result = tsPathsTransform.transformDtsAlias({
|
|
167
|
-
filenames: dtsFilenames,
|
|
168
|
-
baseUrl: path.join(config.projectData.appDirectory, output.path || 'dist'),
|
|
169
|
-
paths: mergedPaths
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
for (const r of result) {
|
|
173
|
-
fs.writeFileSync(r.path, r.content);
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
const taskMain = async ({
|
|
178
|
-
modernConfig
|
|
179
|
-
}) => {
|
|
180
|
-
const processArgv = argv(process.argv.slice(2));
|
|
181
|
-
const config = processArgv({
|
|
182
|
-
appDirectory: process.cwd(),
|
|
183
|
-
srcDir: 'src',
|
|
184
|
-
distDir: 'dist/types',
|
|
185
|
-
tsconfigPath: './tsconfig.json',
|
|
186
|
-
sourceDirName: 'src'
|
|
187
|
-
});
|
|
188
|
-
const option = {
|
|
189
|
-
srcDir: config.srcDir,
|
|
190
|
-
distDir: config.distDir,
|
|
191
|
-
projectData: {
|
|
192
|
-
appDirectory: config.appDirectory
|
|
193
|
-
},
|
|
194
|
-
tsconfigPath: config.tsconfigPath,
|
|
195
|
-
watch: config.watch,
|
|
196
|
-
tsCheck: config.tsCheck,
|
|
197
|
-
sourceDirName: config.sourceDirName
|
|
198
|
-
};
|
|
199
|
-
await generatorDts(modernConfig, option); // TODO: watch 模式下无法转换
|
|
200
|
-
|
|
201
|
-
resolveAlias(modernConfig, option);
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
(async () => {
|
|
205
|
-
let options;
|
|
206
|
-
|
|
207
|
-
if (process.env.CORE_INIT_OPTION_FILE) {
|
|
208
|
-
({
|
|
209
|
-
options
|
|
210
|
-
} = require(process.env.CORE_INIT_OPTION_FILE));
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const {
|
|
214
|
-
resolved
|
|
215
|
-
} = await core.cli.init([], options);
|
|
216
|
-
await core.manager.run(async () => {
|
|
217
|
-
try {
|
|
218
|
-
await taskMain({
|
|
219
|
-
modernConfig: resolved
|
|
220
|
-
});
|
|
221
|
-
} catch (e) {
|
|
222
|
-
console.error(e.message);
|
|
223
|
-
fs.removeSync(removeTsconfigPath);
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
})();
|