@modern-js/module-tools 1.4.3 → 1.4.4
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/dist/js/modern/hooks/build.js +20 -0
- package/dist/js/modern/hooks/dev.js +11 -0
- package/dist/js/modern/hooks/index.js +14 -0
- package/dist/js/modern/index.js +1 -1
- package/dist/js/modern/tasks/build-style.js +1 -1
- package/dist/js/modern/tasks/build-watch-style.js +1 -1
- package/dist/js/modern/tasks/generator-dts/index.js +8 -10
- package/dist/js/modern/tasks/generator-dts/utils.js +9 -0
- package/dist/js/modern/utils/babel.js +2 -19
- package/dist/js/node/hooks/build.js +37 -0
- package/dist/js/node/hooks/dev.js +25 -0
- package/dist/js/node/hooks/index.js +39 -0
- package/dist/js/node/index.js +2 -2
- package/dist/js/node/tasks/build-style.js +1 -1
- package/dist/js/node/tasks/build-watch-style.js +1 -1
- package/dist/js/node/tasks/generator-dts/index.js +7 -13
- package/dist/js/node/tasks/generator-dts/utils.js +14 -2
- package/dist/js/node/utils/babel.js +1 -18
- package/dist/types/hooks/build.d.ts +46 -0
- package/dist/types/hooks/dev.d.ts +18 -0
- package/dist/types/hooks/index.d.ts +26 -0
- package/dist/types/tasks/generator-dts/utils.d.ts +2 -1
- package/dist/types/utils/babel.d.ts +1 -2
- package/jest.config.js +0 -3
- package/package.json +16 -13
- package/tests/generate-dts.test.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @modern-js/module-tools
|
|
2
2
|
|
|
3
|
+
## 1.4.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 12b4dd41: fix: throw error when tsc is not installed
|
|
8
|
+
- 132f7b53: feat: move config declarations to @modern-js/core
|
|
9
|
+
- 8491b6dd: fix: optimise "types" exports from plugin
|
|
10
|
+
- 133a5dd7: remove module hooks dep
|
|
11
|
+
- 9d4a005b: fix: config babel via tools.babel
|
|
12
|
+
- Updated dependencies [bebb39b6]
|
|
13
|
+
- Updated dependencies [ef28a4e6]
|
|
14
|
+
- Updated dependencies [132f7b53]
|
|
15
|
+
- Updated dependencies [ff73a5cc]
|
|
16
|
+
- Updated dependencies [9d4a005b]
|
|
17
|
+
- @modern-js/css-config@1.2.3
|
|
18
|
+
- @modern-js/plugin-analyze@1.3.5
|
|
19
|
+
- @modern-js/plugin-changeset@1.2.4
|
|
20
|
+
- @modern-js/plugin-fast-refresh@1.2.3
|
|
21
|
+
- @modern-js/core@1.6.1
|
|
22
|
+
- @modern-js/utils@1.3.7
|
|
23
|
+
|
|
3
24
|
## 1.4.3
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createParallelWorkflow, createAsyncPipeline } from '@modern-js/plugin';
|
|
2
|
+
import { registerHook } from '@modern-js/core';
|
|
3
|
+
export const platformBuild = createParallelWorkflow();
|
|
4
|
+
export const moduleLessConfig = createAsyncPipeline();
|
|
5
|
+
export const moduleSassConfig = createAsyncPipeline();
|
|
6
|
+
export const moduleTailwindConfig = createAsyncPipeline();
|
|
7
|
+
export const buildHooks = {
|
|
8
|
+
platformBuild,
|
|
9
|
+
moduleLessConfig,
|
|
10
|
+
moduleSassConfig,
|
|
11
|
+
moduleTailwindConfig
|
|
12
|
+
};
|
|
13
|
+
export const lifecycle = () => {
|
|
14
|
+
registerHook({
|
|
15
|
+
moduleLessConfig,
|
|
16
|
+
moduleSassConfig,
|
|
17
|
+
moduleTailwindConfig,
|
|
18
|
+
platformBuild
|
|
19
|
+
});
|
|
20
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createParallelWorkflow } from '@modern-js/plugin';
|
|
2
|
+
import { registerHook } from '@modern-js/core';
|
|
3
|
+
export const moduleToolsMenu = createParallelWorkflow();
|
|
4
|
+
export const devHooks = {
|
|
5
|
+
moduleToolsMenu
|
|
6
|
+
};
|
|
7
|
+
export const lifecycle = () => {
|
|
8
|
+
registerHook({
|
|
9
|
+
moduleToolsMenu
|
|
10
|
+
});
|
|
11
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { buildHooks, lifecycle as buildLifeCycle } from "./build";
|
|
8
|
+
import { devHooks, lifecycle as devLifeCycle } from "./dev";
|
|
9
|
+
export { buildLifeCycle, devLifeCycle };
|
|
10
|
+
export const lifecycle = () => {
|
|
11
|
+
devLifeCycle();
|
|
12
|
+
buildLifeCycle();
|
|
13
|
+
};
|
|
14
|
+
export const hooks = _objectSpread(_objectSpread({}, buildHooks), devHooks);
|
package/dist/js/modern/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Import } from '@modern-js/utils';
|
|
2
2
|
import ChangesetPlugin from '@modern-js/plugin-changeset';
|
|
3
3
|
import AnalyzePlugin from '@modern-js/plugin-analyze';
|
|
4
|
-
import { hooks } from
|
|
4
|
+
import { hooks } from "./hooks";
|
|
5
5
|
const cli = Import.lazy('./cli', require);
|
|
6
6
|
const local = Import.lazy('./locale', require);
|
|
7
7
|
const schema = Import.lazy('./schema', require);
|
|
@@ -4,7 +4,7 @@ const cssConfig = Import.lazy('@modern-js/css-config', require);
|
|
|
4
4
|
const core = Import.lazy('@modern-js/core', require);
|
|
5
5
|
const compiler = Import.lazy('@modern-js/style-compiler', require);
|
|
6
6
|
const glob = Import.lazy('glob', require);
|
|
7
|
-
const hooks = Import.lazy('
|
|
7
|
+
const hooks = Import.lazy('../hooks', require);
|
|
8
8
|
const STYLE_DIRS = 'styles';
|
|
9
9
|
const SRC_STYLE_DIRS = 'src';
|
|
10
10
|
|
|
@@ -3,7 +3,7 @@ import * as path from 'path';
|
|
|
3
3
|
import { fs, watch, WatchChangeType, Import } from '@modern-js/utils';
|
|
4
4
|
const logger = Import.lazy('../features/build/logger', require);
|
|
5
5
|
const cssConfig = Import.lazy('@modern-js/css-config', require);
|
|
6
|
-
const hooks = Import.lazy('
|
|
6
|
+
const hooks = Import.lazy('../hooks', require);
|
|
7
7
|
const core = Import.lazy('@modern-js/core', require);
|
|
8
8
|
const compiler = Import.lazy('@modern-js/style-compiler', require);
|
|
9
9
|
const glob = Import.lazy('glob', require);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { Import, fs, isObject } from '@modern-js/utils';
|
|
2
|
+
import { getTscBinPath } from "./utils";
|
|
3
3
|
const core = Import.lazy('@modern-js/core', require);
|
|
4
4
|
const execa = Import.lazy('execa', require);
|
|
5
5
|
const JSON5 = Import.lazy('json5', require);
|
|
@@ -62,7 +62,7 @@ const generatorDts = async (_, config) => {
|
|
|
62
62
|
sourceDir: sourceDirName
|
|
63
63
|
});
|
|
64
64
|
removeTsconfigPath = willDeleteTsconfigPath;
|
|
65
|
-
const tscBinFile =
|
|
65
|
+
const tscBinFile = getTscBinPath(appDirectory);
|
|
66
66
|
const watchParams = watch ? ['-w'] : [];
|
|
67
67
|
const childProgress = execa(tscBinFile, ['-p', willDeleteTsconfigPath, ...watchParams], {
|
|
68
68
|
stdio: 'pipe',
|
|
@@ -75,17 +75,15 @@ const generatorDts = async (_, config) => {
|
|
|
75
75
|
|
|
76
76
|
try {
|
|
77
77
|
await childProgress;
|
|
78
|
-
console.info('[
|
|
78
|
+
console.info('[TSC Compiler]: Successfully');
|
|
79
79
|
} catch (e) {
|
|
80
80
|
if (!tsCheck) {
|
|
81
81
|
console.info(`There are some type warnings, which can be checked by configuring 'output.disableTsChecker = false'`);
|
|
82
|
+
} // 通过使用 execa,可以将 tsc 的 data 类型的报错信息变为异常错误信息
|
|
83
|
+
else if (isObject(e) && e.stdout) {
|
|
84
|
+
console.error(e.stdout);
|
|
82
85
|
} else {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (isRecord(e)) {
|
|
87
|
-
console.error(e.stdout);
|
|
88
|
-
}
|
|
86
|
+
console.error(e);
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
89
|
|
|
@@ -79,4 +79,13 @@ export const resolveAlias = (modernConfig, config, watchFilenames = []) => {
|
|
|
79
79
|
for (const r of result) {
|
|
80
80
|
fs.writeFileSync(r.path, r.content);
|
|
81
81
|
}
|
|
82
|
+
};
|
|
83
|
+
export const getTscBinPath = appDirectory => {
|
|
84
|
+
const tscBinFile = path.join(appDirectory, './node_modules/.bin/tsc');
|
|
85
|
+
|
|
86
|
+
if (!fs.existsSync(tscBinFile)) {
|
|
87
|
+
throw new Error('Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return tscBinFile;
|
|
82
91
|
};
|
|
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
|
|
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
|
-
import { getBabelConfig
|
|
7
|
+
import { getBabelConfig } from '@modern-js/babel-preset-module';
|
|
8
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); // 排除内部别名,因为不需要处理
|
|
@@ -72,23 +72,6 @@ export const resolveBabelConfig = (appDirectory, modernConfig, option) => {
|
|
|
72
72
|
}); // Preventing warning when files are too large
|
|
73
73
|
|
|
74
74
|
internalBabelConfig.compact = false;
|
|
75
|
-
const babelChain = getModuleBabelChain({
|
|
76
|
-
appDirectory,
|
|
77
|
-
enableReactPreset: true,
|
|
78
|
-
enableTypescriptPreset: true,
|
|
79
|
-
alias: aliasConfig,
|
|
80
|
-
envVars,
|
|
81
|
-
globalVars,
|
|
82
|
-
lodashOptions,
|
|
83
|
-
jsxTransformRuntime,
|
|
84
|
-
importStyle
|
|
85
|
-
}, {
|
|
86
|
-
type: option.type,
|
|
87
|
-
syntax: option.syntax
|
|
88
|
-
});
|
|
89
75
|
const userBabelConfig = modernConfig.tools.babel;
|
|
90
|
-
return applyOptionsChain(internalBabelConfig,
|
|
91
|
-
userBabelConfig, {
|
|
92
|
-
chain: babelChain
|
|
93
|
-
});
|
|
76
|
+
return applyOptionsChain(internalBabelConfig, userBabelConfig);
|
|
94
77
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.platformBuild = exports.moduleTailwindConfig = exports.moduleSassConfig = exports.moduleLessConfig = exports.lifecycle = exports.buildHooks = void 0;
|
|
7
|
+
|
|
8
|
+
var _plugin = require("@modern-js/plugin");
|
|
9
|
+
|
|
10
|
+
var _core = require("@modern-js/core");
|
|
11
|
+
|
|
12
|
+
const platformBuild = (0, _plugin.createParallelWorkflow)();
|
|
13
|
+
exports.platformBuild = platformBuild;
|
|
14
|
+
const moduleLessConfig = (0, _plugin.createAsyncPipeline)();
|
|
15
|
+
exports.moduleLessConfig = moduleLessConfig;
|
|
16
|
+
const moduleSassConfig = (0, _plugin.createAsyncPipeline)();
|
|
17
|
+
exports.moduleSassConfig = moduleSassConfig;
|
|
18
|
+
const moduleTailwindConfig = (0, _plugin.createAsyncPipeline)();
|
|
19
|
+
exports.moduleTailwindConfig = moduleTailwindConfig;
|
|
20
|
+
const buildHooks = {
|
|
21
|
+
platformBuild,
|
|
22
|
+
moduleLessConfig,
|
|
23
|
+
moduleSassConfig,
|
|
24
|
+
moduleTailwindConfig
|
|
25
|
+
};
|
|
26
|
+
exports.buildHooks = buildHooks;
|
|
27
|
+
|
|
28
|
+
const lifecycle = () => {
|
|
29
|
+
(0, _core.registerHook)({
|
|
30
|
+
moduleLessConfig,
|
|
31
|
+
moduleSassConfig,
|
|
32
|
+
moduleTailwindConfig,
|
|
33
|
+
platformBuild
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
exports.lifecycle = lifecycle;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.moduleToolsMenu = exports.lifecycle = exports.devHooks = void 0;
|
|
7
|
+
|
|
8
|
+
var _plugin = require("@modern-js/plugin");
|
|
9
|
+
|
|
10
|
+
var _core = require("@modern-js/core");
|
|
11
|
+
|
|
12
|
+
const moduleToolsMenu = (0, _plugin.createParallelWorkflow)();
|
|
13
|
+
exports.moduleToolsMenu = moduleToolsMenu;
|
|
14
|
+
const devHooks = {
|
|
15
|
+
moduleToolsMenu
|
|
16
|
+
};
|
|
17
|
+
exports.devHooks = devHooks;
|
|
18
|
+
|
|
19
|
+
const lifecycle = () => {
|
|
20
|
+
(0, _core.registerHook)({
|
|
21
|
+
moduleToolsMenu
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.lifecycle = lifecycle;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "buildLifeCycle", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _build.lifecycle;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "devLifeCycle", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _dev.lifecycle;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
exports.lifecycle = exports.hooks = void 0;
|
|
19
|
+
|
|
20
|
+
var _build = require("./build");
|
|
21
|
+
|
|
22
|
+
var _dev = require("./dev");
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
const lifecycle = () => {
|
|
31
|
+
(0, _dev.lifecycle)();
|
|
32
|
+
(0, _build.lifecycle)();
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.lifecycle = lifecycle;
|
|
36
|
+
|
|
37
|
+
const hooks = _objectSpread(_objectSpread({}, _build.buildHooks), _dev.devHooks);
|
|
38
|
+
|
|
39
|
+
exports.hooks = hooks;
|
package/dist/js/node/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var _pluginChangeset = _interopRequireDefault(require("@modern-js/plugin-changes
|
|
|
17
17
|
|
|
18
18
|
var _pluginAnalyze = _interopRequireDefault(require("@modern-js/plugin-analyze"));
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _hooks = require("./hooks");
|
|
21
21
|
|
|
22
22
|
var _core = require("@modern-js/core");
|
|
23
23
|
|
|
@@ -34,7 +34,7 @@ const lang = _utils.Import.lazy('./utils/language', require);
|
|
|
34
34
|
var _default = () => ({
|
|
35
35
|
name: '@modern-js/module-tools',
|
|
36
36
|
post: ['@modern-js/plugin-analyze', '@modern-js/plugin-changeset'],
|
|
37
|
-
registerHook:
|
|
37
|
+
registerHook: _hooks.hooks,
|
|
38
38
|
usePlugins: [(0, _pluginChangeset.default)(), (0, _pluginAnalyze.default)()],
|
|
39
39
|
setup: api => {
|
|
40
40
|
const locale = lang.getLocaleLanguage();
|
|
@@ -16,7 +16,7 @@ const compiler = _utils.Import.lazy('@modern-js/style-compiler', require);
|
|
|
16
16
|
|
|
17
17
|
const glob = _utils.Import.lazy('glob', require);
|
|
18
18
|
|
|
19
|
-
const hooks = _utils.Import.lazy('
|
|
19
|
+
const hooks = _utils.Import.lazy('../hooks', require);
|
|
20
20
|
|
|
21
21
|
const STYLE_DIRS = 'styles';
|
|
22
22
|
const SRC_STYLE_DIRS = 'src';
|
|
@@ -13,7 +13,7 @@ const logger = _utils.Import.lazy('../features/build/logger', require);
|
|
|
13
13
|
|
|
14
14
|
const cssConfig = _utils.Import.lazy('@modern-js/css-config', require);
|
|
15
15
|
|
|
16
|
-
const hooks = _utils.Import.lazy('
|
|
16
|
+
const hooks = _utils.Import.lazy('../hooks', require);
|
|
17
17
|
|
|
18
18
|
const core = _utils.Import.lazy('@modern-js/core', require);
|
|
19
19
|
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var path = _interopRequireWildcard(require("path"));
|
|
4
|
-
|
|
5
3
|
var _utils = require("@modern-js/utils");
|
|
6
4
|
|
|
7
|
-
|
|
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; }
|
|
5
|
+
var _utils2 = require("./utils");
|
|
10
6
|
|
|
11
7
|
const core = _utils.Import.lazy('@modern-js/core', require);
|
|
12
8
|
|
|
@@ -75,7 +71,7 @@ const generatorDts = async (_, config) => {
|
|
|
75
71
|
sourceDir: sourceDirName
|
|
76
72
|
});
|
|
77
73
|
removeTsconfigPath = willDeleteTsconfigPath;
|
|
78
|
-
const tscBinFile =
|
|
74
|
+
const tscBinFile = (0, _utils2.getTscBinPath)(appDirectory);
|
|
79
75
|
const watchParams = watch ? ['-w'] : [];
|
|
80
76
|
const childProgress = execa(tscBinFile, ['-p', willDeleteTsconfigPath, ...watchParams], {
|
|
81
77
|
stdio: 'pipe',
|
|
@@ -88,17 +84,15 @@ const generatorDts = async (_, config) => {
|
|
|
88
84
|
|
|
89
85
|
try {
|
|
90
86
|
await childProgress;
|
|
91
|
-
console.info('[
|
|
87
|
+
console.info('[TSC Compiler]: Successfully');
|
|
92
88
|
} catch (e) {
|
|
93
89
|
if (!tsCheck) {
|
|
94
90
|
console.info(`There are some type warnings, which can be checked by configuring 'output.disableTsChecker = false'`);
|
|
91
|
+
} // 通过使用 execa,可以将 tsc 的 data 类型的报错信息变为异常错误信息
|
|
92
|
+
else if ((0, _utils.isObject)(e) && e.stdout) {
|
|
93
|
+
console.error(e.stdout);
|
|
95
94
|
} else {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (isRecord(e)) {
|
|
100
|
-
console.error(e.stdout);
|
|
101
|
-
}
|
|
95
|
+
console.error(e);
|
|
102
96
|
}
|
|
103
97
|
}
|
|
104
98
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.resolveAlias = exports.generatorTsConfig = void 0;
|
|
6
|
+
exports.resolveAlias = exports.getTscBinPath = exports.generatorTsConfig = void 0;
|
|
7
7
|
|
|
8
8
|
var path = _interopRequireWildcard(require("path"));
|
|
9
9
|
|
|
@@ -105,4 +105,16 @@ const resolveAlias = (modernConfig, config, watchFilenames = []) => {
|
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
exports.resolveAlias = resolveAlias;
|
|
108
|
+
exports.resolveAlias = resolveAlias;
|
|
109
|
+
|
|
110
|
+
const getTscBinPath = appDirectory => {
|
|
111
|
+
const tscBinFile = path.join(appDirectory, './node_modules/.bin/tsc');
|
|
112
|
+
|
|
113
|
+
if (!_utils.fs.existsSync(tscBinFile)) {
|
|
114
|
+
throw new Error('Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return tscBinFile;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
exports.getTscBinPath = getTscBinPath;
|
|
@@ -84,25 +84,8 @@ const resolveBabelConfig = (appDirectory, modernConfig, option) => {
|
|
|
84
84
|
}); // Preventing warning when files are too large
|
|
85
85
|
|
|
86
86
|
internalBabelConfig.compact = false;
|
|
87
|
-
const babelChain = (0, _babelPresetModule.getModuleBabelChain)({
|
|
88
|
-
appDirectory,
|
|
89
|
-
enableReactPreset: true,
|
|
90
|
-
enableTypescriptPreset: true,
|
|
91
|
-
alias: aliasConfig,
|
|
92
|
-
envVars,
|
|
93
|
-
globalVars,
|
|
94
|
-
lodashOptions,
|
|
95
|
-
jsxTransformRuntime,
|
|
96
|
-
importStyle
|
|
97
|
-
}, {
|
|
98
|
-
type: option.type,
|
|
99
|
-
syntax: option.syntax
|
|
100
|
-
});
|
|
101
87
|
const userBabelConfig = modernConfig.tools.babel;
|
|
102
|
-
return (0, _utils.applyOptionsChain)(internalBabelConfig,
|
|
103
|
-
userBabelConfig, {
|
|
104
|
-
chain: babelChain
|
|
105
|
-
});
|
|
88
|
+
return (0, _utils.applyOptionsChain)(internalBabelConfig, userBabelConfig);
|
|
106
89
|
};
|
|
107
90
|
|
|
108
91
|
exports.resolveBabelConfig = resolveBabelConfig;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { NormalizedConfig } from '@modern-js/core';
|
|
2
|
+
import { LessOption, SassOptions } from '@modern-js/style-compiler';
|
|
3
|
+
export interface PlatformBuildOption {
|
|
4
|
+
isTsProject: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const platformBuild: import("@modern-js/plugin").ParallelWorkflow<PlatformBuildOption, {
|
|
7
|
+
name: string;
|
|
8
|
+
title: string;
|
|
9
|
+
taskPath: string;
|
|
10
|
+
params: string[];
|
|
11
|
+
}>;
|
|
12
|
+
export declare const moduleLessConfig: import("@modern-js/plugin").AsyncPipeline<{
|
|
13
|
+
modernConfig: NormalizedConfig;
|
|
14
|
+
}, LessOption | undefined>;
|
|
15
|
+
export declare const moduleSassConfig: import("@modern-js/plugin").AsyncPipeline<{
|
|
16
|
+
modernConfig: NormalizedConfig;
|
|
17
|
+
}, SassOptions<"sync"> | undefined>;
|
|
18
|
+
export declare const moduleTailwindConfig: import("@modern-js/plugin").AsyncPipeline<{
|
|
19
|
+
modernConfig: NormalizedConfig;
|
|
20
|
+
}, any>;
|
|
21
|
+
export declare const buildHooks: {
|
|
22
|
+
platformBuild: import("@modern-js/plugin").ParallelWorkflow<PlatformBuildOption, {
|
|
23
|
+
name: string;
|
|
24
|
+
title: string;
|
|
25
|
+
taskPath: string;
|
|
26
|
+
params: string[];
|
|
27
|
+
}>;
|
|
28
|
+
moduleLessConfig: import("@modern-js/plugin").AsyncPipeline<{
|
|
29
|
+
modernConfig: NormalizedConfig;
|
|
30
|
+
}, LessOption | undefined>;
|
|
31
|
+
moduleSassConfig: import("@modern-js/plugin").AsyncPipeline<{
|
|
32
|
+
modernConfig: NormalizedConfig;
|
|
33
|
+
}, SassOptions<"sync"> | undefined>;
|
|
34
|
+
moduleTailwindConfig: import("@modern-js/plugin").AsyncPipeline<{
|
|
35
|
+
modernConfig: NormalizedConfig;
|
|
36
|
+
}, any>;
|
|
37
|
+
};
|
|
38
|
+
export declare const lifecycle: () => void;
|
|
39
|
+
declare module '@modern-js/core' {
|
|
40
|
+
interface Hooks {
|
|
41
|
+
platformBuild: typeof platformBuild;
|
|
42
|
+
moduleLessConfig: typeof moduleLessConfig;
|
|
43
|
+
moduleSassConfig: typeof moduleSassConfig;
|
|
44
|
+
moduleTailwindConfig: typeof moduleTailwindConfig;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const moduleToolsMenu: import("@modern-js/plugin").ParallelWorkflow<undefined, {
|
|
2
|
+
name: string;
|
|
3
|
+
value: string;
|
|
4
|
+
runTask: (p: any) => void | Promise<void>;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const devHooks: {
|
|
7
|
+
moduleToolsMenu: import("@modern-js/plugin").ParallelWorkflow<undefined, {
|
|
8
|
+
name: string;
|
|
9
|
+
value: string;
|
|
10
|
+
runTask: (p: any) => void | Promise<void>;
|
|
11
|
+
}>;
|
|
12
|
+
};
|
|
13
|
+
export declare const lifecycle: () => void;
|
|
14
|
+
declare module '@modern-js/core' {
|
|
15
|
+
interface Hooks {
|
|
16
|
+
moduleToolsMenu: typeof moduleToolsMenu;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { lifecycle as buildLifeCycle } from './build';
|
|
2
|
+
import { lifecycle as devLifeCycle } from './dev';
|
|
3
|
+
export { buildLifeCycle, devLifeCycle };
|
|
4
|
+
export declare const lifecycle: () => void;
|
|
5
|
+
export declare const hooks: {
|
|
6
|
+
moduleToolsMenu: import("@modern-js/plugin").ParallelWorkflow<undefined, {
|
|
7
|
+
name: string;
|
|
8
|
+
value: string;
|
|
9
|
+
runTask: (p: any) => void | Promise<void>;
|
|
10
|
+
}>;
|
|
11
|
+
platformBuild: import("@modern-js/plugin").ParallelWorkflow<import("./build").PlatformBuildOption, {
|
|
12
|
+
name: string;
|
|
13
|
+
title: string;
|
|
14
|
+
taskPath: string;
|
|
15
|
+
params: string[];
|
|
16
|
+
}>;
|
|
17
|
+
moduleLessConfig: import("@modern-js/plugin").AsyncPipeline<{
|
|
18
|
+
modernConfig: import("@modern-js/core").NormalizedConfig;
|
|
19
|
+
}, import("@modern-js/style-compiler").LessOption | undefined>;
|
|
20
|
+
moduleSassConfig: import("@modern-js/plugin").AsyncPipeline<{
|
|
21
|
+
modernConfig: import("@modern-js/core").NormalizedConfig;
|
|
22
|
+
}, import("@modern-js/style-compiler").SassOptions<"sync"> | undefined>;
|
|
23
|
+
moduleTailwindConfig: import("@modern-js/plugin").AsyncPipeline<{
|
|
24
|
+
modernConfig: import("@modern-js/core").NormalizedConfig;
|
|
25
|
+
}, any>;
|
|
26
|
+
};
|
|
@@ -20,4 +20,5 @@ export declare const generatorTsConfig: (projectTsconfig: ITsconfig, {
|
|
|
20
20
|
distDir: string;
|
|
21
21
|
sourceDir?: string | undefined;
|
|
22
22
|
}) => string;
|
|
23
|
-
export declare const resolveAlias: (modernConfig: NormalizedConfig, config: IGeneratorConfig, watchFilenames?: string[]) => void;
|
|
23
|
+
export declare const resolveAlias: (modernConfig: NormalizedConfig, config: IGeneratorConfig, watchFilenames?: string[]) => void;
|
|
24
|
+
export declare const getTscBinPath: (appDirectory: string) => string;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { TransformOptions } from '@babel/core';
|
|
2
1
|
import { NormalizedConfig } from '@modern-js/core';
|
|
3
2
|
import { IPackageModeValue } from '../types';
|
|
4
3
|
export declare const getFinalAlias: any;
|
|
5
4
|
export declare const resolveBabelConfig: (appDirectory: string, modernConfig: NormalizedConfig, option: Pick<IPackageModeValue, 'syntax' | 'type'> & {
|
|
6
5
|
sourceAbsDir: string;
|
|
7
6
|
tsconfigPath: string;
|
|
8
|
-
}) => TransformOptions;
|
|
7
|
+
}) => import("@modern-js/core").TransformOptions;
|
package/jest.config.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
const sharedConfig = require('@scripts/jest-config');
|
|
2
2
|
|
|
3
|
-
console.info(sharedConfig.coveragePathIgnorePatterns);
|
|
4
|
-
|
|
5
3
|
/** @type {import('@jest/types').Config.InitialOptions} */
|
|
6
4
|
module.exports = {
|
|
7
|
-
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
|
8
5
|
...sharedConfig,
|
|
9
6
|
rootDir: __dirname,
|
|
10
7
|
};
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.4.
|
|
14
|
+
"version": "1.4.4",
|
|
15
15
|
"bin": {
|
|
16
16
|
"modern": "./bin/modern.js"
|
|
17
17
|
},
|
|
@@ -40,13 +40,15 @@
|
|
|
40
40
|
},
|
|
41
41
|
"typesVersions": {
|
|
42
42
|
"*": {
|
|
43
|
+
"types": [
|
|
44
|
+
"./lib/types.d.ts"
|
|
45
|
+
],
|
|
43
46
|
"type": [
|
|
44
47
|
"./lib/types.d.ts"
|
|
45
48
|
]
|
|
46
49
|
}
|
|
47
50
|
},
|
|
48
51
|
"dependencies": {
|
|
49
|
-
"@modern-js/core": "^1.6.0",
|
|
50
52
|
"@babel/generator": "^7.15.0",
|
|
51
53
|
"@babel/parser": "^7.15.2",
|
|
52
54
|
"@babel/runtime": "^7",
|
|
@@ -54,16 +56,17 @@
|
|
|
54
56
|
"@babel/types": "^7.17.0",
|
|
55
57
|
"@modern-js/babel-compiler": "^1.2.2",
|
|
56
58
|
"@modern-js/babel-preset-module": "^1.3.1",
|
|
57
|
-
"@modern-js/
|
|
59
|
+
"@modern-js/core": "^1.6.1",
|
|
60
|
+
"@modern-js/css-config": "^1.2.3",
|
|
58
61
|
"@modern-js/i18n-cli-language-detector": "^1.2.1",
|
|
59
|
-
"@modern-js/module-tools-hooks": "^1.2.3",
|
|
60
62
|
"@modern-js/new-action": "^1.3.3",
|
|
61
|
-
"@modern-js/plugin
|
|
62
|
-
"@modern-js/plugin-
|
|
63
|
-
"@modern-js/plugin-
|
|
63
|
+
"@modern-js/plugin": "^1.3.2",
|
|
64
|
+
"@modern-js/plugin-analyze": "^1.3.5",
|
|
65
|
+
"@modern-js/plugin-changeset": "^1.2.4",
|
|
66
|
+
"@modern-js/plugin-fast-refresh": "^1.2.3",
|
|
64
67
|
"@modern-js/plugin-i18n": "^1.2.1",
|
|
65
68
|
"@modern-js/style-compiler": "^1.2.2",
|
|
66
|
-
"@modern-js/utils": "^1.3.
|
|
69
|
+
"@modern-js/utils": "^1.3.7",
|
|
67
70
|
"chalk": "^4.1.2",
|
|
68
71
|
"dotenv": "^10.0.0",
|
|
69
72
|
"execa": "^5.1.1",
|
|
@@ -81,6 +84,8 @@
|
|
|
81
84
|
"devDependencies": {
|
|
82
85
|
"@babel/preset-typescript": "^7.15.0",
|
|
83
86
|
"@modern-js/babel-chain": "^1.2.1",
|
|
87
|
+
"@scripts/build": "0.0.0",
|
|
88
|
+
"@scripts/jest-config": "0.0.0",
|
|
84
89
|
"@types/babel__core": "^7.1.15",
|
|
85
90
|
"@types/babel__generator": "^7.6.3",
|
|
86
91
|
"@types/babel__traverse": "^7.14.2",
|
|
@@ -90,13 +95,11 @@
|
|
|
90
95
|
"@types/lodash.merge": "^4.6.6",
|
|
91
96
|
"@types/node": "^14",
|
|
92
97
|
"@types/normalize-path": "^3.0.0",
|
|
93
|
-
"commander": "^8.1.0",
|
|
94
|
-
"typescript": "^4",
|
|
95
|
-
"@scripts/build": "0.0.0",
|
|
96
|
-
"jest": "^27",
|
|
97
98
|
"@types/react": "^17",
|
|
98
99
|
"@types/react-dom": "^17",
|
|
99
|
-
"
|
|
100
|
+
"commander": "^8.1.0",
|
|
101
|
+
"jest": "^27",
|
|
102
|
+
"typescript": "^4"
|
|
100
103
|
},
|
|
101
104
|
"sideEffects": false,
|
|
102
105
|
"modernConfig": {
|