@modern-js/utils 1.1.2 → 1.1.5
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 +29 -0
- package/dist/js/modern/alias.js +10 -10
- package/dist/js/modern/compatRequire.js +11 -0
- package/dist/js/modern/constants.js +28 -3
- package/dist/js/modern/getEntryOptions.js +2 -2
- 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/modern/watch.js +1 -1
- package/dist/js/node/alias.js +10 -10
- package/dist/js/node/compatRequire.js +16 -2
- package/dist/js/node/constants.js +33 -5
- package/dist/js/node/getEntryOptions.js +2 -2
- 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/node/watch.js +1 -1
- package/dist/js/treeshaking/alias.js +9 -9
- package/dist/js/treeshaking/compatRequire.js +14 -0
- package/dist/js/treeshaking/constants.js +28 -3
- package/dist/js/treeshaking/formatWebpackMessages.js +1 -1
- package/dist/js/treeshaking/getEntryOptions.js +2 -2
- package/dist/js/treeshaking/is/type.js +1 -1
- package/dist/js/treeshaking/logger.js +3 -3
- package/dist/js/treeshaking/monorepo.js +2 -2
- package/dist/js/treeshaking/runtimeExports.js +5 -1
- package/dist/js/treeshaking/watch.js +1 -1
- package/dist/types/compatRequire.d.ts +2 -1
- package/dist/types/constants.d.ts +17 -2
- package/dist/types/runtimeExports.d.ts +1 -1
- package/dist/types/watch.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 +26 -2
- package/src/runtimeExports.ts +43 -30
- package/src/watch.ts +2 -2
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
# @modern-js/utils
|
2
2
|
|
3
|
+
## 1.1.5
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- ca7dcb32: change watch logic
|
8
|
+
|
9
|
+
## 1.1.4
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- d927bc83: update plugins list
|
14
|
+
- d73ff455: support multi process product
|
15
|
+
- 9c1ab865: fix: filter invalid ts paths
|
16
|
+
- d73ff455: support multi process product
|
17
|
+
- d73ff455: support multi process product
|
18
|
+
- d73ff455: support multi process product
|
19
|
+
- d73ff455: support multi process product
|
20
|
+
|
21
|
+
## 1.1.3
|
22
|
+
|
23
|
+
### Patch Changes
|
24
|
+
|
25
|
+
- 085a6a58: refactor server plugin
|
26
|
+
- 085a6a58: refactor server plugin
|
27
|
+
- 085a6a58: refactor server conifg
|
28
|
+
- d280ea33: chore: runtime exports can choose to generate d.ts file
|
29
|
+
- 085a6a58: support server runtime
|
30
|
+
- 085a6a58: feat: refactor server plugin
|
31
|
+
|
3
32
|
## 1.1.2
|
4
33
|
|
5
34
|
### Patch Changes
|
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
|
};
|
@@ -47,7 +47,18 @@ export const SERVER_RENDER_FUNCTION_NAME = 'serverRender';
|
|
47
47
|
*/
|
48
48
|
|
49
49
|
export const LOADABLE_STATS_FILE = 'loadable-stats.json';
|
50
|
+
/**
|
51
|
+
* real entry generate by modern.js
|
52
|
+
*/
|
53
|
+
|
50
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';
|
51
62
|
/**
|
52
63
|
* Internal plugins that work as soon as they are installed.
|
53
64
|
*/
|
@@ -118,6 +129,10 @@ export const INTERNAL_PLUGINS = {
|
|
118
129
|
'@modern-js/plugin-server-build': {
|
119
130
|
cli: '@modern-js/plugin-server-build'
|
120
131
|
},
|
132
|
+
'@modern-js/plugin-server': {
|
133
|
+
cli: '@modern-js/plugin-server/cli',
|
134
|
+
server: '@modern-js/plugin-server/server'
|
135
|
+
},
|
121
136
|
'@modern-js/plugin-micro-frontend': {
|
122
137
|
cli: '@modern-js/plugin-micro-frontend/cli'
|
123
138
|
},
|
@@ -144,6 +159,12 @@ export const INTERNAL_PLUGINS = {
|
|
144
159
|
},
|
145
160
|
'@modern-js/plugin-polyfill': {
|
146
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'
|
147
168
|
}
|
148
169
|
};
|
149
170
|
/**
|
@@ -175,7 +196,10 @@ export const PLUGIN_SCHEMAS = {
|
|
175
196
|
type: 'object',
|
176
197
|
properties: {
|
177
198
|
prefix: {
|
178
|
-
type: 'string'
|
199
|
+
type: ['string', 'array'],
|
200
|
+
items: {
|
201
|
+
type: 'string'
|
202
|
+
}
|
179
203
|
},
|
180
204
|
fetcher: {
|
181
205
|
type: 'string'
|
@@ -183,7 +207,7 @@ export const PLUGIN_SCHEMAS = {
|
|
183
207
|
proxy: {
|
184
208
|
type: 'object'
|
185
209
|
},
|
186
|
-
|
210
|
+
requestCreator: {
|
187
211
|
type: 'string'
|
188
212
|
}
|
189
213
|
}
|
@@ -286,5 +310,6 @@ export const PLUGIN_SCHEMAS = {
|
|
286
310
|
schema: {
|
287
311
|
type: ['object']
|
288
312
|
}
|
289
|
-
}]
|
313
|
+
}],
|
314
|
+
'@modern-js/plugin-nocode': []
|
290
315
|
};
|
@@ -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
|
|
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/modern/watch.js
CHANGED
@@ -8,7 +8,7 @@ export const WatchChangeType = {
|
|
8
8
|
};
|
9
9
|
export const watch = (watchDir, runTask, ignored = []) => {
|
10
10
|
let ready = false;
|
11
|
-
const watcher = chokidar.watch(
|
11
|
+
const watcher = chokidar.watch(watchDir, {
|
12
12
|
ignored
|
13
13
|
});
|
14
14
|
watcher.on('ready', () => ready = true);
|
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.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 = 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
|
@@ -63,13 +63,27 @@ const SERVER_RENDER_FUNCTION_NAME = 'serverRender';
|
|
63
63
|
|
64
64
|
exports.SERVER_RENDER_FUNCTION_NAME = SERVER_RENDER_FUNCTION_NAME;
|
65
65
|
const LOADABLE_STATS_FILE = 'loadable-stats.json';
|
66
|
+
/**
|
67
|
+
* real entry generate by modern.js
|
68
|
+
*/
|
69
|
+
|
66
70
|
exports.LOADABLE_STATS_FILE = LOADABLE_STATS_FILE;
|
67
71
|
const HIDE_MODERN_JS_DIR = './node_modules/.modern-js';
|
68
72
|
/**
|
69
|
-
*
|
73
|
+
* internal specified folder
|
70
74
|
*/
|
71
75
|
|
72
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;
|
73
87
|
const INTERNAL_PLUGINS = {
|
74
88
|
'@modern-js/app-tools': {
|
75
89
|
cli: '@modern-js/app-tools/cli'
|
@@ -136,6 +150,10 @@ const INTERNAL_PLUGINS = {
|
|
136
150
|
'@modern-js/plugin-server-build': {
|
137
151
|
cli: '@modern-js/plugin-server-build'
|
138
152
|
},
|
153
|
+
'@modern-js/plugin-server': {
|
154
|
+
cli: '@modern-js/plugin-server/cli',
|
155
|
+
server: '@modern-js/plugin-server/server'
|
156
|
+
},
|
139
157
|
'@modern-js/plugin-micro-frontend': {
|
140
158
|
cli: '@modern-js/plugin-micro-frontend/cli'
|
141
159
|
},
|
@@ -162,6 +180,12 @@ const INTERNAL_PLUGINS = {
|
|
162
180
|
},
|
163
181
|
'@modern-js/plugin-polyfill': {
|
164
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'
|
165
189
|
}
|
166
190
|
};
|
167
191
|
/**
|
@@ -194,7 +218,10 @@ const PLUGIN_SCHEMAS = {
|
|
194
218
|
type: 'object',
|
195
219
|
properties: {
|
196
220
|
prefix: {
|
197
|
-
type: 'string'
|
221
|
+
type: ['string', 'array'],
|
222
|
+
items: {
|
223
|
+
type: 'string'
|
224
|
+
}
|
198
225
|
},
|
199
226
|
fetcher: {
|
200
227
|
type: 'string'
|
@@ -202,7 +229,7 @@ const PLUGIN_SCHEMAS = {
|
|
202
229
|
proxy: {
|
203
230
|
type: 'object'
|
204
231
|
},
|
205
|
-
|
232
|
+
requestCreator: {
|
206
233
|
type: 'string'
|
207
234
|
}
|
208
235
|
}
|
@@ -305,6 +332,7 @@ const PLUGIN_SCHEMAS = {
|
|
305
332
|
schema: {
|
306
333
|
type: ['object']
|
307
334
|
}
|
308
|
-
}]
|
335
|
+
}],
|
336
|
+
'@modern-js/plugin-nocode': []
|
309
337
|
};
|
310
338
|
exports.PLUGIN_SCHEMAS = PLUGIN_SCHEMAS;
|
@@ -9,9 +9,9 @@ var _is = require("./is");
|
|
9
9
|
|
10
10
|
var _constants = require("./constants");
|
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/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
|
|
@@ -29,8 +29,10 @@ const memo = fn => {
|
|
29
29
|
};
|
30
30
|
};
|
31
31
|
|
32
|
-
const createRuntimeExportsUtils = memo((pwd = '', namespace) => {
|
33
|
-
const entryExportFile = _path.default.join(pwd, `.runtime-exports/${namespace ? `${namespace}.js` : 'index.js'}`);
|
32
|
+
const createRuntimeExportsUtils = memo((pwd = '', namespace, ts = false) => {
|
33
|
+
const entryExportFile = _path.default.join(pwd, `.runtime-exports/${namespace ? `${namespace}.js` : 'index.js'}`);
|
34
|
+
|
35
|
+
const entryExportTsFile = _path.default.join(pwd, `.runtime-exports/${namespace ? `${namespace}.d.ts` : 'index.d.ts'}`); // const ensure = () => {
|
34
36
|
// if (!fs.existsSync(entryExportFile)) {
|
35
37
|
// fs.outputFileSync(entryExportFile, '');
|
36
38
|
// }
|
@@ -45,8 +47,12 @@ const createRuntimeExportsUtils = memo((pwd = '', namespace) => {
|
|
45
47
|
try {
|
46
48
|
_fsExtra.default.ensureFileSync(entryExportFile);
|
47
49
|
|
50
|
+
_fsExtra.default.ensureFileSync(entryExportTsFile);
|
51
|
+
|
48
52
|
if (!_fsExtra.default.readFileSync(entryExportFile, 'utf8').includes(statement)) {
|
49
53
|
_fsExtra.default.appendFileSync(entryExportFile, `${statement}\n`);
|
54
|
+
|
55
|
+
ts && _fsExtra.default.appendFileSync(entryExportTsFile, `${statement.replace('.js', '.d')}\n`);
|
50
56
|
}
|
51
57
|
} catch (_unused) {// FIXME:
|
52
58
|
}
|
package/dist/js/node/watch.js
CHANGED
@@ -24,7 +24,7 @@ exports.WatchChangeType = WatchChangeType;
|
|
24
24
|
|
25
25
|
const watch = (watchDir, runTask, ignored = []) => {
|
26
26
|
let ready = false;
|
27
|
-
const watcher = chokidar.watch(
|
27
|
+
const watcher = chokidar.watch(watchDir, {
|
28
28
|
ignored
|
29
29
|
});
|
30
30
|
watcher.on('ready', () => ready = true);
|
@@ -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
|
|
@@ -58,15 +58,15 @@ export var getAlias = function getAlias(aliasOption, option) {
|
|
58
58
|
}
|
59
59
|
|
60
60
|
return aliasConfig;
|
61
|
-
};
|
61
|
+
}; // filter invalid ts paths that are not array
|
62
|
+
|
62
63
|
export var getUserAlias = function getUserAlias() {
|
63
64
|
var alias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
o[k] = alias[k];
|
65
|
+
return Object.keys(alias).reduce(function (o, k) {
|
66
|
+
if (Array.isArray(alias[k])) {
|
67
|
+
o[k] = alias[k];
|
68
|
+
}
|
69
|
+
|
70
70
|
return o;
|
71
71
|
}, {});
|
72
72
|
};
|
@@ -1,10 +1,24 @@
|
|
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 var compatRequire = function compatRequire(filePath) {
|
7
9
|
var mod = require(filePath);
|
8
10
|
|
9
11
|
return mod !== null && mod !== void 0 && mod.__esModule ? mod["default"] : mod;
|
12
|
+
};
|
13
|
+
export var requireExistModule = function requireExistModule(filename) {
|
14
|
+
var extensions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['.ts', '.js'];
|
15
|
+
var exist = findExists(extensions.map(function (ext) {
|
16
|
+
return "".concat(filename).concat(ext);
|
17
|
+
}));
|
18
|
+
|
19
|
+
if (!exist) {
|
20
|
+
return null;
|
21
|
+
}
|
22
|
+
|
23
|
+
return compatRequire(exist);
|
10
24
|
};
|
@@ -49,7 +49,18 @@ export var SERVER_RENDER_FUNCTION_NAME = 'serverRender';
|
|
49
49
|
*/
|
50
50
|
|
51
51
|
export var LOADABLE_STATS_FILE = 'loadable-stats.json';
|
52
|
+
/**
|
53
|
+
* real entry generate by modern.js
|
54
|
+
*/
|
55
|
+
|
52
56
|
export var HIDE_MODERN_JS_DIR = './node_modules/.modern-js';
|
57
|
+
/**
|
58
|
+
* internal specified folder
|
59
|
+
*/
|
60
|
+
|
61
|
+
export var API_DIR = 'api';
|
62
|
+
export var SERVER_DIR = 'server';
|
63
|
+
export var SHARED_DIR = 'shared';
|
53
64
|
/**
|
54
65
|
* Internal plugins that work as soon as they are installed.
|
55
66
|
*/
|
@@ -120,6 +131,10 @@ export var INTERNAL_PLUGINS = {
|
|
120
131
|
'@modern-js/plugin-server-build': {
|
121
132
|
cli: '@modern-js/plugin-server-build'
|
122
133
|
},
|
134
|
+
'@modern-js/plugin-server': {
|
135
|
+
cli: '@modern-js/plugin-server/cli',
|
136
|
+
server: '@modern-js/plugin-server/server'
|
137
|
+
},
|
123
138
|
'@modern-js/plugin-micro-frontend': {
|
124
139
|
cli: '@modern-js/plugin-micro-frontend/cli'
|
125
140
|
},
|
@@ -146,6 +161,12 @@ export var INTERNAL_PLUGINS = {
|
|
146
161
|
},
|
147
162
|
'@modern-js/plugin-polyfill': {
|
148
163
|
server: '@modern-js/plugin-polyfill'
|
164
|
+
},
|
165
|
+
'@modern-js/plugin-multiprocess': {
|
166
|
+
cli: '@modern-js/plugin-multiprocess/cli'
|
167
|
+
},
|
168
|
+
'@modern-js/plugin-nocode': {
|
169
|
+
cli: '@modern-js/plugin-nocode/cli'
|
149
170
|
}
|
150
171
|
};
|
151
172
|
/**
|
@@ -175,7 +196,10 @@ export var PLUGIN_SCHEMAS = {
|
|
175
196
|
type: 'object',
|
176
197
|
properties: {
|
177
198
|
prefix: {
|
178
|
-
type: 'string'
|
199
|
+
type: ['string', 'array'],
|
200
|
+
items: {
|
201
|
+
type: 'string'
|
202
|
+
}
|
179
203
|
},
|
180
204
|
fetcher: {
|
181
205
|
type: 'string'
|
@@ -183,7 +207,7 @@ export var PLUGIN_SCHEMAS = {
|
|
183
207
|
proxy: {
|
184
208
|
type: 'object'
|
185
209
|
},
|
186
|
-
|
210
|
+
requestCreator: {
|
187
211
|
type: 'string'
|
188
212
|
}
|
189
213
|
}
|
@@ -286,5 +310,6 @@ export var PLUGIN_SCHEMAS = {
|
|
286
310
|
schema: {
|
287
311
|
type: ['object']
|
288
312
|
}
|
289
|
-
}]
|
313
|
+
}],
|
314
|
+
'@modern-js/plugin-nocode': []
|
290
315
|
};
|
@@ -10,7 +10,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
10
10
|
|
11
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
12
12
|
|
13
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
13
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
14
14
|
|
15
15
|
/* eslint-disable no-param-reassign */
|
16
16
|
|
@@ -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,4 +1,4 @@
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
2
2
|
|
3
3
|
export function isString(str) {
|
4
4
|
return typeof str === 'string';
|
@@ -10,9 +10,9 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
|
|
10
10
|
|
11
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
12
12
|
|
13
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
13
|
+
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; }
|
14
14
|
|
15
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
15
|
+
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; }
|
16
16
|
|
17
17
|
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; }
|
18
18
|
|
@@ -20,7 +20,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
20
20
|
|
21
21
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
22
22
|
|
23
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
23
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
24
24
|
|
25
25
|
import chalk from 'chalk';
|
26
26
|
var grey = chalk.grey,
|
@@ -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
|
|
@@ -25,7 +25,9 @@ var memo = function memo(fn) {
|
|
25
25
|
export var createRuntimeExportsUtils = memo(function () {
|
26
26
|
var pwd = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
27
27
|
var namespace = arguments.length > 1 ? arguments[1] : undefined;
|
28
|
-
var
|
28
|
+
var ts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
29
|
+
var entryExportFile = path.join(pwd, ".runtime-exports/".concat(namespace ? "".concat(namespace, ".js") : 'index.js'));
|
30
|
+
var entryExportTsFile = path.join(pwd, ".runtime-exports/".concat(namespace ? "".concat(namespace, ".d.ts") : 'index.d.ts')); // const ensure = () => {
|
29
31
|
// if (!fs.existsSync(entryExportFile)) {
|
30
32
|
// fs.outputFileSync(entryExportFile, '');
|
31
33
|
// }
|
@@ -38,9 +40,11 @@ export var createRuntimeExportsUtils = memo(function () {
|
|
38
40
|
|
39
41
|
try {
|
40
42
|
fs.ensureFileSync(entryExportFile);
|
43
|
+
fs.ensureFileSync(entryExportTsFile);
|
41
44
|
|
42
45
|
if (!fs.readFileSync(entryExportFile, 'utf8').includes(statement)) {
|
43
46
|
fs.appendFileSync(entryExportFile, "".concat(statement, "\n"));
|
47
|
+
ts && fs.appendFileSync(entryExportTsFile, "".concat(statement.replace('.js', '.d'), "\n"));
|
44
48
|
}
|
45
49
|
} catch (_unused) {// FIXME:
|
46
50
|
}
|
@@ -15,7 +15,7 @@ export var WatchChangeType = {
|
|
15
15
|
export var watch = function watch(watchDir, runTask) {
|
16
16
|
var ignored = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
17
17
|
var ready = false;
|
18
|
-
var watcher = chokidar.watch(
|
18
|
+
var watcher = chokidar.watch(watchDir, {
|
19
19
|
ignored: ignored
|
20
20
|
});
|
21
21
|
watcher.on('ready', function () {
|
@@ -3,4 +3,5 @@
|
|
3
3
|
* @param filePath - File to required.
|
4
4
|
* @returns module export object.
|
5
5
|
*/
|
6
|
-
export declare const compatRequire: (filePath: string) => any;
|
6
|
+
export declare const compatRequire: (filePath: string) => any;
|
7
|
+
export declare const requireExistModule: (filename: string, extensions?: string[]) => any;
|
@@ -47,7 +47,18 @@ export declare const SERVER_RENDER_FUNCTION_NAME = "serverRender";
|
|
47
47
|
*/
|
48
48
|
|
49
49
|
export declare const LOADABLE_STATS_FILE = "loadable-stats.json";
|
50
|
+
/**
|
51
|
+
* real entry generate by modern.js
|
52
|
+
*/
|
53
|
+
|
50
54
|
export declare const HIDE_MODERN_JS_DIR = "./node_modules/.modern-js";
|
55
|
+
/**
|
56
|
+
* internal specified folder
|
57
|
+
*/
|
58
|
+
|
59
|
+
export declare const API_DIR = "api";
|
60
|
+
export declare const SERVER_DIR = "server";
|
61
|
+
export declare const SHARED_DIR = "shared";
|
51
62
|
/**
|
52
63
|
* Internal plugins that work as soon as they are installed.
|
53
64
|
*/
|
@@ -88,7 +99,10 @@ export declare const PLUGIN_SCHEMAS: {
|
|
88
99
|
type: string;
|
89
100
|
properties: {
|
90
101
|
prefix: {
|
91
|
-
type: string;
|
102
|
+
type: string[];
|
103
|
+
items: {
|
104
|
+
type: string;
|
105
|
+
};
|
92
106
|
};
|
93
107
|
fetcher: {
|
94
108
|
type: string;
|
@@ -96,7 +110,7 @@ export declare const PLUGIN_SCHEMAS: {
|
|
96
110
|
proxy: {
|
97
111
|
type: string;
|
98
112
|
};
|
99
|
-
|
113
|
+
requestCreator: {
|
100
114
|
type: string;
|
101
115
|
};
|
102
116
|
};
|
@@ -180,4 +194,5 @@ export declare const PLUGIN_SCHEMAS: {
|
|
180
194
|
type: string[];
|
181
195
|
};
|
182
196
|
}[];
|
197
|
+
'@modern-js/plugin-nocode': never[];
|
183
198
|
};
|
package/dist/types/watch.d.ts
CHANGED
@@ -4,5 +4,5 @@ declare type RunTaskType = (option: {
|
|
4
4
|
changedFilePath: string;
|
5
5
|
changeType: WatchChangeTypeValueT;
|
6
6
|
}) => void | Promise<void>;
|
7
|
-
export declare const watch: (watchDir: string, runTask: RunTaskType, ignored?: string[]) => import("chokidar").FSWatcher;
|
7
|
+
export declare const watch: (watchDir: string | string[], runTask: RunTaskType, ignored?: string[]) => import("chokidar").FSWatcher;
|
8
8
|
export {};
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "1.1.
|
14
|
+
"version": "1.1.5",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/js/node/index.js",
|
@@ -65,8 +65,8 @@
|
|
65
65
|
"@types/recursive-readdir": "^2.2.0",
|
66
66
|
"typescript": "^4",
|
67
67
|
"webpack": "^5.54.0",
|
68
|
-
"@modern-js/plugin-testing": "^1.1.
|
69
|
-
"@modern-js/module-tools": "^1.1.
|
68
|
+
"@modern-js/plugin-testing": "^1.1.1",
|
69
|
+
"@modern-js/module-tools": "^1.1.2"
|
70
70
|
},
|
71
71
|
"peerDependencies": {
|
72
72
|
"typescript": "^4.4.3"
|
@@ -80,5 +80,6 @@
|
|
80
80
|
"new": "modern new",
|
81
81
|
"build": "modern build",
|
82
82
|
"test": "modern test --passWithNoTests"
|
83
|
-
}
|
83
|
+
},
|
84
|
+
"readme": "\n<p align=\"center\">\n <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>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
|
84
85
|
}
|
package/src/alias.ts
CHANGED
@@ -80,11 +80,11 @@ export const getAlias = (
|
|
80
80
|
return aliasConfig;
|
81
81
|
};
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
83
|
+
// filter invalid ts paths that are not array
|
84
|
+
export const getUserAlias = (alias: Record<string, string | string[]> = {}) =>
|
85
|
+
Object.keys(alias).reduce((o, k) => {
|
86
|
+
if (Array.isArray(alias[k])) {
|
87
|
+
o[k] = alias[k];
|
88
|
+
}
|
88
89
|
return o;
|
89
|
-
}, {});
|
90
|
-
};
|
90
|
+
}, {} as Record<string, string | string[]>);
|
package/src/compatRequire.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import { findExists } from './findExists';
|
2
|
+
|
1
3
|
/**
|
2
4
|
* Require function compatible with esm and cjs module.
|
3
5
|
* @param filePath - File to required.
|
@@ -8,3 +10,16 @@ export const compatRequire = (filePath: string) => {
|
|
8
10
|
|
9
11
|
return mod?.__esModule ? mod.default : mod;
|
10
12
|
};
|
13
|
+
|
14
|
+
export const requireExistModule = (
|
15
|
+
filename: string,
|
16
|
+
extensions = ['.ts', '.js'],
|
17
|
+
) => {
|
18
|
+
const exist = findExists(extensions.map(ext => `${filename}${ext}`));
|
19
|
+
|
20
|
+
if (!exist) {
|
21
|
+
return null;
|
22
|
+
}
|
23
|
+
|
24
|
+
return compatRequire(exist);
|
25
|
+
};
|
package/src/constants.ts
CHANGED
@@ -48,8 +48,20 @@ export const SERVER_RENDER_FUNCTION_NAME = 'serverRender';
|
|
48
48
|
*/
|
49
49
|
export const LOADABLE_STATS_FILE = 'loadable-stats.json';
|
50
50
|
|
51
|
+
/**
|
52
|
+
* real entry generate by modern.js
|
53
|
+
*/
|
51
54
|
export const HIDE_MODERN_JS_DIR = './node_modules/.modern-js';
|
52
55
|
|
56
|
+
/**
|
57
|
+
* internal specified folder
|
58
|
+
*/
|
59
|
+
export const API_DIR = 'api';
|
60
|
+
|
61
|
+
export const SERVER_DIR = 'server';
|
62
|
+
|
63
|
+
export const SHARED_DIR = 'shared';
|
64
|
+
|
53
65
|
/**
|
54
66
|
* Internal plugins that work as soon as they are installed.
|
55
67
|
*/
|
@@ -91,6 +103,10 @@ export const INTERNAL_PLUGINS: {
|
|
91
103
|
},
|
92
104
|
'@modern-js/plugin-unbundle': { cli: '@modern-js/plugin-unbundle' },
|
93
105
|
'@modern-js/plugin-server-build': { cli: '@modern-js/plugin-server-build' },
|
106
|
+
'@modern-js/plugin-server': {
|
107
|
+
cli: '@modern-js/plugin-server/cli',
|
108
|
+
server: '@modern-js/plugin-server/server',
|
109
|
+
},
|
94
110
|
'@modern-js/plugin-micro-frontend': {
|
95
111
|
cli: '@modern-js/plugin-micro-frontend/cli',
|
96
112
|
},
|
@@ -104,6 +120,10 @@ export const INTERNAL_PLUGINS: {
|
|
104
120
|
cli: '@modern-js/plugin-static-hosting/cli',
|
105
121
|
},
|
106
122
|
'@modern-js/plugin-polyfill': { server: '@modern-js/plugin-polyfill' },
|
123
|
+
'@modern-js/plugin-multiprocess': {
|
124
|
+
cli: '@modern-js/plugin-multiprocess/cli',
|
125
|
+
},
|
126
|
+
'@modern-js/plugin-nocode': { cli: '@modern-js/plugin-nocode/cli' },
|
107
127
|
};
|
108
128
|
|
109
129
|
/**
|
@@ -133,10 +153,13 @@ export const PLUGIN_SCHEMAS = {
|
|
133
153
|
schema: {
|
134
154
|
type: 'object',
|
135
155
|
properties: {
|
136
|
-
prefix: {
|
156
|
+
prefix: {
|
157
|
+
type: ['string', 'array'],
|
158
|
+
items: { type: 'string' },
|
159
|
+
},
|
137
160
|
fetcher: { type: 'string' },
|
138
161
|
proxy: { type: 'object' },
|
139
|
-
|
162
|
+
requestCreator: { type: 'string' },
|
140
163
|
},
|
141
164
|
},
|
142
165
|
},
|
@@ -235,4 +258,5 @@ export const PLUGIN_SCHEMAS = {
|
|
235
258
|
schema: { type: ['object'] },
|
236
259
|
},
|
237
260
|
],
|
261
|
+
'@modern-js/plugin-nocode': [],
|
238
262
|
};
|
package/src/runtimeExports.ts
CHANGED
@@ -20,36 +20,49 @@ const memo = <T extends (...args: any[]) => any>(fn: T) => {
|
|
20
20
|
};
|
21
21
|
};
|
22
22
|
|
23
|
-
export const createRuntimeExportsUtils = memo(
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
//
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
23
|
+
export const createRuntimeExportsUtils = memo(
|
24
|
+
(pwd = '', namespace: string, ts = false) => {
|
25
|
+
const entryExportFile = path.join(
|
26
|
+
pwd,
|
27
|
+
`.runtime-exports/${namespace ? `${namespace}.js` : 'index.js'}`,
|
28
|
+
);
|
29
|
+
const entryExportTsFile = path.join(
|
30
|
+
pwd,
|
31
|
+
`.runtime-exports/${namespace ? `${namespace}.d.ts` : 'index.d.ts'}`,
|
32
|
+
);
|
33
|
+
|
34
|
+
// const ensure = () => {
|
35
|
+
// if (!fs.existsSync(entryExportFile)) {
|
36
|
+
// fs.outputFileSync(entryExportFile, '');
|
37
|
+
// }
|
38
|
+
// fs.ensureFileSync(entryExportFile);
|
39
|
+
// };
|
40
|
+
|
41
|
+
const addExport = (statement: string) => {
|
42
|
+
// eslint-disable-next-line no-param-reassign
|
43
|
+
statement = normalizeOutputPath(statement);
|
44
|
+
try {
|
45
|
+
fs.ensureFileSync(entryExportFile);
|
46
|
+
fs.ensureFileSync(entryExportTsFile);
|
47
|
+
|
48
|
+
if (!fs.readFileSync(entryExportFile, 'utf8').includes(statement)) {
|
49
|
+
fs.appendFileSync(entryExportFile, `${statement}\n`);
|
50
|
+
ts &&
|
51
|
+
fs.appendFileSync(
|
52
|
+
entryExportTsFile,
|
53
|
+
`${statement.replace('.js', '.d')}\n`,
|
54
|
+
);
|
55
|
+
}
|
56
|
+
} catch {
|
57
|
+
// FIXME:
|
43
58
|
}
|
44
|
-
}
|
45
|
-
// FIXME:
|
46
|
-
}
|
47
|
-
};
|
59
|
+
};
|
48
60
|
|
49
|
-
|
61
|
+
const getPath = () => entryExportFile;
|
50
62
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
}
|
63
|
+
return {
|
64
|
+
addExport,
|
65
|
+
getPath,
|
66
|
+
};
|
67
|
+
},
|
68
|
+
);
|
package/src/watch.ts
CHANGED
@@ -20,12 +20,12 @@ type RunTaskType = (option: {
|
|
20
20
|
}) => void | Promise<void>;
|
21
21
|
|
22
22
|
export const watch = (
|
23
|
-
watchDir: string,
|
23
|
+
watchDir: string | string[],
|
24
24
|
runTask: RunTaskType,
|
25
25
|
ignored: string[] = [],
|
26
26
|
) => {
|
27
27
|
let ready = false;
|
28
|
-
const watcher = chokidar.watch(
|
28
|
+
const watcher = chokidar.watch(watchDir, {
|
29
29
|
ignored,
|
30
30
|
});
|
31
31
|
|