@modern-js/module-tools 1.21.5 → 2.0.0-beta.1
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 +83 -46
- package/dist/js/modern/cli/build.js +2 -1
- package/dist/js/modern/cli/dev.js +2 -2
- package/dist/js/modern/cli/new.js +0 -3
- package/dist/js/modern/commands/build.js +0 -4
- package/dist/js/modern/commands/dev.js +2 -5
- package/dist/js/modern/features/build/build-platform.js +11 -14
- package/dist/js/modern/features/build/bundle/runRollup.js +5 -18
- package/dist/js/modern/features/build/bundle/runSpeedy.js +4 -18
- package/dist/js/modern/features/build/bundleless/copy-assets.js +0 -8
- package/dist/js/modern/features/build/bundleless/generator-dts/index.js +7 -17
- package/dist/js/modern/features/build/bundleless/generator-dts/utils.js +6 -16
- package/dist/js/modern/features/build/bundleless/index.js +0 -2
- package/dist/js/modern/features/build/bundleless/runBabel.js +7 -34
- package/dist/js/modern/features/build/bundleless/style.js +1 -30
- package/dist/js/modern/features/build/constants.js +0 -3
- package/dist/js/modern/features/build/error.js +4 -27
- package/dist/js/modern/features/build/index.js +6 -15
- package/dist/js/modern/features/build/legacy-constants.js +8 -4
- package/dist/js/modern/features/build/logger/logText.js +0 -12
- package/dist/js/modern/features/build/logger/loggerManager.js +6 -19
- package/dist/js/modern/features/build/normalize.js +18 -43
- package/dist/js/modern/features/build/utils.js +14 -19
- package/dist/js/modern/features/dev/index.js +4 -9
- package/dist/js/modern/hooks/index.js +0 -3
- package/dist/js/modern/index.js +5 -9
- package/dist/js/modern/schema/build-config.js +2 -1
- package/dist/js/modern/schema/output.js +5 -10
- package/dist/js/modern/utils/babel.js +13 -15
- package/dist/js/modern/utils/copy.js +6 -15
- package/dist/js/modern/utils/init-env.js +0 -1
- package/dist/js/modern/utils/logger.js +1 -16
- package/dist/js/modern/utils/readline.js +2 -4
- package/dist/js/modern/utils/tsconfig.js +0 -1
- package/dist/js/modern/utils/tspaths-transform/constants.js +4 -2
- package/dist/js/modern/utils/tspaths-transform/index.js +2 -19
- package/dist/js/modern/utils/tspaths-transform/utils.js +0 -3
- package/dist/js/modern/utils/valide.js +2 -6
- package/dist/js/node/cli/build.js +2 -6
- package/dist/js/node/cli/dev.js +2 -7
- package/dist/js/node/cli/index.js +0 -6
- package/dist/js/node/cli/new.js +0 -8
- package/dist/js/node/commands/build.js +0 -19
- package/dist/js/node/commands/dev.js +2 -15
- package/dist/js/node/commands/index.js +0 -2
- package/dist/js/node/features/build/build-platform.js +11 -20
- package/dist/js/node/features/build/bundle/index.js +0 -6
- package/dist/js/node/features/build/bundle/runRollup.js +3 -32
- package/dist/js/node/features/build/bundle/runSpeedy.js +4 -32
- package/dist/js/node/features/build/bundleless/copy-assets.js +0 -20
- package/dist/js/node/features/build/bundleless/generator-dts/index.js +7 -27
- package/dist/js/node/features/build/bundleless/generator-dts/utils.js +6 -32
- package/dist/js/node/features/build/bundleless/index.js +0 -11
- package/dist/js/node/features/build/bundleless/runBabel.js +6 -60
- package/dist/js/node/features/build/bundleless/style.js +1 -50
- package/dist/js/node/features/build/constants.js +0 -11
- package/dist/js/node/features/build/error.js +4 -40
- package/dist/js/node/features/build/index.js +6 -38
- package/dist/js/node/features/build/legacy-constants.js +8 -4
- package/dist/js/node/features/build/logger/index.js +0 -4
- package/dist/js/node/features/build/logger/logText.js +0 -18
- package/dist/js/node/features/build/logger/loggerManager.js +5 -26
- package/dist/js/node/features/build/normalize.js +18 -61
- package/dist/js/node/features/build/utils.js +13 -35
- package/dist/js/node/features/dev/index.js +4 -17
- package/dist/js/node/hooks/build.js +0 -5
- package/dist/js/node/hooks/dev.js +0 -5
- package/dist/js/node/hooks/index.js +0 -10
- package/dist/js/node/index.js +6 -26
- package/dist/js/node/locale/index.js +0 -5
- package/dist/js/node/schema/build-config.js +2 -1
- package/dist/js/node/schema/index.js +0 -5
- package/dist/js/node/schema/output.js +5 -12
- package/dist/js/node/utils/babel.js +12 -22
- package/dist/js/node/utils/color.js +0 -3
- package/dist/js/node/utils/copy.js +6 -23
- package/dist/js/node/utils/init-env.js +0 -3
- package/dist/js/node/utils/json.js +0 -2
- package/dist/js/node/utils/language.js +0 -3
- package/dist/js/node/utils/logger.js +1 -26
- package/dist/js/node/utils/readline.js +0 -8
- package/dist/js/node/utils/tsconfig.js +0 -7
- package/dist/js/node/utils/tspaths-transform/constants.js +4 -2
- package/dist/js/node/utils/tspaths-transform/index.js +2 -34
- package/dist/js/node/utils/tspaths-transform/utils.js +0 -7
- package/dist/js/node/utils/valide.js +2 -11
- package/dist/types/commands/build.d.ts +0 -1
- package/dist/types/features/build/logger/loggerManager.d.ts +0 -1
- package/dist/types/features/build/utils.d.ts +1 -3
- package/dist/types/hooks/index.d.ts +2 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/schema/types.d.ts +1 -3
- package/dist/types/types.d.ts +0 -1
- package/package.json +20 -44
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.safeParse = void 0;
|
|
7
|
-
|
|
8
7
|
const safeParse = jsonString => {
|
|
9
8
|
try {
|
|
10
9
|
return {
|
|
@@ -18,5 +17,4 @@ const safeParse = jsonString => {
|
|
|
18
17
|
};
|
|
19
18
|
}
|
|
20
19
|
};
|
|
21
|
-
|
|
22
20
|
exports.safeParse = safeParse;
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getLocaleLanguage = getLocaleLanguage;
|
|
7
|
-
|
|
8
7
|
var _utils = require("@modern-js/utils");
|
|
9
|
-
|
|
10
8
|
const i18n = _utils.Import.lazy('@modern-js/plugin-i18n/language-detector', require);
|
|
11
|
-
|
|
12
9
|
function getLocaleLanguage() {
|
|
13
10
|
const detector = new i18n.I18CLILanguageDetector();
|
|
14
11
|
return detector.detect();
|
|
@@ -4,18 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.logTemplate = exports.clearFlag = exports.LoggerText = exports.LoggerManager = void 0;
|
|
7
|
-
|
|
8
7
|
var _events = _interopRequireDefault(require("events"));
|
|
9
|
-
|
|
10
8
|
var _utils = require("@modern-js/utils");
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
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; }
|
|
15
|
-
|
|
16
11
|
const clearFlag = '\x1Bc';
|
|
17
12
|
exports.clearFlag = clearFlag;
|
|
18
|
-
|
|
19
13
|
const logTemplate = (title, messageStack, maxLength, {
|
|
20
14
|
noBottomBorder: _noBottomBorder = false,
|
|
21
15
|
bottomBorderText: _bottomBorderText = '',
|
|
@@ -31,39 +25,29 @@ const logTemplate = (title, messageStack, maxLength, {
|
|
|
31
25
|
.filter(s => s !== leftBorderFlag) // 过滤空字符串
|
|
32
26
|
.slice(0, maxLength) // 控制长度
|
|
33
27
|
.reverse(); // 调换顺序,最新的消息在最后面
|
|
34
|
-
|
|
35
28
|
messageFragments[messageFragments.length - 1] = messageFragments[messageFragments.length - 1].trim();
|
|
36
29
|
const template = `${title}:
|
|
37
30
|
${_contentColor(messageFragments.join(''))}${_noBottomBorder ? '' : `\n${_bottomBorderText}`}`;
|
|
38
31
|
console.info('template', messageFragments);
|
|
39
32
|
return template;
|
|
40
33
|
};
|
|
41
|
-
|
|
42
34
|
exports.logTemplate = logTemplate;
|
|
43
|
-
|
|
44
35
|
class LoggerText {
|
|
45
36
|
constructor(option) {
|
|
46
37
|
_defineProperty(this, "messages", void 0);
|
|
47
|
-
|
|
48
38
|
_defineProperty(this, "option", void 0);
|
|
49
|
-
|
|
50
39
|
this.messages = [];
|
|
51
40
|
this.option = option;
|
|
52
41
|
}
|
|
53
|
-
|
|
54
42
|
append(message) {
|
|
55
43
|
var _this$option$contentC;
|
|
56
|
-
|
|
57
44
|
const replace = ((_this$option$contentC = this.option.contentConfig) === null || _this$option$contentC === void 0 ? void 0 : _this$option$contentC.replace) || [];
|
|
58
45
|
let content = message;
|
|
59
|
-
|
|
60
46
|
for (const r of replace) {
|
|
61
47
|
content = content.replace(new RegExp(r, 'g'), '');
|
|
62
48
|
}
|
|
63
|
-
|
|
64
49
|
this.messages.push(content);
|
|
65
50
|
}
|
|
66
|
-
|
|
67
51
|
get value() {
|
|
68
52
|
const {
|
|
69
53
|
title,
|
|
@@ -73,17 +57,14 @@ class LoggerText {
|
|
|
73
57
|
const messages = [...new Set(this.messages)];
|
|
74
58
|
return logTemplate(title, messages, maxLength, contentConfig);
|
|
75
59
|
}
|
|
76
|
-
|
|
77
60
|
}
|
|
78
|
-
|
|
79
61
|
exports.LoggerText = LoggerText;
|
|
80
|
-
|
|
81
62
|
class LoggerManager extends _events.default {
|
|
82
63
|
// constructor() {}
|
|
64
|
+
|
|
83
65
|
createLoggerText(option) {
|
|
84
66
|
return new LoggerText(option);
|
|
85
67
|
}
|
|
86
|
-
|
|
87
68
|
addStdout(loggerText, stdout, config = {}) {
|
|
88
69
|
const {
|
|
89
70
|
event = {
|
|
@@ -96,7 +77,6 @@ class LoggerManager extends _events.default {
|
|
|
96
77
|
warning: _utils.chalk.yellow
|
|
97
78
|
}
|
|
98
79
|
} = config;
|
|
99
|
-
|
|
100
80
|
if (event.data) {
|
|
101
81
|
stdout === null || stdout === void 0 ? void 0 : stdout.on('data', chunk => {
|
|
102
82
|
const data = chunk.toString();
|
|
@@ -105,7 +85,6 @@ class LoggerManager extends _events.default {
|
|
|
105
85
|
this.emit('data');
|
|
106
86
|
});
|
|
107
87
|
}
|
|
108
|
-
|
|
109
88
|
if (event.error) {
|
|
110
89
|
stdout === null || stdout === void 0 ? void 0 : stdout.on('error', error => {
|
|
111
90
|
const data = error.message;
|
|
@@ -115,18 +94,14 @@ class LoggerManager extends _events.default {
|
|
|
115
94
|
});
|
|
116
95
|
}
|
|
117
96
|
}
|
|
118
|
-
|
|
119
97
|
addStderr(loggerText, stderr) {
|
|
120
98
|
stderr === null || stderr === void 0 ? void 0 : stderr.on('data', chunk => {
|
|
121
99
|
const data = chunk.toString();
|
|
122
100
|
loggerText.append(data);
|
|
123
101
|
});
|
|
124
102
|
}
|
|
125
|
-
|
|
126
103
|
show(loggerText) {
|
|
127
104
|
console.info(loggerText.value);
|
|
128
105
|
}
|
|
129
|
-
|
|
130
106
|
}
|
|
131
|
-
|
|
132
107
|
exports.LoggerManager = LoggerManager;
|
|
@@ -4,30 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ReadlineUtils = void 0;
|
|
7
|
-
|
|
8
7
|
var readline = _interopRequireWildcard(require("readline"));
|
|
9
|
-
|
|
10
8
|
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); }
|
|
11
|
-
|
|
12
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; }
|
|
13
|
-
|
|
14
10
|
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
15
11
|
class ReadlineUtils {
|
|
16
12
|
static clearPrevLine(output) {
|
|
17
13
|
ReadlineUtils.clearLine(output, 1);
|
|
18
14
|
}
|
|
19
|
-
|
|
20
15
|
static clearLine(output, n = 1, dir = -1) {
|
|
21
16
|
// -1 向上,1 向下
|
|
22
17
|
const dx = dir === 1 ? 1 : -1;
|
|
23
|
-
|
|
24
18
|
for (let i = 0; i < n; i++) {
|
|
25
19
|
readline.moveCursor(output, 0, dx);
|
|
26
20
|
readline.clearLine(output, 0);
|
|
27
21
|
readline.cursorTo(output, 0);
|
|
28
22
|
}
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
}
|
|
32
|
-
|
|
33
25
|
exports.ReadlineUtils = ReadlineUtils;
|
|
@@ -4,25 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.readTsConfig = exports.existTsConfigFile = void 0;
|
|
7
|
-
|
|
8
7
|
var _utils = require("@modern-js/utils");
|
|
9
|
-
|
|
10
8
|
const readTsConfig = (tsconfigPath, noExistReturn = null) => {
|
|
11
9
|
// 如果不存在,则返回 noExistReturn
|
|
12
10
|
if (!_utils.fs.existsSync(tsconfigPath)) {
|
|
13
11
|
return noExistReturn;
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
const content = _utils.fs.readFileSync(tsconfigPath, 'utf-8');
|
|
17
|
-
|
|
18
14
|
return _utils.json5.parse(content);
|
|
19
15
|
};
|
|
20
|
-
|
|
21
16
|
exports.readTsConfig = readTsConfig;
|
|
22
|
-
|
|
23
17
|
const existTsConfigFile = tsconfigAbsolutePath => {
|
|
24
18
|
const tsconfig = readTsConfig(tsconfigAbsolutePath);
|
|
25
19
|
return Boolean(tsconfig);
|
|
26
20
|
};
|
|
27
|
-
|
|
28
21
|
exports.existTsConfigFile = existTsConfigFile;
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.defaultTransformedFunctions = void 0;
|
|
7
|
-
const defaultTransformedFunctions = ['require', 'require.resolve', 'System.import',
|
|
8
|
-
|
|
7
|
+
const defaultTransformedFunctions = ['require', 'require.resolve', 'System.import',
|
|
8
|
+
// Jest methods
|
|
9
|
+
'jest.genMockFromModule', 'jest.mock', 'jest.unmock', 'jest.doMock', 'jest.dontMock', 'jest.setMock', 'jest.requireActual', 'jest.requireMock',
|
|
10
|
+
// Older Jest methods
|
|
9
11
|
'require.requireActual', 'require.requireMock'];
|
|
10
12
|
exports.defaultTransformedFunctions = defaultTransformedFunctions;
|
|
@@ -4,50 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.transformDtsAlias = void 0;
|
|
7
|
-
|
|
8
7
|
var path = _interopRequireWildcard(require("path"));
|
|
9
|
-
|
|
10
8
|
var parser = _interopRequireWildcard(require("@babel/parser"));
|
|
11
|
-
|
|
12
9
|
var _traverse = _interopRequireDefault(require("@babel/traverse"));
|
|
13
|
-
|
|
14
10
|
var _generator = _interopRequireDefault(require("@babel/generator"));
|
|
15
|
-
|
|
16
11
|
var t = _interopRequireWildcard(require("@babel/types"));
|
|
17
|
-
|
|
18
12
|
var _tsconfigPaths = require("@modern-js/utils/tsconfig-paths");
|
|
19
|
-
|
|
20
13
|
var _utils = require("@modern-js/utils");
|
|
21
|
-
|
|
22
14
|
var _constants = require("./constants");
|
|
23
|
-
|
|
24
15
|
var _utils2 = require("./utils");
|
|
25
|
-
|
|
26
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
|
|
28
17
|
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); }
|
|
29
|
-
|
|
30
18
|
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; }
|
|
31
|
-
|
|
32
19
|
const getPathsMap = (paths, sourceDirName = 'src') => {
|
|
33
20
|
const pathKeys = Object.keys(paths);
|
|
34
21
|
const pathsMap = {};
|
|
35
|
-
|
|
36
22
|
const replaceSrcToTypes = s => s.replace(sourceDirName, 'types');
|
|
37
|
-
|
|
38
23
|
for (const key of pathKeys) {
|
|
39
24
|
const p = paths[key];
|
|
40
|
-
|
|
41
25
|
if (typeof p === 'string') {
|
|
42
26
|
pathsMap[key] = [replaceSrcToTypes(p)];
|
|
43
27
|
} else {
|
|
44
28
|
pathsMap[key] = paths[key].map(sp => replaceSrcToTypes(sp));
|
|
45
29
|
}
|
|
46
30
|
}
|
|
47
|
-
|
|
48
31
|
return pathsMap;
|
|
49
32
|
};
|
|
50
|
-
|
|
51
33
|
function mapPathString(nodePath, {
|
|
52
34
|
filename,
|
|
53
35
|
baseUrl,
|
|
@@ -56,7 +38,6 @@ function mapPathString(nodePath, {
|
|
|
56
38
|
if (!t.isStringLiteral(nodePath)) {
|
|
57
39
|
return;
|
|
58
40
|
}
|
|
59
|
-
|
|
60
41
|
const sourcePath = nodePath.node.value;
|
|
61
42
|
const currentFile = filename;
|
|
62
43
|
const pathsMap = getPathsMap(paths);
|
|
@@ -65,45 +46,36 @@ function mapPathString(nodePath, {
|
|
|
65
46
|
if (!_utils.fs.existsSync(packageJsonPath)) {
|
|
66
47
|
return undefined;
|
|
67
48
|
}
|
|
68
|
-
|
|
69
49
|
return _utils.fs.readJSONSync(packageJsonPath);
|
|
70
50
|
}, filePath => _utils.fs.existsSync(filePath), ['.d.ts']);
|
|
71
|
-
|
|
72
51
|
if (result) {
|
|
73
52
|
const relativePath = path.relative(path.dirname(currentFile), path.dirname(result));
|
|
74
|
-
const fileName = path.basename(result);
|
|
75
|
-
|
|
53
|
+
const fileName = path.basename(result);
|
|
54
|
+
// 如果是同级文件,则返回的是 ''
|
|
76
55
|
const filePath = path.normalize(`${relativePath.length === 0 ? '.' : relativePath}/${fileName}`);
|
|
77
56
|
const replaceString = filePath.startsWith('.') ? filePath : `./${filePath}`;
|
|
78
57
|
nodePath.replaceWith(t.stringLiteral(replaceString));
|
|
79
58
|
}
|
|
80
59
|
}
|
|
81
|
-
|
|
82
60
|
const transformCall = option => nodePath => {
|
|
83
61
|
const calleePath = nodePath.get('callee');
|
|
84
|
-
|
|
85
62
|
const isNormalCall = _constants.defaultTransformedFunctions.some(pattern => (0, _utils2.matchesPattern)(calleePath, pattern));
|
|
86
|
-
|
|
87
63
|
if (isNormalCall || (0, _utils2.isImportCall)(nodePath)) {
|
|
88
64
|
mapPathString(nodePath.get('arguments.0'), option);
|
|
89
65
|
}
|
|
90
66
|
};
|
|
91
|
-
|
|
92
67
|
const transformImport = option => nodePath => {
|
|
93
68
|
mapPathString(nodePath.get('source'), option);
|
|
94
69
|
};
|
|
95
|
-
|
|
96
70
|
const transformExport = option => nodePath => {
|
|
97
71
|
mapPathString(nodePath.get('source'), option);
|
|
98
72
|
};
|
|
99
|
-
|
|
100
73
|
const transformSingleFileAlias = ({
|
|
101
74
|
filename,
|
|
102
75
|
baseUrl,
|
|
103
76
|
paths
|
|
104
77
|
}) => {
|
|
105
78
|
const sourceCode = _utils.fs.readFileSync(filename, 'utf-8');
|
|
106
|
-
|
|
107
79
|
const ast = parser.parse(sourceCode, {
|
|
108
80
|
sourceType: 'module',
|
|
109
81
|
errorRecovery: true,
|
|
@@ -129,7 +101,6 @@ const transformSingleFileAlias = ({
|
|
|
129
101
|
});
|
|
130
102
|
return (0, _generator.default)(ast).code;
|
|
131
103
|
};
|
|
132
|
-
|
|
133
104
|
const transformDtsAlias = option => {
|
|
134
105
|
const {
|
|
135
106
|
filenames = [],
|
|
@@ -137,7 +108,6 @@ const transformDtsAlias = option => {
|
|
|
137
108
|
paths
|
|
138
109
|
} = option;
|
|
139
110
|
const transformResult = [];
|
|
140
|
-
|
|
141
111
|
for (const filename of filenames) {
|
|
142
112
|
transformResult.push({
|
|
143
113
|
path: filename,
|
|
@@ -148,8 +118,6 @@ const transformDtsAlias = option => {
|
|
|
148
118
|
})
|
|
149
119
|
});
|
|
150
120
|
}
|
|
151
|
-
|
|
152
121
|
return transformResult;
|
|
153
122
|
};
|
|
154
|
-
|
|
155
123
|
exports.transformDtsAlias = transformDtsAlias;
|
|
@@ -5,28 +5,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.isImportCall = isImportCall;
|
|
7
7
|
exports.matchesPattern = matchesPattern;
|
|
8
|
-
|
|
9
8
|
var _utils = require("@modern-js/utils");
|
|
10
|
-
|
|
11
9
|
const t = _utils.Import.lazy('@babel/types', require);
|
|
12
|
-
|
|
13
10
|
function matchesPattern(calleePath, pattern) {
|
|
14
11
|
const {
|
|
15
12
|
node
|
|
16
13
|
} = calleePath;
|
|
17
|
-
|
|
18
14
|
if (t.isMemberExpression(node)) {
|
|
19
15
|
return calleePath.matchesPattern(pattern);
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
if (!t.isIdentifier(node) || pattern.includes('.')) {
|
|
23
18
|
return false;
|
|
24
19
|
}
|
|
25
|
-
|
|
26
20
|
const name = pattern.split('.')[0];
|
|
27
21
|
return node.name === name;
|
|
28
22
|
}
|
|
29
|
-
|
|
30
23
|
function isImportCall(calleePath) {
|
|
31
24
|
return t.isImport(calleePath.node.callee);
|
|
32
25
|
}
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.valideBeforeTask = exports.modernConfigValid = void 0;
|
|
7
|
-
|
|
8
7
|
var _utils = require("@modern-js/utils");
|
|
9
|
-
|
|
10
8
|
const valideBeforeTask = ({
|
|
11
9
|
modernConfig,
|
|
12
10
|
tsconfigPath
|
|
@@ -14,28 +12,21 @@ const valideBeforeTask = ({
|
|
|
14
12
|
const modernConfigValidResult = modernConfigValid(modernConfig, {
|
|
15
13
|
tsconfigPath
|
|
16
14
|
});
|
|
17
|
-
|
|
18
15
|
if (modernConfigValidResult) {
|
|
19
|
-
console.error(modernConfigValidResult);
|
|
20
|
-
|
|
16
|
+
console.error(modernConfigValidResult);
|
|
17
|
+
// eslint-disable-next-line no-process-exit
|
|
21
18
|
process.exit(0);
|
|
22
19
|
}
|
|
23
20
|
};
|
|
24
|
-
|
|
25
21
|
exports.valideBeforeTask = valideBeforeTask;
|
|
26
|
-
|
|
27
22
|
const modernConfigValid = (modernConfig, option) => {
|
|
28
23
|
const valids = [_utils.validAlias];
|
|
29
|
-
|
|
30
24
|
for (const validFn of valids) {
|
|
31
25
|
const result = validFn(modernConfig, option);
|
|
32
|
-
|
|
33
26
|
if (result) {
|
|
34
27
|
return result;
|
|
35
28
|
}
|
|
36
29
|
}
|
|
37
|
-
|
|
38
30
|
return null;
|
|
39
31
|
};
|
|
40
|
-
|
|
41
32
|
exports.modernConfigValid = modernConfigValid;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { NormalizedConfig } from '@modern-js/core';
|
|
2
1
|
import type { PostcssOption } from '@modern-js/style-compiler';
|
|
3
2
|
/**
|
|
4
3
|
* 处理日志信息
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
5
|
export declare class LogStack {
|
|
8
6
|
private _codeLogStack;
|
|
9
7
|
constructor();
|
|
@@ -34,5 +32,5 @@ export declare enum SectionTitleStatus {
|
|
|
34
32
|
Log = 2,
|
|
35
33
|
}
|
|
36
34
|
export declare const watchSectionTitle: (str: string, status: SectionTitleStatus) => string;
|
|
37
|
-
export declare const getPostcssOption: (
|
|
35
|
+
export declare const getPostcssOption: (...args: any[]) => PostcssOption;
|
|
38
36
|
export declare const getAllDeps: <T>(appDirectory: string) => string[];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CliPlugin } from '@modern-js/core';
|
|
2
|
+
import { ModuleHooks } from './hooks';
|
|
2
3
|
export * from './types';
|
|
4
|
+
export type { ModuleHooks, CliPlugin };
|
|
3
5
|
export { defineConfig } from '@modern-js/core';
|
|
4
|
-
|
|
5
6
|
declare const _default: () => CliPlugin;
|
|
6
|
-
|
|
7
7
|
export default _default;
|
|
@@ -15,9 +15,7 @@ export declare type BundleOptions = {
|
|
|
15
15
|
export declare type BundlelessOptions = {
|
|
16
16
|
sourceDir?: string;
|
|
17
17
|
style?: {
|
|
18
|
-
compileMode?: 'all' | 'only-compiled-code' |
|
|
19
|
-
/* may be will be deprecated */
|
|
20
|
-
'only-source-code' | false;
|
|
18
|
+
compileMode?: 'all' | 'only-compiled-code' | /* may be will be deprecated */'only-source-code' | false;
|
|
21
19
|
path?: string;
|
|
22
20
|
};
|
|
23
21
|
static?: {
|
package/dist/types/types.d.ts
CHANGED
|
@@ -35,7 +35,6 @@ declare module '@modern-js/core' {
|
|
|
35
35
|
/** @deprecated Use the `buildConfig.bundlelessOptions.static.path` instead . */
|
|
36
36
|
assetsPath?: string;
|
|
37
37
|
/** @deprecated Use the `buildConfig.sourceMap` instead */
|
|
38
|
-
|
|
39
38
|
disableSourceMap?: boolean;
|
|
40
39
|
buildPreset?: BuildPreset;
|
|
41
40
|
buildConfig?: BuildConfig;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "
|
|
14
|
+
"version": "2.0.0-beta.1",
|
|
15
15
|
"bin": {
|
|
16
16
|
"modern": "./bin/modern.js"
|
|
17
17
|
},
|
|
@@ -54,10 +54,11 @@
|
|
|
54
54
|
"@babel/runtime": "^7.18.0",
|
|
55
55
|
"@babel/traverse": "^7.18.0",
|
|
56
56
|
"@babel/types": "^7.18.0",
|
|
57
|
+
"@modern-js/css-config": "1.21.1",
|
|
57
58
|
"@rollup/plugin-json": "~4.1.0",
|
|
58
|
-
"@speedy-js/speedy-types": "0.13.2-modern.
|
|
59
|
-
"@speedy-js/speedy-core": "0.13.2-modern.
|
|
60
|
-
"@speedy-js/speedy-plugin-es5": "0.13.2-modern.
|
|
59
|
+
"@speedy-js/speedy-types": "0.13.2-modern.4",
|
|
60
|
+
"@speedy-js/speedy-core": "0.13.2-modern.4",
|
|
61
|
+
"@speedy-js/speedy-plugin-es5": "0.13.2-modern.4",
|
|
61
62
|
"normalize-path": "^3.0.0",
|
|
62
63
|
"p-map": "^4",
|
|
63
64
|
"process.argv": "^0.6.0",
|
|
@@ -65,18 +66,17 @@
|
|
|
65
66
|
"rollup-plugin-dts": "^4.2.1",
|
|
66
67
|
"rollup-plugin-hashbang": "^3.0.0",
|
|
67
68
|
"signal-exit": "^3.0.7",
|
|
68
|
-
"@modern-js/babel-
|
|
69
|
-
"@modern-js/
|
|
70
|
-
"@modern-js/
|
|
71
|
-
"@modern-js/
|
|
72
|
-
"@modern-js/
|
|
73
|
-
"@modern-js/
|
|
74
|
-
"@modern-js/plugin": "
|
|
75
|
-
"@modern-js/plugin-
|
|
76
|
-
"@modern-js/
|
|
77
|
-
"@modern-js/
|
|
78
|
-
"@modern-js/
|
|
79
|
-
"@modern-js/utils": "1.21.5"
|
|
69
|
+
"@modern-js/babel-preset-module": "2.0.0-beta.1",
|
|
70
|
+
"@modern-js/core": "2.0.0-beta.1",
|
|
71
|
+
"@modern-js/new-action": "2.0.0-beta.1",
|
|
72
|
+
"@modern-js/upgrade": "2.0.0-beta.1",
|
|
73
|
+
"@modern-js/plugin": "2.0.0-beta.1",
|
|
74
|
+
"@modern-js/plugin-changeset": "2.0.0-beta.1",
|
|
75
|
+
"@modern-js/plugin-i18n": "2.0.0-beta.1",
|
|
76
|
+
"@modern-js/plugin-lint": "2.0.0-beta.1",
|
|
77
|
+
"@modern-js/style-compiler": "2.0.0-beta.1",
|
|
78
|
+
"@modern-js/utils": "2.0.0-beta.1",
|
|
79
|
+
"@modern-js/babel-compiler": "2.0.0-beta.1"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@types/babel__core": "^7.1.15",
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
"typescript": "^4",
|
|
92
92
|
"ajv": "^8",
|
|
93
93
|
"ajv-keywords": "^5",
|
|
94
|
-
"@scripts/build": "
|
|
95
|
-
"@scripts/jest-config": "
|
|
94
|
+
"@scripts/build": "2.0.0-beta.1",
|
|
95
|
+
"@scripts/jest-config": "2.0.0-beta.1"
|
|
96
96
|
},
|
|
97
97
|
"sideEffects": false,
|
|
98
98
|
"modernConfig": {
|
|
@@ -104,34 +104,10 @@
|
|
|
104
104
|
"registry": "https://registry.npmjs.org/",
|
|
105
105
|
"access": "public"
|
|
106
106
|
},
|
|
107
|
-
"wireit": {
|
|
108
|
-
"build": {
|
|
109
|
-
"command": "modern build",
|
|
110
|
-
"files": [
|
|
111
|
-
"src/**/*",
|
|
112
|
-
"tsconfig.json",
|
|
113
|
-
"package.json",
|
|
114
|
-
"./modern.config.js"
|
|
115
|
-
],
|
|
116
|
-
"output": [
|
|
117
|
-
"dist/**/*"
|
|
118
|
-
]
|
|
119
|
-
},
|
|
120
|
-
"test": {
|
|
121
|
-
"command": "jest --passWithNoTests",
|
|
122
|
-
"files": [
|
|
123
|
-
"src/**/*",
|
|
124
|
-
"tsconfig.json",
|
|
125
|
-
"package.json",
|
|
126
|
-
"tests/**/*"
|
|
127
|
-
],
|
|
128
|
-
"output": []
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
107
|
"scripts": {
|
|
132
108
|
"new": "modern new",
|
|
133
|
-
"build": "
|
|
134
|
-
"test": "
|
|
109
|
+
"build": "modern build",
|
|
110
|
+
"test": "jest --passWithNoTests",
|
|
135
111
|
"dev": "modern build --watch"
|
|
136
112
|
}
|
|
137
113
|
}
|