@modern-js/core 1.11.0-beta.1 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/modern-js.js +18 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +33 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +4 -4
- package/dist/loadPlugins.js +1 -1
- package/package.json +7 -7
- package/dist/bin.d.ts +0 -2
- package/dist/bin.js +0 -20
package/bin/modern-js.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
require('../compiled/v8-compile-cache');
|
|
4
|
+
const { cli } = require('../');
|
|
5
|
+
const { version } = require('../package.json');
|
|
6
|
+
|
|
7
|
+
process.env.MODERN_JS_VERSION = version;
|
|
8
|
+
if (!process.env.NODE_ENV) {
|
|
9
|
+
process.env.NODE_ENV =
|
|
10
|
+
// eslint-disable-next-line no-nested-ternary
|
|
11
|
+
['build', 'start', 'deploy'].indexOf(process.argv[2]) !== -1
|
|
12
|
+
? 'production'
|
|
13
|
+
: process.argv[2] === 'test'
|
|
14
|
+
? 'test'
|
|
15
|
+
: 'development';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
cli.run(process.argv.slice(2));
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// 这个文件跟 bin/modern-js.js 基本一样
|
|
3
|
+
// 在开发阶段,因为 package.json 的 exports['./bin']['jsnext:source'] 配置
|
|
4
|
+
// 了这个文件,所以需要保留, 后续如果找到更好的方式之后会移除这个文件
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const _1 = require(".");
|
|
11
|
+
const { version } = require('../package.json');
|
|
12
|
+
// XXX: 通过这个方式去掉了 package.json 里面对于 @modern-js/module-tools 的 devDependencies 依赖
|
|
13
|
+
// 然后可以正常的执行 modern build
|
|
14
|
+
const kModuleToolsCliPath = path_1.default.resolve(__dirname, '../../../solutions/module-tools/src/index.ts');
|
|
15
|
+
process.env.MODERN_JS_VERSION = version;
|
|
16
|
+
if (!process.env.NODE_ENV) {
|
|
17
|
+
process.env.NODE_ENV =
|
|
18
|
+
// eslint-disable-next-line no-nested-ternary
|
|
19
|
+
['build', 'start', 'deploy'].includes(process.argv[2])
|
|
20
|
+
? 'production'
|
|
21
|
+
: process.argv[2] === 'test'
|
|
22
|
+
? 'test'
|
|
23
|
+
: 'development';
|
|
24
|
+
}
|
|
25
|
+
_1.cli.run(process.argv.slice(2), {
|
|
26
|
+
plugins: {
|
|
27
|
+
'@modern-js/module-tools': {
|
|
28
|
+
cli: kModuleToolsCliPath,
|
|
29
|
+
// 是否需要强制加载这个组件,跳过 loadPlugins 里面 filter 的检测逻辑
|
|
30
|
+
forced: true,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export type { PluginAPI } from './pluginAPI';
|
|
|
15
15
|
export type { NormalizedConfig, IAppContext };
|
|
16
16
|
declare const initAppDir: (cwd?: string | undefined) => Promise<string>;
|
|
17
17
|
export interface CoreOptions {
|
|
18
|
-
version?: string;
|
|
19
18
|
configFile?: string;
|
|
20
19
|
serverConfigFile?: string;
|
|
21
20
|
packageJsonConfig?: string;
|
|
@@ -30,7 +29,6 @@ export interface CoreOptions {
|
|
|
30
29
|
};
|
|
31
30
|
}
|
|
32
31
|
export declare const mergeOptions: (options?: CoreOptions | undefined) => {
|
|
33
|
-
version?: string | undefined;
|
|
34
32
|
configFile?: string | undefined;
|
|
35
33
|
serverConfigFile: string;
|
|
36
34
|
packageJsonConfig?: string | undefined;
|
package/dist/index.js
CHANGED
|
@@ -43,6 +43,10 @@ Object.defineProperty(exports, "ResolvedConfigContext", { enumerable: true, get:
|
|
|
43
43
|
Object.defineProperty(exports, "useAppContext", { enumerable: true, get: function () { return pluginAPI_1.useAppContext; } });
|
|
44
44
|
Object.defineProperty(exports, "useConfigContext", { enumerable: true, get: function () { return pluginAPI_1.useConfigContext; } });
|
|
45
45
|
Object.defineProperty(exports, "useResolvedConfigContext", { enumerable: true, get: function () { return pluginAPI_1.useResolvedConfigContext; } });
|
|
46
|
+
utils_1.program
|
|
47
|
+
.name('modern')
|
|
48
|
+
.usage('<command> [options]')
|
|
49
|
+
.version(process.env.MODERN_JS_VERSION || '0.1.0');
|
|
46
50
|
const initAppDir = async (cwd) => {
|
|
47
51
|
if (!cwd) {
|
|
48
52
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -65,9 +69,6 @@ const mergeOptions = (options) => {
|
|
|
65
69
|
};
|
|
66
70
|
};
|
|
67
71
|
exports.mergeOptions = mergeOptions;
|
|
68
|
-
const setProgramVersion = (version = 'unknown') => {
|
|
69
|
-
utils_1.program.name('modern').usage('<command> [options]').version(version);
|
|
70
|
-
};
|
|
71
72
|
const createCli = () => {
|
|
72
73
|
let hooksRunner;
|
|
73
74
|
let isRestart = false;
|
|
@@ -81,7 +82,6 @@ const createCli = () => {
|
|
|
81
82
|
restartOptions = mergedOptions;
|
|
82
83
|
const appDirectory = await initAppDir();
|
|
83
84
|
(0, commander_1.initCommandsMap)();
|
|
84
|
-
setProgramVersion(options === null || options === void 0 ? void 0 : options.version);
|
|
85
85
|
const metaName = (_b = (_a = mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.options) === null || _a === void 0 ? void 0 : _a.metaName) !== null && _b !== void 0 ? _b : 'MODERN';
|
|
86
86
|
(0, loadEnv_1.loadEnv)(appDirectory, process.env[`${metaName.toUpperCase()}_ENV`]);
|
|
87
87
|
const loaded = await (0, config_1.loadUserConfig)(appDirectory, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.configFile, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.packageJsonConfig);
|
package/dist/loadPlugins.js
CHANGED
|
@@ -31,7 +31,7 @@ function getAppPlugins(appDirectory, oldPluginConfig, internalPlugins) {
|
|
|
31
31
|
.filter(name => {
|
|
32
32
|
const config = allPlugins[name];
|
|
33
33
|
if (config.forced === true) {
|
|
34
|
-
// 参考 packages/cli/core/src/
|
|
34
|
+
// 参考 packages/cli/core/src/cli.ts 文件
|
|
35
35
|
return true;
|
|
36
36
|
}
|
|
37
37
|
return (0, utils_1.isDepExists)(appDirectory, name);
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.11.0
|
|
14
|
+
"version": "1.11.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"main": "./dist/index.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"default": "./dist/index.js"
|
|
28
28
|
},
|
|
29
29
|
"./bin": {
|
|
30
|
-
"jsnext:source": "./src/
|
|
31
|
-
"default": "./
|
|
30
|
+
"jsnext:source": "./src/cli.ts",
|
|
31
|
+
"default": "./bin/modern-js.js"
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"typesVersions": {
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
]
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
|
-
"bin": "./
|
|
41
|
+
"bin": "./bin/modern-js.js",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@modern-js/load-config": "^1.3.
|
|
44
|
-
"@modern-js/plugin": "^1.3.
|
|
45
|
-
"@modern-js/utils": "^1.7.
|
|
43
|
+
"@modern-js/load-config": "^1.3.3",
|
|
44
|
+
"@modern-js/plugin": "^1.3.5",
|
|
45
|
+
"@modern-js/utils": "^1.7.5"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@jest/types": "^27.0.6",
|
package/dist/bin.d.ts
DELETED
package/dist/bin.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
require('../compiled/v8-compile-cache');
|
|
5
|
-
// eslint-disable-next-line import/first
|
|
6
|
-
const _1 = require(".");
|
|
7
|
-
if (!process.env.NODE_ENV) {
|
|
8
|
-
const command = process.argv[2];
|
|
9
|
-
if (['build', 'start', 'deploy'].includes(command)) {
|
|
10
|
-
process.env.NODE_ENV = 'production';
|
|
11
|
-
}
|
|
12
|
-
else if (command === 'test') {
|
|
13
|
-
process.env.NODE_ENV = 'test';
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
process.env.NODE_ENV = 'development';
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
const { version } = require('../package.json');
|
|
20
|
-
_1.cli.run(process.argv.slice(2), { version });
|