@modern-js/utils 1.0.0-rc.11 → 1.0.0-rc.12
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 +7 -0
- package/README.md +13 -21
- package/dist/js/modern/alias.js +7 -1
- package/dist/js/modern/constants.js +3 -0
- package/dist/js/modern/prettyInstructions.js +4 -3
- package/dist/js/node/alias.js +7 -1
- package/dist/js/node/constants.js +3 -0
- package/dist/js/node/prettyInstructions.js +4 -2
- package/dist/js/treeshaking/alias.js +7 -1
- package/dist/js/treeshaking/constants.js +3 -0
- package/dist/js/treeshaking/prettyInstructions.js +4 -3
- package/dist/types/prettyInstructions.d.ts +1 -1
- package/package.json +71 -71
- package/src/alias.ts +4 -4
- package/src/constants.ts +1 -0
- package/src/prettyInstructions.ts +6 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
@@ -3,30 +3,22 @@
|
|
3
3
|
<a href="https://modernjs.dev" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png" width="300" alt="Modern.js Logo" /></a>
|
4
4
|
</p>
|
5
5
|
|
6
|
-
<p align="center"
|
6
|
+
<p align="center">
|
7
|
+
现代 Web 工程体系
|
8
|
+
<br/>
|
9
|
+
<a href="https://modernjs.dev" target="blank">
|
10
|
+
modernjs.dev
|
11
|
+
</a>
|
12
|
+
</p>
|
13
|
+
|
7
14
|
|
8
|
-
##
|
15
|
+
## 参考链接
|
9
16
|
- [迈入现代 Web 开发](https://zhuanlan.zhihu.com/p/386607009)
|
10
17
|
- [现代 Web 开发者问卷调查报告](https://zhuanlan.zhihu.com/p/403206195)
|
18
|
+
- [字节跳动是如何落地微前端的](https://mp.weixin.qq.com/s/L9wbfNG5fTXF5bx7dcgj4Q)
|
11
19
|
|
12
|
-
##
|
13
|
-
|
14
|
-
Modern.js 的 1.0.0.rc 版已经发到 npm,目前在做测试改进,README 文档之后统一提供(现阶段加入测试和开发,可以发 [issue](https://github.com/modern-js-dev/modern.js/issues) 留微信联系),完整的文档站计划在10月14日上线
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
20
|
+
## 近期计划
|
31
21
|
|
22
|
+
Modern.js 的 1.0.0.rc 版已经发到 npm,目前在做测试改进和文档建设。
|
32
23
|
|
24
|
+
README、完整的文档站、介绍等,都计划在 10 月 27 日上线。
|
package/dist/js/modern/alias.js
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { 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
|
+
|
1
7
|
import fs from 'fs';
|
2
8
|
import path from 'path';
|
3
9
|
import chalk from 'chalk';
|
@@ -50,7 +56,7 @@ export const getAlias = (aliasOption, option) => {
|
|
50
56
|
const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig$compilerOpt = tsconfig.compilerOptions) === null || _tsconfig$compilerOpt === void 0 ? void 0 : _tsconfig$compilerOpt.baseUrl;
|
51
57
|
aliasConfig = {
|
52
58
|
absoluteBaseUrl: baseUrl ? path.join(option.appDirectory, baseUrl) : option.appDirectory,
|
53
|
-
paths:
|
59
|
+
paths: _objectSpread(_objectSpread({}, aliasOption || {}), tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig$compilerOpt2 = tsconfig.compilerOptions) === null || _tsconfig$compilerOpt2 === void 0 ? void 0 : _tsconfig$compilerOpt2.paths),
|
54
60
|
isTsPath: true,
|
55
61
|
isTsProject
|
56
62
|
};
|
@@ -71,6 +71,9 @@ export const INTERNAL_PLUGINS = {
|
|
71
71
|
'@modern-js/plugin-proxy': {
|
72
72
|
cli: '@modern-js/plugin-proxy/cli'
|
73
73
|
},
|
74
|
+
'@modern-js/plugin-ssg': {
|
75
|
+
cli: '@modern-js/plugin-ssg/cli'
|
76
|
+
},
|
74
77
|
'@modern-js/plugin-bff': {
|
75
78
|
cli: '@modern-js/plugin-bff/cli',
|
76
79
|
server: '@modern-js/plugin-bff/server'
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import os from 'os';
|
2
|
-
import chalk from 'chalk';
|
2
|
+
import chalk from 'chalk';
|
3
|
+
import { isDev } from "./is"; // TODO: type
|
3
4
|
|
4
5
|
// TODO: remove hard code 'main'
|
5
6
|
const isSPA = entrypoints => entrypoints.length === 1 && entrypoints[0].entryName === 'main';
|
@@ -33,13 +34,13 @@ const getAddressUrls = (protocol = 'http', port) => {
|
|
33
34
|
}, []);
|
34
35
|
};
|
35
36
|
|
36
|
-
export const prettyInstructions = appContext => {
|
37
|
+
export const prettyInstructions = (appContext, config) => {
|
37
38
|
const {
|
38
39
|
entrypoints,
|
39
40
|
serverRoutes,
|
40
41
|
port
|
41
42
|
} = appContext;
|
42
|
-
const urls = getAddressUrls('http', port);
|
43
|
+
const urls = getAddressUrls(config.dev.https && isDev() ? 'https' : 'http', port);
|
43
44
|
const routes = serverRoutes.filter(route => route.entryName);
|
44
45
|
let message = 'App running at:\n\n';
|
45
46
|
|
package/dist/js/node/alias.js
CHANGED
@@ -17,6 +17,12 @@ var _applyOptionsChain = require("./applyOptionsChain");
|
|
17
17
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
19
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
21
|
+
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
23
|
+
|
24
|
+
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; }
|
25
|
+
|
20
26
|
const validAlias = (modernConfig, {
|
21
27
|
tsconfigPath
|
22
28
|
}) => {
|
@@ -68,7 +74,7 @@ const getAlias = (aliasOption, option) => {
|
|
68
74
|
const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig$compilerOpt = tsconfig.compilerOptions) === null || _tsconfig$compilerOpt === void 0 ? void 0 : _tsconfig$compilerOpt.baseUrl;
|
69
75
|
aliasConfig = {
|
70
76
|
absoluteBaseUrl: baseUrl ? _path.default.join(option.appDirectory, baseUrl) : option.appDirectory,
|
71
|
-
paths: (
|
77
|
+
paths: _objectSpread(_objectSpread({}, aliasOption || {}), tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig$compilerOpt2 = tsconfig.compilerOptions) === null || _tsconfig$compilerOpt2 === void 0 ? void 0 : _tsconfig$compilerOpt2.paths),
|
72
78
|
isTsPath: true,
|
73
79
|
isTsProject
|
74
80
|
};
|
@@ -87,6 +87,9 @@ const INTERNAL_PLUGINS = {
|
|
87
87
|
'@modern-js/plugin-proxy': {
|
88
88
|
cli: '@modern-js/plugin-proxy/cli'
|
89
89
|
},
|
90
|
+
'@modern-js/plugin-ssg': {
|
91
|
+
cli: '@modern-js/plugin-ssg/cli'
|
92
|
+
},
|
90
93
|
'@modern-js/plugin-bff': {
|
91
94
|
cli: '@modern-js/plugin-bff/cli',
|
92
95
|
server: '@modern-js/plugin-bff/server'
|
@@ -9,6 +9,8 @@ var _os = _interopRequireDefault(require("os"));
|
|
9
9
|
|
10
10
|
var _chalk = _interopRequireDefault(require("chalk"));
|
11
11
|
|
12
|
+
var _is = require("./is");
|
13
|
+
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
15
|
|
14
16
|
// TODO: remove hard code 'main'
|
@@ -44,13 +46,13 @@ const getAddressUrls = (protocol = 'http', port) => {
|
|
44
46
|
}, []);
|
45
47
|
};
|
46
48
|
|
47
|
-
const prettyInstructions = appContext => {
|
49
|
+
const prettyInstructions = (appContext, config) => {
|
48
50
|
const {
|
49
51
|
entrypoints,
|
50
52
|
serverRoutes,
|
51
53
|
port
|
52
54
|
} = appContext;
|
53
|
-
const urls = getAddressUrls('http', port);
|
55
|
+
const urls = getAddressUrls(config.dev.https && (0, _is.isDev)() ? 'https' : 'http', port);
|
54
56
|
const routes = serverRoutes.filter(route => route.entryName);
|
55
57
|
let message = 'App running at:\n\n';
|
56
58
|
|
@@ -1,3 +1,9 @@
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { 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
|
+
|
1
7
|
import fs from 'fs';
|
2
8
|
import path from 'path';
|
3
9
|
import chalk from 'chalk';
|
@@ -45,7 +51,7 @@ export var getAlias = function getAlias(aliasOption, option) {
|
|
45
51
|
var baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig$compilerOpt = tsconfig.compilerOptions) === null || _tsconfig$compilerOpt === void 0 ? void 0 : _tsconfig$compilerOpt.baseUrl;
|
46
52
|
aliasConfig = {
|
47
53
|
absoluteBaseUrl: baseUrl ? path.join(option.appDirectory, baseUrl) : option.appDirectory,
|
48
|
-
paths:
|
54
|
+
paths: _objectSpread(_objectSpread({}, aliasOption || {}), tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig$compilerOpt2 = tsconfig.compilerOptions) === null || _tsconfig$compilerOpt2 === void 0 ? void 0 : _tsconfig$compilerOpt2.paths),
|
49
55
|
isTsPath: true,
|
50
56
|
isTsProject: isTsProject
|
51
57
|
};
|
@@ -73,6 +73,9 @@ export var INTERNAL_PLUGINS = {
|
|
73
73
|
'@modern-js/plugin-proxy': {
|
74
74
|
cli: '@modern-js/plugin-proxy/cli'
|
75
75
|
},
|
76
|
+
'@modern-js/plugin-ssg': {
|
77
|
+
cli: '@modern-js/plugin-ssg/cli'
|
78
|
+
},
|
76
79
|
'@modern-js/plugin-bff': {
|
77
80
|
cli: '@modern-js/plugin-bff/cli',
|
78
81
|
server: '@modern-js/plugin-bff/server'
|
@@ -11,7 +11,8 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
11
11
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
12
12
|
|
13
13
|
import os from 'os';
|
14
|
-
import chalk from 'chalk';
|
14
|
+
import chalk from 'chalk';
|
15
|
+
import { isDev } from "./is"; // TODO: type
|
15
16
|
|
16
17
|
// TODO: remove hard code 'main'
|
17
18
|
var isSPA = function isSPA(entrypoints) {
|
@@ -51,12 +52,12 @@ var getAddressUrls = function getAddressUrls() {
|
|
51
52
|
}, []);
|
52
53
|
};
|
53
54
|
|
54
|
-
export var prettyInstructions = function prettyInstructions(appContext) {
|
55
|
+
export var prettyInstructions = function prettyInstructions(appContext, config) {
|
55
56
|
var _ref = appContext,
|
56
57
|
entrypoints = _ref.entrypoints,
|
57
58
|
serverRoutes = _ref.serverRoutes,
|
58
59
|
port = _ref.port;
|
59
|
-
var urls = getAddressUrls('http', port);
|
60
|
+
var urls = getAddressUrls(config.dev.https && isDev() ? 'https' : 'http', port);
|
60
61
|
var routes = serverRoutes.filter(function (route) {
|
61
62
|
return route.entryName;
|
62
63
|
});
|
@@ -1 +1 @@
|
|
1
|
-
export declare const prettyInstructions: (appContext: any) => string;
|
1
|
+
export declare const prettyInstructions: (appContext: any, config: any) => string;
|
package/package.json
CHANGED
@@ -1,72 +1,72 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
}
|
2
|
+
"name": "@modern-js/utils",
|
3
|
+
"version": "1.0.0-rc.12",
|
4
|
+
"jsnext:source": "./src/index.ts",
|
5
|
+
"types": "./dist/types/index.d.ts",
|
6
|
+
"main": "./dist/js/node/index.js",
|
7
|
+
"module": "./dist/js/treeshaking/index.js",
|
8
|
+
"jsnext:modern": "./dist/js/modern/index.js",
|
9
|
+
"exports": {
|
10
|
+
".": {
|
11
|
+
"node": {
|
12
|
+
"import": "./dist/js/modern/index.js",
|
13
|
+
"require": "./dist/js/node/index.js"
|
14
|
+
},
|
15
|
+
"default": "./dist/js/treeshaking/index.js"
|
16
|
+
},
|
17
|
+
"./formatWebpackMessages": "./dist/js/treeshaking/formatWebpackMessages.js",
|
18
|
+
"./constants": "./dist/js/treeshaking/constants.js"
|
19
|
+
},
|
20
|
+
"typesVersions": {
|
21
|
+
"*": {
|
22
|
+
"formatWebpackMessages": [
|
23
|
+
"./dist/types/formatWebpackMessages.d.ts"
|
24
|
+
],
|
25
|
+
"constants": [
|
26
|
+
"./dist/types/constants.d.ts"
|
27
|
+
]
|
28
|
+
}
|
29
|
+
},
|
30
|
+
"dependencies": {
|
31
|
+
"@babel/runtime": "^7",
|
32
|
+
"@types/fs-extra": "^9.0.12",
|
33
|
+
"browserslist": "^4.16.7",
|
34
|
+
"chalk": "^4.1.2",
|
35
|
+
"chokidar": "^3.5.2",
|
36
|
+
"debug": "^4.3.2",
|
37
|
+
"filesize": "^7.0.0",
|
38
|
+
"fs-extra": "^10.0.0",
|
39
|
+
"glob": "^7.1.7",
|
40
|
+
"gzip-size": "^6.0.0",
|
41
|
+
"import-lazy": "^4.0.0",
|
42
|
+
"pkg-up": "^3.1.0",
|
43
|
+
"recursive-readdir": "^2.2.2",
|
44
|
+
"strip-ansi": "6.0.0",
|
45
|
+
"yaml": "^1.10.2"
|
46
|
+
},
|
47
|
+
"devDependencies": {
|
48
|
+
"@types/debug": "^4.1.7",
|
49
|
+
"@types/fs-extra": "^9.0.12",
|
50
|
+
"@types/glob": "^7.1.4",
|
51
|
+
"@types/jest": "^26",
|
52
|
+
"@types/node": "^14",
|
53
|
+
"@types/recursive-readdir": "^2.2.0",
|
54
|
+
"typescript": "^4",
|
55
|
+
"webpack": "^5.54.0",
|
56
|
+
"@modern-js/plugin-testing": "^1.0.0-rc.12",
|
57
|
+
"@modern-js/module-tools": "^1.0.0-rc.12"
|
58
|
+
},
|
59
|
+
"peerDependencies": {
|
60
|
+
"typescript": "^4.4.3"
|
61
|
+
},
|
62
|
+
"sideEffects": false,
|
63
|
+
"publishConfig": {
|
64
|
+
"registry": "https://registry.npmjs.org/",
|
65
|
+
"access": "public"
|
66
|
+
},
|
67
|
+
"scripts": {
|
68
|
+
"new": "modern new",
|
69
|
+
"build": "modern build",
|
70
|
+
"test": "modern test --passWithNoTests"
|
71
|
+
}
|
72
|
+
}
|
package/src/alias.ts
CHANGED
@@ -69,10 +69,10 @@ export const getAlias = (
|
|
69
69
|
absoluteBaseUrl: baseUrl
|
70
70
|
? path.join(option.appDirectory, baseUrl)
|
71
71
|
: option.appDirectory,
|
72
|
-
paths:
|
73
|
-
aliasOption || {},
|
74
|
-
tsconfig?.compilerOptions?.paths,
|
75
|
-
|
72
|
+
paths: {
|
73
|
+
...(aliasOption || {}),
|
74
|
+
...tsconfig?.compilerOptions?.paths,
|
75
|
+
},
|
76
76
|
isTsPath: true,
|
77
77
|
isTsProject,
|
78
78
|
};
|
package/src/constants.ts
CHANGED
@@ -57,6 +57,7 @@ export const INTERNAL_PLUGINS: {
|
|
57
57
|
'@modern-js/plugin-sass': { cli: '@modern-js/plugin-sass/cli' },
|
58
58
|
'@modern-js/plugin-esbuild': { cli: '@modern-js/plugin-esbuild/cli' },
|
59
59
|
'@modern-js/plugin-proxy': { cli: '@modern-js/plugin-proxy/cli' },
|
60
|
+
'@modern-js/plugin-ssg': { cli: '@modern-js/plugin-ssg/cli' },
|
60
61
|
'@modern-js/plugin-bff': {
|
61
62
|
cli: '@modern-js/plugin-bff/cli',
|
62
63
|
server: '@modern-js/plugin-bff/server',
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import os from 'os';
|
2
2
|
import chalk from 'chalk';
|
3
|
+
import { isDev } from './is';
|
3
4
|
|
4
5
|
// TODO: type
|
5
6
|
interface EntryPoint {
|
@@ -45,14 +46,17 @@ const getAddressUrls = (protocol = 'http', port: number) => {
|
|
45
46
|
);
|
46
47
|
};
|
47
48
|
|
48
|
-
export const prettyInstructions = (appContext: any) => {
|
49
|
+
export const prettyInstructions = (appContext: any, config: any) => {
|
49
50
|
const { entrypoints, serverRoutes, port } = appContext as {
|
50
51
|
entrypoints: EntryPoint[];
|
51
52
|
serverRoutes: ServerRoute[];
|
52
53
|
port: number;
|
53
54
|
};
|
54
55
|
|
55
|
-
const urls = getAddressUrls(
|
56
|
+
const urls = getAddressUrls(
|
57
|
+
config.dev.https && isDev() ? 'https' : 'http',
|
58
|
+
port,
|
59
|
+
);
|
56
60
|
|
57
61
|
const routes = serverRoutes.filter(route => route.entryName);
|
58
62
|
|