@modern-js/utils 1.1.0 → 1.1.4-rc.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/CHANGELOG.md +27 -66
- package/dist/js/modern/alias.js +10 -10
- package/dist/js/modern/compatRequire.js +11 -0
- package/dist/js/modern/constants.js +51 -3
- package/dist/js/modern/getEntryOptions.js +15 -6
- package/dist/js/modern/is/type.js +3 -0
- package/dist/js/modern/logger.js +2 -2
- package/dist/js/modern/monorepo.js +2 -2
- package/dist/js/modern/runtimeExports.js +5 -2
- package/dist/js/node/alias.js +10 -10
- package/dist/js/node/compatRequire.js +16 -2
- package/dist/js/node/constants.js +58 -6
- package/dist/js/node/getEntryOptions.js +16 -6
- package/dist/js/node/is/type.js +5 -0
- package/dist/js/node/logger.js +2 -2
- package/dist/js/node/monorepo.js +2 -2
- package/dist/js/node/runtimeExports.js +8 -2
- package/dist/js/treeshaking/alias.js +9 -9
- package/dist/js/treeshaking/compatRequire.js +14 -0
- package/dist/js/treeshaking/constants.js +51 -3
- package/dist/js/treeshaking/formatWebpackMessages.js +1 -1
- package/dist/js/treeshaking/getEntryOptions.js +16 -5
- package/dist/js/treeshaking/is/type.js +4 -1
- package/dist/js/treeshaking/logger.js +3 -3
- package/dist/js/treeshaking/monorepo.js +2 -2
- package/dist/js/treeshaking/runtimeExports.js +8 -2
- package/dist/types/compatRequire.d.ts +2 -1
- package/dist/types/constants.d.ts +22 -2
- package/dist/types/getEntryOptions.d.ts +1 -1
- package/dist/types/is/type.d.ts +2 -1
- package/dist/types/runtimeExports.d.ts +1 -1
- package/package.json +5 -4
- package/src/alias.ts +7 -7
- package/src/compatRequire.ts +15 -0
- package/src/constants.ts +39 -2
- package/src/getEntryOptions.ts +23 -4
- package/src/is/type.ts +4 -0
- package/src/runtimeExports.ts +12 -1
- package/tests/getEntryOptions.test.ts +11 -0
package/CHANGELOG.md
CHANGED
@@ -1,85 +1,46 @@
|
|
1
1
|
# @modern-js/utils
|
2
2
|
|
3
|
-
## 1.1.0
|
4
|
-
|
5
|
-
### Minor Changes
|
6
|
-
|
7
|
-
- 96119db2: Relese v1.1.0
|
8
|
-
|
9
|
-
1. 全面支持 Windows 平台
|
10
|
-
|
11
|
-
ISSUE:
|
12
|
-
|
13
|
-
- [182](https://github.com/modern-js-dev/modern.js/issues/182)
|
14
|
-
- [236](https://github.com/modern-js-dev/modern.js/issues/236)
|
15
|
-
|
16
|
-
PR
|
17
|
-
|
18
|
-
- [219](https://github.com/modern-js-dev/modern.js/pull/219)
|
19
|
-
- [247](https://github.com/modern-js-dev/modern.js/pull/247)
|
20
|
-
- [249](https://github.com/modern-js-dev/modern.js/pull/249)
|
21
|
-
- [253](https://github.com/modern-js-dev/modern.js/pull/253)
|
22
|
-
- [268](https://github.com/modern-js-dev/modern.js/pull/268)
|
23
|
-
- [270](https://github.com/modern-js-dev/modern.js/pull/270)
|
24
|
-
- [273](https://github.com/modern-js-dev/modern.js/pull/273)
|
25
|
-
- [276](https://github.com/modern-js-dev/modern.js/pull/276)
|
26
|
-
|
27
|
-
2. 修复 Unbundled 模式启用问题
|
28
|
-
|
29
|
-
ISSUE
|
30
|
-
|
31
|
-
- [186](https://github.com/modern-js-dev/modern.js/issues/186)
|
32
|
-
- [224](https://github.com/modern-js-dev/modern.js/issues/224)
|
33
|
-
- [225](https://github.com/modern-js-dev/modern.js/issues/225)
|
34
|
-
- [238](https://github.com/modern-js-dev/modern.js/issues/238)
|
35
|
-
|
36
|
-
PR
|
3
|
+
## 1.1.4-rc.0
|
37
4
|
|
38
|
-
|
39
|
-
- [264](https://github.com/modern-js-dev/modern.js/pull/264)
|
40
|
-
- [codesmith-12](https://github.com/modern-js-dev/codesmith/pull/12)
|
41
|
-
|
42
|
-
3. 修复模块工程方案 .npmignore 文件初始化未生成
|
43
|
-
|
44
|
-
ISSUE
|
45
|
-
|
46
|
-
- [198](https://github.com/modern-js-dev/modern.js/issues/198)
|
47
|
-
|
48
|
-
PR
|
49
|
-
|
50
|
-
- [209](https://github.com/modern-js-dev/modern.js/pull/209)
|
51
|
-
|
52
|
-
4. 修复 Storybook 使用时浏览器打开页面报错
|
53
|
-
|
54
|
-
ISSUE
|
5
|
+
### Patch Changes
|
55
6
|
|
56
|
-
|
7
|
+
- d927bc83: update plugins list
|
8
|
+
- d73ff455: support multi process product
|
9
|
+
- 9c1ab865: fix: filter invalid ts paths
|
10
|
+
- d73ff455: support multi process product
|
11
|
+
- d73ff455: support multi process product
|
12
|
+
- d73ff455: support multi process product
|
13
|
+
- d73ff455: support multi process product
|
57
14
|
|
58
|
-
|
15
|
+
## 1.1.3
|
59
16
|
|
60
|
-
|
17
|
+
### Patch Changes
|
61
18
|
|
62
|
-
|
19
|
+
- 085a6a58: refactor server plugin
|
20
|
+
- 085a6a58: refactor server plugin
|
21
|
+
- 085a6a58: refactor server conifg
|
22
|
+
- d280ea33: chore: runtime exports can choose to generate d.ts file
|
23
|
+
- 085a6a58: support server runtime
|
24
|
+
- 085a6a58: feat: refactor server plugin
|
63
25
|
|
64
|
-
|
26
|
+
## 1.1.2
|
65
27
|
|
66
|
-
|
67
|
-
- [257](https://github.com/modern-js-dev/modern.js/issues/257)
|
28
|
+
### Patch Changes
|
68
29
|
|
69
|
-
|
30
|
+
- 0fa83663: support more .env files
|
31
|
+
- f594fbc8: fix apple icon and favicon support
|
70
32
|
|
71
|
-
|
72
|
-
- [271](https://github.com/modern-js-dev/modern.js/pull/271)
|
33
|
+
## 1.1.1
|
73
34
|
|
74
|
-
|
35
|
+
### Patch Changes
|
75
36
|
|
76
|
-
|
37
|
+
- c0fc0700: feat: support deploy plugin
|
77
38
|
|
78
|
-
|
39
|
+
## 1.1.0
|
79
40
|
|
80
|
-
|
41
|
+
### Minor Changes
|
81
42
|
|
82
|
-
|
43
|
+
- 96119db2: Relese v1.1.0
|
83
44
|
|
84
45
|
## 1.0.0
|
85
46
|
|
package/dist/js/modern/alias.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
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
2
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
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
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
|
|
@@ -63,12 +63,12 @@ export const getAlias = (aliasOption, option) => {
|
|
63
63
|
}
|
64
64
|
|
65
65
|
return aliasConfig;
|
66
|
-
};
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
return userKeys.reduce((o, k) => {
|
66
|
+
}; // filter invalid ts paths that are not array
|
67
|
+
|
68
|
+
export const getUserAlias = (alias = {}) => Object.keys(alias).reduce((o, k) => {
|
69
|
+
if (Array.isArray(alias[k])) {
|
71
70
|
o[k] = alias[k];
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
}
|
72
|
+
|
73
|
+
return o;
|
74
|
+
}, {});
|
@@ -1,10 +1,21 @@
|
|
1
|
+
import { findExists } from "./findExists";
|
1
2
|
/**
|
2
3
|
* Require function compatible with esm and cjs module.
|
3
4
|
* @param filePath - File to required.
|
4
5
|
* @returns module export object.
|
5
6
|
*/
|
7
|
+
|
6
8
|
export const compatRequire = filePath => {
|
7
9
|
const mod = require(filePath);
|
8
10
|
|
9
11
|
return mod !== null && mod !== void 0 && mod.__esModule ? mod.default : mod;
|
12
|
+
};
|
13
|
+
export const requireExistModule = (filename, extensions = ['.ts', '.js']) => {
|
14
|
+
const exist = findExists(extensions.map(ext => `${filename}${ext}`));
|
15
|
+
|
16
|
+
if (!exist) {
|
17
|
+
return null;
|
18
|
+
}
|
19
|
+
|
20
|
+
return compatRequire(exist);
|
10
21
|
};
|
@@ -17,6 +17,11 @@ export const HMR_SOCK_PATH = '/_modern_js_hmr_ws';
|
|
17
17
|
*/
|
18
18
|
|
19
19
|
export const ROUTE_SPEC_FILE = 'route.json';
|
20
|
+
/**
|
21
|
+
* main entry name
|
22
|
+
*/
|
23
|
+
|
24
|
+
export const MAIN_ENTRY_NAME = 'main';
|
20
25
|
/**
|
21
26
|
* open editor request path
|
22
27
|
*/
|
@@ -42,7 +47,18 @@ export const SERVER_RENDER_FUNCTION_NAME = 'serverRender';
|
|
42
47
|
*/
|
43
48
|
|
44
49
|
export const LOADABLE_STATS_FILE = 'loadable-stats.json';
|
50
|
+
/**
|
51
|
+
* real entry generate by modern.js
|
52
|
+
*/
|
53
|
+
|
45
54
|
export const HIDE_MODERN_JS_DIR = './node_modules/.modern-js';
|
55
|
+
/**
|
56
|
+
* internal specified folder
|
57
|
+
*/
|
58
|
+
|
59
|
+
export const API_DIR = 'api';
|
60
|
+
export const SERVER_DIR = 'server';
|
61
|
+
export const SHARED_DIR = 'shared';
|
46
62
|
/**
|
47
63
|
* Internal plugins that work as soon as they are installed.
|
48
64
|
*/
|
@@ -113,6 +129,10 @@ export const INTERNAL_PLUGINS = {
|
|
113
129
|
'@modern-js/plugin-server-build': {
|
114
130
|
cli: '@modern-js/plugin-server-build'
|
115
131
|
},
|
132
|
+
'@modern-js/plugin-server': {
|
133
|
+
cli: '@modern-js/plugin-server/cli',
|
134
|
+
server: '@modern-js/plugin-server/server'
|
135
|
+
},
|
116
136
|
'@modern-js/plugin-micro-frontend': {
|
117
137
|
cli: '@modern-js/plugin-micro-frontend/cli'
|
118
138
|
},
|
@@ -121,6 +141,30 @@ export const INTERNAL_PLUGINS = {
|
|
121
141
|
},
|
122
142
|
'@modern-js/plugin-tailwindcss': {
|
123
143
|
cli: '@modern-js/plugin-tailwindcss/cli'
|
144
|
+
},
|
145
|
+
'@modern-js/plugin-lambda-fc': {
|
146
|
+
cli: '@modern-js/plugin-lambda-fc/cli'
|
147
|
+
},
|
148
|
+
'@modern-js/plugin-lambda-scf': {
|
149
|
+
cli: '@modern-js/plugin-lambda-scf/cli'
|
150
|
+
},
|
151
|
+
'@modern-js/plugin-cdn-oss': {
|
152
|
+
cli: '@modern-js/plugin-cdn-oss/cli'
|
153
|
+
},
|
154
|
+
'@modern-js/plugin-cdn-cos': {
|
155
|
+
cli: '@modern-js/plugin-cdn-cos/cli'
|
156
|
+
},
|
157
|
+
'@modern-js/plugin-static-hosting': {
|
158
|
+
cli: '@modern-js/plugin-static-hosting/cli'
|
159
|
+
},
|
160
|
+
'@modern-js/plugin-polyfill': {
|
161
|
+
server: '@modern-js/plugin-polyfill'
|
162
|
+
},
|
163
|
+
'@modern-js/plugin-multiprocess': {
|
164
|
+
cli: '@modern-js/plugin-multiprocess/cli'
|
165
|
+
},
|
166
|
+
'@modern-js/plugin-nocode': {
|
167
|
+
cli: '@modern-js/plugin-nocode/cli'
|
124
168
|
}
|
125
169
|
};
|
126
170
|
/**
|
@@ -152,7 +196,10 @@ export const PLUGIN_SCHEMAS = {
|
|
152
196
|
type: 'object',
|
153
197
|
properties: {
|
154
198
|
prefix: {
|
155
|
-
type: 'string'
|
199
|
+
type: ['string', 'array'],
|
200
|
+
items: {
|
201
|
+
type: 'string'
|
202
|
+
}
|
156
203
|
},
|
157
204
|
fetcher: {
|
158
205
|
type: 'string'
|
@@ -160,7 +207,7 @@ export const PLUGIN_SCHEMAS = {
|
|
160
207
|
proxy: {
|
161
208
|
type: 'object'
|
162
209
|
},
|
163
|
-
|
210
|
+
requestCreator: {
|
164
211
|
type: 'string'
|
165
212
|
}
|
166
213
|
}
|
@@ -263,5 +310,6 @@ export const PLUGIN_SCHEMAS = {
|
|
263
310
|
schema: {
|
264
311
|
type: ['object']
|
265
312
|
}
|
266
|
-
}]
|
313
|
+
}],
|
314
|
+
'@modern-js/plugin-nocode': []
|
267
315
|
};
|
@@ -1,15 +1,24 @@
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
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
2
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
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
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
7
|
import { isPlainObject } from "./is";
|
8
|
-
|
8
|
+
import { MAIN_ENTRY_NAME } from "./constants";
|
9
|
+
export const getEntryOptions = (name, baseOptions, optionsByEntries, packageName) => {
|
9
10
|
if (optionsByEntries) {
|
10
|
-
//
|
11
|
-
|
11
|
+
let optionsByEntry = getOptionsByEntryName(name, optionsByEntries); // compatible with main entry using packageName as the key
|
12
|
+
|
13
|
+
if (optionsByEntry === undefined && name === MAIN_ENTRY_NAME && packageName) {
|
14
|
+
optionsByEntry = getOptionsByEntryName(packageName, optionsByEntries);
|
15
|
+
} // eslint-disable-next-line no-nested-ternary
|
16
|
+
|
17
|
+
|
18
|
+
return optionsByEntry !== undefined ? isPlainObject(optionsByEntry) && isPlainObject(baseOptions) ? _objectSpread(_objectSpread({}, baseOptions), optionsByEntry) : optionsByEntry : baseOptions;
|
12
19
|
} else {
|
13
20
|
return baseOptions;
|
14
21
|
}
|
15
|
-
};
|
22
|
+
};
|
23
|
+
|
24
|
+
const getOptionsByEntryName = (name, optionsByEntries) => optionsByEntries.hasOwnProperty(name) ? optionsByEntries[name] : undefined;
|
@@ -22,4 +22,7 @@ export function isPromise(obj) {
|
|
22
22
|
/* eslint-disable promise/prefer-await-to-then */
|
23
23
|
return Boolean(obj) && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
|
24
24
|
/* eslint-enable promise/prefer-await-to-then */
|
25
|
+
}
|
26
|
+
export function isRegExp(obj) {
|
27
|
+
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
25
28
|
}
|
package/dist/js/modern/logger.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
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
2
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
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
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
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
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
2
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
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
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
|
|
@@ -18,8 +18,9 @@ const memo = fn => {
|
|
18
18
|
};
|
19
19
|
};
|
20
20
|
|
21
|
-
export const createRuntimeExportsUtils = memo((pwd, namespace) => {
|
22
|
-
const entryExportFile = path.join(pwd, `.runtime-exports/${namespace ? `${namespace}.js` : 'index.js'}`);
|
21
|
+
export const createRuntimeExportsUtils = memo((pwd = '', namespace, ts = false) => {
|
22
|
+
const entryExportFile = path.join(pwd, `.runtime-exports/${namespace ? `${namespace}.js` : 'index.js'}`);
|
23
|
+
const entryExportTsFile = path.join(pwd, `.runtime-exports/${namespace ? `${namespace}.d.ts` : 'index.d.ts'}`); // const ensure = () => {
|
23
24
|
// if (!fs.existsSync(entryExportFile)) {
|
24
25
|
// fs.outputFileSync(entryExportFile, '');
|
25
26
|
// }
|
@@ -32,9 +33,11 @@ export const createRuntimeExportsUtils = memo((pwd, namespace) => {
|
|
32
33
|
|
33
34
|
try {
|
34
35
|
fs.ensureFileSync(entryExportFile);
|
36
|
+
fs.ensureFileSync(entryExportTsFile);
|
35
37
|
|
36
38
|
if (!fs.readFileSync(entryExportFile, 'utf8').includes(statement)) {
|
37
39
|
fs.appendFileSync(entryExportFile, `${statement}\n`);
|
40
|
+
ts && fs.appendFileSync(entryExportTsFile, `${statement.replace('.js', '.d')}\n`);
|
38
41
|
}
|
39
42
|
} catch (_unused) {// FIXME:
|
40
43
|
}
|
package/dist/js/node/alias.js
CHANGED
@@ -17,9 +17,9 @@ 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);
|
20
|
+
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; }
|
21
21
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
22
|
+
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; }
|
23
23
|
|
24
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
25
|
|
@@ -81,17 +81,17 @@ const getAlias = (aliasOption, option) => {
|
|
81
81
|
}
|
82
82
|
|
83
83
|
return aliasConfig;
|
84
|
-
};
|
84
|
+
}; // filter invalid ts paths that are not array
|
85
|
+
|
85
86
|
|
86
87
|
exports.getAlias = getAlias;
|
87
88
|
|
88
|
-
const getUserAlias = (alias = {}) => {
|
89
|
-
|
90
|
-
const userKeys = keys.filter(key => !key.includes('@modern-js/runtime'));
|
91
|
-
return userKeys.reduce((o, k) => {
|
89
|
+
const getUserAlias = (alias = {}) => Object.keys(alias).reduce((o, k) => {
|
90
|
+
if (Array.isArray(alias[k])) {
|
92
91
|
o[k] = alias[k];
|
93
|
-
|
94
|
-
|
95
|
-
|
92
|
+
}
|
93
|
+
|
94
|
+
return o;
|
95
|
+
}, {});
|
96
96
|
|
97
97
|
exports.getUserAlias = getUserAlias;
|
@@ -3,7 +3,9 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.compatRequire = void 0;
|
6
|
+
exports.requireExistModule = exports.compatRequire = void 0;
|
7
|
+
|
8
|
+
var _findExists = require("./findExists");
|
7
9
|
|
8
10
|
/**
|
9
11
|
* Require function compatible with esm and cjs module.
|
@@ -16,4 +18,16 @@ const compatRequire = filePath => {
|
|
16
18
|
return mod !== null && mod !== void 0 && mod.__esModule ? mod.default : mod;
|
17
19
|
};
|
18
20
|
|
19
|
-
exports.compatRequire = compatRequire;
|
21
|
+
exports.compatRequire = compatRequire;
|
22
|
+
|
23
|
+
const requireExistModule = (filename, extensions = ['.ts', '.js']) => {
|
24
|
+
const exist = (0, _findExists.findExists)(extensions.map(ext => `${filename}${ext}`));
|
25
|
+
|
26
|
+
if (!exist) {
|
27
|
+
return null;
|
28
|
+
}
|
29
|
+
|
30
|
+
return compatRequire(exist);
|
31
|
+
};
|
32
|
+
|
33
|
+
exports.requireExistModule = requireExistModule;
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.SERVER_RENDER_FUNCTION_NAME = exports.SERVER_BUNDLE_DIRECTORY = exports.ROUTE_SPEC_FILE = exports.PLUGIN_SCHEMAS = exports.LOADABLE_STATS_FILE = exports.LAUNCH_EDITOR_ENDPOINT = exports.INTERNAL_SRC_ALIAS = exports.INTERNAL_PLUGINS = exports.INTERNAL_DIR_ALAIS = exports.HMR_SOCK_PATH = exports.HIDE_MODERN_JS_DIR = exports.ENTRY_NAME_PATTERN = void 0;
|
6
|
+
exports.SHARED_DIR = exports.SERVER_RENDER_FUNCTION_NAME = exports.SERVER_DIR = exports.SERVER_BUNDLE_DIRECTORY = exports.ROUTE_SPEC_FILE = exports.PLUGIN_SCHEMAS = exports.MAIN_ENTRY_NAME = exports.LOADABLE_STATS_FILE = exports.LAUNCH_EDITOR_ENDPOINT = exports.INTERNAL_SRC_ALIAS = exports.INTERNAL_PLUGINS = exports.INTERNAL_DIR_ALAIS = exports.HMR_SOCK_PATH = exports.HIDE_MODERN_JS_DIR = exports.ENTRY_NAME_PATTERN = exports.API_DIR = void 0;
|
7
7
|
|
8
8
|
/**
|
9
9
|
* alias to src directory
|
@@ -28,10 +28,16 @@ const HMR_SOCK_PATH = '/_modern_js_hmr_ws';
|
|
28
28
|
exports.HMR_SOCK_PATH = HMR_SOCK_PATH;
|
29
29
|
const ROUTE_SPEC_FILE = 'route.json';
|
30
30
|
/**
|
31
|
-
*
|
31
|
+
* main entry name
|
32
32
|
*/
|
33
33
|
|
34
34
|
exports.ROUTE_SPEC_FILE = ROUTE_SPEC_FILE;
|
35
|
+
const MAIN_ENTRY_NAME = 'main';
|
36
|
+
/**
|
37
|
+
* open editor request path
|
38
|
+
*/
|
39
|
+
|
40
|
+
exports.MAIN_ENTRY_NAME = MAIN_ENTRY_NAME;
|
35
41
|
const LAUNCH_EDITOR_ENDPOINT = '/__open-stack-frame-in-editor';
|
36
42
|
/**
|
37
43
|
* server side bundles directory, which relative to dist.
|
@@ -57,13 +63,27 @@ const SERVER_RENDER_FUNCTION_NAME = 'serverRender';
|
|
57
63
|
|
58
64
|
exports.SERVER_RENDER_FUNCTION_NAME = SERVER_RENDER_FUNCTION_NAME;
|
59
65
|
const LOADABLE_STATS_FILE = 'loadable-stats.json';
|
66
|
+
/**
|
67
|
+
* real entry generate by modern.js
|
68
|
+
*/
|
69
|
+
|
60
70
|
exports.LOADABLE_STATS_FILE = LOADABLE_STATS_FILE;
|
61
71
|
const HIDE_MODERN_JS_DIR = './node_modules/.modern-js';
|
62
72
|
/**
|
63
|
-
*
|
73
|
+
* internal specified folder
|
64
74
|
*/
|
65
75
|
|
66
76
|
exports.HIDE_MODERN_JS_DIR = HIDE_MODERN_JS_DIR;
|
77
|
+
const API_DIR = 'api';
|
78
|
+
exports.API_DIR = API_DIR;
|
79
|
+
const SERVER_DIR = 'server';
|
80
|
+
exports.SERVER_DIR = SERVER_DIR;
|
81
|
+
const SHARED_DIR = 'shared';
|
82
|
+
/**
|
83
|
+
* Internal plugins that work as soon as they are installed.
|
84
|
+
*/
|
85
|
+
|
86
|
+
exports.SHARED_DIR = SHARED_DIR;
|
67
87
|
const INTERNAL_PLUGINS = {
|
68
88
|
'@modern-js/app-tools': {
|
69
89
|
cli: '@modern-js/app-tools/cli'
|
@@ -130,6 +150,10 @@ const INTERNAL_PLUGINS = {
|
|
130
150
|
'@modern-js/plugin-server-build': {
|
131
151
|
cli: '@modern-js/plugin-server-build'
|
132
152
|
},
|
153
|
+
'@modern-js/plugin-server': {
|
154
|
+
cli: '@modern-js/plugin-server/cli',
|
155
|
+
server: '@modern-js/plugin-server/server'
|
156
|
+
},
|
133
157
|
'@modern-js/plugin-micro-frontend': {
|
134
158
|
cli: '@modern-js/plugin-micro-frontend/cli'
|
135
159
|
},
|
@@ -138,6 +162,30 @@ const INTERNAL_PLUGINS = {
|
|
138
162
|
},
|
139
163
|
'@modern-js/plugin-tailwindcss': {
|
140
164
|
cli: '@modern-js/plugin-tailwindcss/cli'
|
165
|
+
},
|
166
|
+
'@modern-js/plugin-lambda-fc': {
|
167
|
+
cli: '@modern-js/plugin-lambda-fc/cli'
|
168
|
+
},
|
169
|
+
'@modern-js/plugin-lambda-scf': {
|
170
|
+
cli: '@modern-js/plugin-lambda-scf/cli'
|
171
|
+
},
|
172
|
+
'@modern-js/plugin-cdn-oss': {
|
173
|
+
cli: '@modern-js/plugin-cdn-oss/cli'
|
174
|
+
},
|
175
|
+
'@modern-js/plugin-cdn-cos': {
|
176
|
+
cli: '@modern-js/plugin-cdn-cos/cli'
|
177
|
+
},
|
178
|
+
'@modern-js/plugin-static-hosting': {
|
179
|
+
cli: '@modern-js/plugin-static-hosting/cli'
|
180
|
+
},
|
181
|
+
'@modern-js/plugin-polyfill': {
|
182
|
+
server: '@modern-js/plugin-polyfill'
|
183
|
+
},
|
184
|
+
'@modern-js/plugin-multiprocess': {
|
185
|
+
cli: '@modern-js/plugin-multiprocess/cli'
|
186
|
+
},
|
187
|
+
'@modern-js/plugin-nocode': {
|
188
|
+
cli: '@modern-js/plugin-nocode/cli'
|
141
189
|
}
|
142
190
|
};
|
143
191
|
/**
|
@@ -170,7 +218,10 @@ const PLUGIN_SCHEMAS = {
|
|
170
218
|
type: 'object',
|
171
219
|
properties: {
|
172
220
|
prefix: {
|
173
|
-
type: 'string'
|
221
|
+
type: ['string', 'array'],
|
222
|
+
items: {
|
223
|
+
type: 'string'
|
224
|
+
}
|
174
225
|
},
|
175
226
|
fetcher: {
|
176
227
|
type: 'string'
|
@@ -178,7 +229,7 @@ const PLUGIN_SCHEMAS = {
|
|
178
229
|
proxy: {
|
179
230
|
type: 'object'
|
180
231
|
},
|
181
|
-
|
232
|
+
requestCreator: {
|
182
233
|
type: 'string'
|
183
234
|
}
|
184
235
|
}
|
@@ -281,6 +332,7 @@ const PLUGIN_SCHEMAS = {
|
|
281
332
|
schema: {
|
282
333
|
type: ['object']
|
283
334
|
}
|
284
|
-
}]
|
335
|
+
}],
|
336
|
+
'@modern-js/plugin-nocode': []
|
285
337
|
};
|
286
338
|
exports.PLUGIN_SCHEMAS = PLUGIN_SCHEMAS;
|
@@ -7,19 +7,29 @@ exports.getEntryOptions = void 0;
|
|
7
7
|
|
8
8
|
var _is = require("./is");
|
9
9
|
|
10
|
-
|
10
|
+
var _constants = require("./constants");
|
11
11
|
|
12
|
-
function
|
12
|
+
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; }
|
13
|
+
|
14
|
+
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; }
|
13
15
|
|
14
16
|
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
17
|
|
16
|
-
const getEntryOptions = (name, baseOptions, optionsByEntries) => {
|
18
|
+
const getEntryOptions = (name, baseOptions, optionsByEntries, packageName) => {
|
17
19
|
if (optionsByEntries) {
|
18
|
-
//
|
19
|
-
|
20
|
+
let optionsByEntry = getOptionsByEntryName(name, optionsByEntries); // compatible with main entry using packageName as the key
|
21
|
+
|
22
|
+
if (optionsByEntry === undefined && name === _constants.MAIN_ENTRY_NAME && packageName) {
|
23
|
+
optionsByEntry = getOptionsByEntryName(packageName, optionsByEntries);
|
24
|
+
} // eslint-disable-next-line no-nested-ternary
|
25
|
+
|
26
|
+
|
27
|
+
return optionsByEntry !== undefined ? (0, _is.isPlainObject)(optionsByEntry) && (0, _is.isPlainObject)(baseOptions) ? _objectSpread(_objectSpread({}, baseOptions), optionsByEntry) : optionsByEntry : baseOptions;
|
20
28
|
} else {
|
21
29
|
return baseOptions;
|
22
30
|
}
|
23
31
|
};
|
24
32
|
|
25
|
-
exports.getEntryOptions = getEntryOptions;
|
33
|
+
exports.getEntryOptions = getEntryOptions;
|
34
|
+
|
35
|
+
const getOptionsByEntryName = (name, optionsByEntries) => optionsByEntries.hasOwnProperty(name) ? optionsByEntries[name] : undefined;
|
package/dist/js/node/is/type.js
CHANGED
@@ -8,6 +8,7 @@ exports.isFunction = isFunction;
|
|
8
8
|
exports.isObject = isObject;
|
9
9
|
exports.isPlainObject = isPlainObject;
|
10
10
|
exports.isPromise = isPromise;
|
11
|
+
exports.isRegExp = isRegExp;
|
11
12
|
exports.isString = isString;
|
12
13
|
exports.isUndefined = isUndefined;
|
13
14
|
|
@@ -41,4 +42,8 @@ function isPromise(obj) {
|
|
41
42
|
/* eslint-disable promise/prefer-await-to-then */
|
42
43
|
return Boolean(obj) && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
|
43
44
|
/* eslint-enable promise/prefer-await-to-then */
|
45
|
+
}
|
46
|
+
|
47
|
+
function isRegExp(obj) {
|
48
|
+
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
44
49
|
}
|
package/dist/js/node/logger.js
CHANGED
@@ -9,9 +9,9 @@ var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
9
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
11
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
12
|
+
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; }
|
13
13
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
14
|
+
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; }
|
15
15
|
|
16
16
|
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; }
|
17
17
|
|
package/dist/js/node/monorepo.js
CHANGED
@@ -15,9 +15,9 @@ var _yaml = _interopRequireDefault(require("yaml"));
|
|
15
15
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
17
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
18
|
+
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; }
|
19
19
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
20
|
+
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; }
|
21
21
|
|
22
22
|
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; }
|
23
23
|
|