@modern-js/utils 1.0.0-alpha.4 → 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 +65 -1
- package/README.md +13 -21
- package/dist/js/modern/alias.js +8 -2
- package/dist/js/modern/constants.js +17 -0
- package/dist/js/modern/prettyInstructions.js +4 -3
- package/dist/js/node/alias.js +8 -3
- package/dist/js/node/constants.js +17 -0
- package/dist/js/node/prettyInstructions.js +4 -2
- package/dist/js/treeshaking/alias.js +8 -2
- package/dist/js/treeshaking/constants.js +17 -0
- package/dist/js/treeshaking/getPort.js +4 -2
- package/dist/js/treeshaking/prettyInstructions.js +4 -3
- package/dist/js/treeshaking/watch.js +8 -6
- package/dist/types/constants.d.ts +6 -0
- package/dist/types/prettyInstructions.d.ts +1 -1
- package/package.json +7 -3
- package/src/alias.ts +5 -5
- package/src/constants.ts +12 -0
- package/src/prettyInstructions.ts +6 -2
package/CHANGELOG.md
CHANGED
@@ -1,6 +1,70 @@
|
|
1
1
|
# @modern-js/utils
|
2
2
|
|
3
|
-
## 1.0.0-
|
3
|
+
## 1.0.0-rc.12
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 224f7fe: fix server route match
|
8
|
+
- 204c626: feat: initial
|
9
|
+
|
10
|
+
## 1.0.0-rc.11
|
11
|
+
|
12
|
+
### Patch Changes
|
13
|
+
|
14
|
+
- 224f7fe: fix server route match
|
15
|
+
- 204c626: feat: initial
|
16
|
+
|
17
|
+
## 1.0.0-rc.10
|
18
|
+
|
19
|
+
### Patch Changes
|
20
|
+
|
21
|
+
- 224f7fe: fix server route match
|
22
|
+
- 204c626: feat: initial
|
23
|
+
|
24
|
+
## 1.0.0-rc.9
|
25
|
+
|
26
|
+
### Patch Changes
|
27
|
+
|
28
|
+
- 224f7fe: fix server route match
|
29
|
+
- 204c626: feat: initial
|
30
|
+
|
31
|
+
## 1.0.0-rc.8
|
32
|
+
|
33
|
+
### Patch Changes
|
34
|
+
|
35
|
+
- 224f7fe: fix server route match
|
36
|
+
- 204c626: feat: initial
|
37
|
+
|
38
|
+
## 1.0.0-rc.7
|
39
|
+
|
40
|
+
### Patch Changes
|
41
|
+
|
42
|
+
- 224f7fe: fix server route match
|
43
|
+
- 204c626: feat: initial
|
44
|
+
|
45
|
+
## 1.0.0-rc.6
|
46
|
+
|
47
|
+
### Patch Changes
|
48
|
+
|
49
|
+
- 224f7fe: fix server route match
|
50
|
+
- 204c626: feat: initial
|
51
|
+
|
52
|
+
## 1.0.0-rc.5
|
53
|
+
|
54
|
+
### Patch Changes
|
55
|
+
|
56
|
+
- 224f7fe: fix server route match
|
57
|
+
- 204c626: feat: initial
|
58
|
+
|
59
|
+
## 1.0.0-rc.4
|
60
|
+
|
61
|
+
### Patch Changes
|
62
|
+
|
63
|
+
- fix server route match
|
64
|
+
- 204c626: feat: initial
|
65
|
+
|
66
|
+
## 1.0.0-rc.3
|
67
|
+
|
4
68
|
### Patch Changes
|
5
69
|
|
6
70
|
- feat: initial
|
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';
|
@@ -31,7 +37,6 @@ export const validAlias = (modernConfig, {
|
|
31
37
|
return null;
|
32
38
|
};
|
33
39
|
export const getAlias = (aliasOption, option) => {
|
34
|
-
const tsconfig = readTsConfigByFile(option.tsconfigPath);
|
35
40
|
const isTsProject = fs.existsSync(option.tsconfigPath);
|
36
41
|
let aliasConfig;
|
37
42
|
|
@@ -47,10 +52,11 @@ export const getAlias = (aliasOption, option) => {
|
|
47
52
|
} else {
|
48
53
|
var _tsconfig$compilerOpt, _tsconfig$compilerOpt2;
|
49
54
|
|
55
|
+
const tsconfig = readTsConfigByFile(option.tsconfigPath);
|
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'
|
@@ -114,6 +117,9 @@ export const INTERNAL_PLUGINS = {
|
|
114
117
|
},
|
115
118
|
'@modern-js/plugin-jarvis': {
|
116
119
|
cli: '@modern-js/plugin-jarvis/cli'
|
120
|
+
},
|
121
|
+
'@modern-js/plugin-tailwindcss': {
|
122
|
+
cli: '@modern-js/plugin-tailwindcss/cli'
|
117
123
|
}
|
118
124
|
};
|
119
125
|
/**
|
@@ -174,6 +180,17 @@ export const PLUGIN_SCHEMAS = {
|
|
174
180
|
typeof: ['object', 'function']
|
175
181
|
}
|
176
182
|
}],
|
183
|
+
'@modern-js/plugin-tailwindcss': [{
|
184
|
+
target: 'tools.tailwind',
|
185
|
+
schema: {
|
186
|
+
typeof: ['object', 'function']
|
187
|
+
}
|
188
|
+
}, {
|
189
|
+
target: 'source.designSystem',
|
190
|
+
schema: {
|
191
|
+
typeof: ['object']
|
192
|
+
}
|
193
|
+
}],
|
177
194
|
'@modern-js/plugin-proxy': [{
|
178
195
|
target: 'dev.proxy',
|
179
196
|
schema: {
|
@@ -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
|
}) => {
|
@@ -48,8 +54,6 @@ const validAlias = (modernConfig, {
|
|
48
54
|
exports.validAlias = validAlias;
|
49
55
|
|
50
56
|
const getAlias = (aliasOption, option) => {
|
51
|
-
const tsconfig = (0, _readTsConfig.readTsConfigByFile)(option.tsconfigPath);
|
52
|
-
|
53
57
|
const isTsProject = _fs.default.existsSync(option.tsconfigPath);
|
54
58
|
|
55
59
|
let aliasConfig;
|
@@ -66,10 +70,11 @@ const getAlias = (aliasOption, option) => {
|
|
66
70
|
} else {
|
67
71
|
var _tsconfig$compilerOpt, _tsconfig$compilerOpt2;
|
68
72
|
|
73
|
+
const tsconfig = (0, _readTsConfig.readTsConfigByFile)(option.tsconfigPath);
|
69
74
|
const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig$compilerOpt = tsconfig.compilerOptions) === null || _tsconfig$compilerOpt === void 0 ? void 0 : _tsconfig$compilerOpt.baseUrl;
|
70
75
|
aliasConfig = {
|
71
76
|
absoluteBaseUrl: baseUrl ? _path.default.join(option.appDirectory, baseUrl) : option.appDirectory,
|
72
|
-
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),
|
73
78
|
isTsPath: true,
|
74
79
|
isTsProject
|
75
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'
|
@@ -130,6 +133,9 @@ const INTERNAL_PLUGINS = {
|
|
130
133
|
},
|
131
134
|
'@modern-js/plugin-jarvis': {
|
132
135
|
cli: '@modern-js/plugin-jarvis/cli'
|
136
|
+
},
|
137
|
+
'@modern-js/plugin-tailwindcss': {
|
138
|
+
cli: '@modern-js/plugin-tailwindcss/cli'
|
133
139
|
}
|
134
140
|
};
|
135
141
|
/**
|
@@ -191,6 +197,17 @@ const PLUGIN_SCHEMAS = {
|
|
191
197
|
typeof: ['object', 'function']
|
192
198
|
}
|
193
199
|
}],
|
200
|
+
'@modern-js/plugin-tailwindcss': [{
|
201
|
+
target: 'tools.tailwind',
|
202
|
+
schema: {
|
203
|
+
typeof: ['object', 'function']
|
204
|
+
}
|
205
|
+
}, {
|
206
|
+
target: 'source.designSystem',
|
207
|
+
schema: {
|
208
|
+
typeof: ['object']
|
209
|
+
}
|
210
|
+
}],
|
194
211
|
'@modern-js/plugin-proxy': [{
|
195
212
|
target: 'dev.proxy',
|
196
213
|
schema: {
|
@@ -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';
|
@@ -26,7 +32,6 @@ export var validAlias = function validAlias(modernConfig, _ref) {
|
|
26
32
|
return null;
|
27
33
|
};
|
28
34
|
export var getAlias = function getAlias(aliasOption, option) {
|
29
|
-
var tsconfig = readTsConfigByFile(option.tsconfigPath);
|
30
35
|
var isTsProject = fs.existsSync(option.tsconfigPath);
|
31
36
|
var aliasConfig;
|
32
37
|
|
@@ -42,10 +47,11 @@ export var getAlias = function getAlias(aliasOption, option) {
|
|
42
47
|
} else {
|
43
48
|
var _tsconfig$compilerOpt, _tsconfig$compilerOpt2;
|
44
49
|
|
50
|
+
var tsconfig = readTsConfigByFile(option.tsconfigPath);
|
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'
|
@@ -116,6 +119,9 @@ export var INTERNAL_PLUGINS = {
|
|
116
119
|
},
|
117
120
|
'@modern-js/plugin-jarvis': {
|
118
121
|
cli: '@modern-js/plugin-jarvis/cli'
|
122
|
+
},
|
123
|
+
'@modern-js/plugin-tailwindcss': {
|
124
|
+
cli: '@modern-js/plugin-tailwindcss/cli'
|
119
125
|
}
|
120
126
|
};
|
121
127
|
/**
|
@@ -174,6 +180,17 @@ export var PLUGIN_SCHEMAS = {
|
|
174
180
|
"typeof": ['object', 'function']
|
175
181
|
}
|
176
182
|
}],
|
183
|
+
'@modern-js/plugin-tailwindcss': [{
|
184
|
+
target: 'tools.tailwind',
|
185
|
+
schema: {
|
186
|
+
"typeof": ['object', 'function']
|
187
|
+
}
|
188
|
+
}, {
|
189
|
+
target: 'source.designSystem',
|
190
|
+
schema: {
|
191
|
+
"typeof": ['object']
|
192
|
+
}
|
193
|
+
}],
|
177
194
|
'@modern-js/plugin-proxy': [{
|
178
195
|
target: 'dev.proxy',
|
179
196
|
schema: {
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
2
|
+
|
1
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
2
4
|
|
3
5
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
@@ -15,13 +17,13 @@ import { logger } from "./logger";
|
|
15
17
|
/* eslint-disable no-param-reassign, @typescript-eslint/no-loop-func */
|
16
18
|
|
17
19
|
export var getPort = /*#__PURE__*/function () {
|
18
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/
|
20
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(port) {
|
19
21
|
var tryLimits,
|
20
22
|
original,
|
21
23
|
found,
|
22
24
|
attempts,
|
23
25
|
_args = arguments;
|
24
|
-
return
|
26
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
25
27
|
while (1) {
|
26
28
|
switch (_context.prev = _context.next) {
|
27
29
|
case 0:
|
@@ -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,3 +1,5 @@
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
2
|
+
|
1
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
2
4
|
|
3
5
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
@@ -20,9 +22,9 @@ export var watch = function watch(watchDir, runTask) {
|
|
20
22
|
return ready = true;
|
21
23
|
});
|
22
24
|
watcher.on('change', /*#__PURE__*/function () {
|
23
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/
|
25
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(filePath) {
|
24
26
|
var changedFilePath;
|
25
|
-
return
|
27
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
26
28
|
while (1) {
|
27
29
|
switch (_context.prev = _context.next) {
|
28
30
|
case 0:
|
@@ -46,9 +48,9 @@ export var watch = function watch(watchDir, runTask) {
|
|
46
48
|
};
|
47
49
|
}());
|
48
50
|
watcher.on('add', /*#__PURE__*/function () {
|
49
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/
|
51
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(filePath) {
|
50
52
|
var changedFilePath;
|
51
|
-
return
|
53
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
52
54
|
while (1) {
|
53
55
|
switch (_context2.prev = _context2.next) {
|
54
56
|
case 0:
|
@@ -78,9 +80,9 @@ export var watch = function watch(watchDir, runTask) {
|
|
78
80
|
};
|
79
81
|
}());
|
80
82
|
watcher.on('unlink', /*#__PURE__*/function () {
|
81
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/
|
83
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(filePath) {
|
82
84
|
var changedFilePath;
|
83
|
-
return
|
85
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
84
86
|
while (1) {
|
85
87
|
switch (_context3.prev = _context3.next) {
|
86
88
|
case 0:
|
@@ -111,6 +111,12 @@ export declare const PLUGIN_SCHEMAS: {
|
|
111
111
|
typeof: string[];
|
112
112
|
};
|
113
113
|
}[];
|
114
|
+
'@modern-js/plugin-tailwindcss': {
|
115
|
+
target: string;
|
116
|
+
schema: {
|
117
|
+
typeof: string[];
|
118
|
+
};
|
119
|
+
}[];
|
114
120
|
'@modern-js/plugin-proxy': {
|
115
121
|
target: string;
|
116
122
|
schema: {
|
@@ -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,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@modern-js/utils",
|
3
|
-
"version": "1.0.0-
|
3
|
+
"version": "1.0.0-rc.12",
|
4
4
|
"jsnext:source": "./src/index.ts",
|
5
5
|
"types": "./dist/types/index.d.ts",
|
6
6
|
"main": "./dist/js/node/index.js",
|
@@ -53,13 +53,17 @@
|
|
53
53
|
"@types/recursive-readdir": "^2.2.0",
|
54
54
|
"typescript": "^4",
|
55
55
|
"webpack": "^5.54.0",
|
56
|
-
"@modern-js/plugin-testing": "^1.0.0-
|
57
|
-
"@modern-js/module-tools": "^1.0.0-
|
56
|
+
"@modern-js/plugin-testing": "^1.0.0-rc.12",
|
57
|
+
"@modern-js/module-tools": "^1.0.0-rc.12"
|
58
58
|
},
|
59
59
|
"peerDependencies": {
|
60
60
|
"typescript": "^4.4.3"
|
61
61
|
},
|
62
62
|
"sideEffects": false,
|
63
|
+
"publishConfig": {
|
64
|
+
"registry": "https://registry.npmjs.org/",
|
65
|
+
"access": "public"
|
66
|
+
},
|
63
67
|
"scripts": {
|
64
68
|
"new": "modern new",
|
65
69
|
"build": "modern build",
|
package/src/alias.ts
CHANGED
@@ -53,7 +53,6 @@ export const getAlias = (
|
|
53
53
|
aliasOption: AliasOption | Array<AliasOption>,
|
54
54
|
option: { appDirectory: string; tsconfigPath: string },
|
55
55
|
) => {
|
56
|
-
const tsconfig = readTsConfigByFile(option.tsconfigPath);
|
57
56
|
const isTsProject = fs.existsSync(option.tsconfigPath);
|
58
57
|
let aliasConfig: IAliasConfig;
|
59
58
|
if (!isTsProject) {
|
@@ -64,15 +63,16 @@ export const getAlias = (
|
|
64
63
|
isTsProject,
|
65
64
|
};
|
66
65
|
} else {
|
66
|
+
const tsconfig = readTsConfigByFile(option.tsconfigPath);
|
67
67
|
const baseUrl = tsconfig?.compilerOptions?.baseUrl;
|
68
68
|
aliasConfig = {
|
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',
|
@@ -87,6 +88,7 @@ export const INTERNAL_PLUGINS: {
|
|
87
88
|
cli: '@modern-js/plugin-micro-frontend/cli',
|
88
89
|
},
|
89
90
|
'@modern-js/plugin-jarvis': { cli: '@modern-js/plugin-jarvis/cli' },
|
91
|
+
'@modern-js/plugin-tailwindcss': { cli: '@modern-js/plugin-tailwindcss/cli' },
|
90
92
|
};
|
91
93
|
|
92
94
|
/**
|
@@ -141,6 +143,16 @@ export const PLUGIN_SCHEMAS = {
|
|
141
143
|
schema: { typeof: ['object', 'function'] },
|
142
144
|
},
|
143
145
|
],
|
146
|
+
'@modern-js/plugin-tailwindcss': [
|
147
|
+
{
|
148
|
+
target: 'tools.tailwind',
|
149
|
+
schema: { typeof: ['object', 'function'] },
|
150
|
+
},
|
151
|
+
{
|
152
|
+
target: 'source.designSystem',
|
153
|
+
schema: { typeof: ['object'] },
|
154
|
+
},
|
155
|
+
],
|
144
156
|
'@modern-js/plugin-proxy': [
|
145
157
|
{
|
146
158
|
target: 'dev.proxy',
|
@@ -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
|
|