@modern-js/utils 1.2.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +36 -0
- package/dist/js/modern/clearConsole.js +1 -1
- package/dist/js/modern/compatRequire.js +5 -0
- package/dist/js/modern/constants.js +4 -18
- package/dist/js/modern/index.js +2 -1
- package/dist/js/modern/prettyInstructions.js +15 -5
- package/dist/js/modern/wait.js +5 -0
- package/dist/js/node/clearConsole.js +1 -1
- package/dist/js/node/compatRequire.js +10 -2
- package/dist/js/node/constants.js +6 -23
- package/dist/js/node/index.js +14 -0
- package/dist/js/node/prettyInstructions.js +15 -5
- package/dist/js/node/wait.js +12 -0
- package/dist/js/treeshaking/clearConsole.js +1 -1
- package/dist/js/treeshaking/compatRequire.js +5 -0
- package/dist/js/treeshaking/constants.js +4 -18
- package/dist/js/treeshaking/index.js +2 -1
- package/dist/js/treeshaking/prettyInstructions.js +17 -6
- package/dist/js/treeshaking/wait.js +8 -0
- package/dist/types/compatRequire.d.ts +2 -1
- package/dist/types/constants.d.ts +1 -16
- package/dist/types/index.d.ts +2 -1
- package/dist/types/wait.d.ts +2 -0
- package/package.json +2 -3
- package/tests/__snapshots__/prettyInstructions.test.ts.snap +19 -0
- package/tests/compatRequire.test.ts +11 -1
- package/tests/fixtures/compat-require/foo.js +3 -0
- package/tests/prettyInstructions.test.ts +139 -0
- package/tests/wait.ts +38 -0
- package/src/FileSizeReporter.ts +0 -181
- package/src/alias.ts +0 -90
- package/src/applyOptionsChain.ts +0 -44
- package/src/chalk.ts +0 -3
- package/src/clearConsole.ts +0 -5
- package/src/compatRequire.ts +0 -25
- package/src/constants.ts +0 -262
- package/src/debug.ts +0 -8
- package/src/ensureAbsolutePath.ts +0 -10
- package/src/findExists.ts +0 -15
- package/src/formatWebpackMessages.ts +0 -131
- package/src/generateMetaTags.ts +0 -75
- package/src/getBrowserslist.ts +0 -6
- package/src/getCacheIdentifier.ts +0 -30
- package/src/getEntryOptions.ts +0 -37
- package/src/getPackageManager.ts +0 -30
- package/src/getPort.ts +0 -62
- package/src/import.ts +0 -10
- package/src/index.ts +0 -31
- package/src/is/index.ts +0 -78
- package/src/is/node-env.ts +0 -9
- package/src/is/platform.ts +0 -7
- package/src/is/type.ts +0 -43
- package/src/logger.ts +0 -184
- package/src/monorepo.ts +0 -106
- package/src/nodeEnv.ts +0 -28
- package/src/path.ts +0 -9
- package/src/pkgUp.ts +0 -3
- package/src/prettyInstructions.ts +0 -88
- package/src/printBuildError.ts +0 -47
- package/src/readTsConfig.ts +0 -21
- package/src/removeSlash.ts +0 -6
- package/src/runtimeExports.ts +0 -68
- package/src/types.d.ts +0 -1
- package/src/watch.ts +0 -56
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,41 @@
|
|
1
1
|
# @modern-js/utils
|
2
2
|
|
3
|
+
## 1.3.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 78279953: compiler entry bug fix and dev build console
|
8
|
+
- 4d72edea: support dev compiler by entry
|
9
|
+
|
10
|
+
## 1.3.0
|
11
|
+
|
12
|
+
### Minor Changes
|
13
|
+
|
14
|
+
- ec4dbffb: feat: support as a pure api service
|
15
|
+
- bada2879: refactor plugin-garfish:
|
16
|
+
- change @modern-js/plugin-micro-frontend => @modern-js/plugin-garfish
|
17
|
+
- remove disableCustomerRouter logic
|
18
|
+
- adding unit test
|
19
|
+
- fix plugin-garfish type error
|
20
|
+
|
21
|
+
### Patch Changes
|
22
|
+
|
23
|
+
- d099e5c5: fix error when modify modern.config.js
|
24
|
+
- 24f616ca: feat: support custom meta info
|
25
|
+
- bd819a8d: feat: add wait function
|
26
|
+
|
27
|
+
## 1.2.2
|
28
|
+
|
29
|
+
### Patch Changes
|
30
|
+
|
31
|
+
- 83166714: change .npmignore
|
32
|
+
|
33
|
+
## 1.2.1
|
34
|
+
|
35
|
+
### Patch Changes
|
36
|
+
|
37
|
+
- 823809c6: fix: remove plugin-polyfill from app-tools
|
38
|
+
|
3
39
|
## 1.2.0
|
4
40
|
|
5
41
|
### Minor Changes
|
@@ -1,16 +1,6 @@
|
|
1
|
-
/**
|
2
|
-
* alias to src directory
|
3
|
-
*/
|
4
|
-
export const INTERNAL_SRC_ALIAS = '@_modern_js_src';
|
5
|
-
/**
|
6
|
-
* alias to node_modules/.modern-js
|
7
|
-
*/
|
8
|
-
|
9
|
-
export const INTERNAL_DIR_ALAIS = '@_modern_js_internal';
|
10
1
|
/**
|
11
2
|
* hmr socket connect path
|
12
3
|
*/
|
13
|
-
|
14
4
|
export const HMR_SOCK_PATH = '/_modern_js_hmr_ws';
|
15
5
|
/**
|
16
6
|
* route specification file
|
@@ -47,11 +37,6 @@ export const SERVER_RENDER_FUNCTION_NAME = 'serverRender';
|
|
47
37
|
*/
|
48
38
|
|
49
39
|
export const LOADABLE_STATS_FILE = 'loadable-stats.json';
|
50
|
-
/**
|
51
|
-
* real entry generate by modern.js
|
52
|
-
*/
|
53
|
-
|
54
|
-
export const HIDE_MODERN_JS_DIR = './node_modules/.modern-js';
|
55
40
|
/**
|
56
41
|
* internal specified folder
|
57
42
|
*/
|
@@ -133,8 +118,8 @@ export const INTERNAL_PLUGINS = {
|
|
133
118
|
cli: '@modern-js/plugin-server/cli',
|
134
119
|
server: '@modern-js/plugin-server/server'
|
135
120
|
},
|
136
|
-
'@modern-js/plugin-
|
137
|
-
cli: '@modern-js/plugin-
|
121
|
+
'@modern-js/plugin-garfish': {
|
122
|
+
cli: '@modern-js/plugin-garfish/cli'
|
138
123
|
},
|
139
124
|
'@modern-js/plugin-jarvis': {
|
140
125
|
cli: '@modern-js/plugin-jarvis/cli'
|
@@ -158,6 +143,7 @@ export const INTERNAL_PLUGINS = {
|
|
158
143
|
cli: '@modern-js/plugin-static-hosting/cli'
|
159
144
|
},
|
160
145
|
'@modern-js/plugin-polyfill': {
|
146
|
+
cli: '@modern-js/plugin-polyfill/cli',
|
161
147
|
server: '@modern-js/plugin-polyfill'
|
162
148
|
},
|
163
149
|
'@modern-js/plugin-multiprocess': {
|
@@ -300,7 +286,7 @@ export const PLUGIN_SCHEMAS = {
|
|
300
286
|
typeof: ['object', 'function']
|
301
287
|
}
|
302
288
|
}],
|
303
|
-
'@modern-js/plugin-
|
289
|
+
'@modern-js/plugin-garfish': [{
|
304
290
|
target: 'runtime.masterApp',
|
305
291
|
schema: {
|
306
292
|
type: ['object']
|
package/dist/js/modern/index.js
CHANGED
@@ -38,13 +38,15 @@ export const prettyInstructions = (appContext, config) => {
|
|
38
38
|
const {
|
39
39
|
entrypoints,
|
40
40
|
serverRoutes,
|
41
|
-
port
|
41
|
+
port,
|
42
|
+
existSrc,
|
43
|
+
checkedEntries
|
42
44
|
} = appContext;
|
43
45
|
const urls = getAddressUrls(config.dev.https && isDev() ? 'https' : 'http', port);
|
44
|
-
const routes = serverRoutes.filter(route => route.entryName);
|
46
|
+
const routes = existSrc ? serverRoutes.filter(route => route.entryName) : serverRoutes;
|
45
47
|
let message = 'App running at:\n\n';
|
46
48
|
|
47
|
-
if (isSingleEntry(entrypoints)) {
|
49
|
+
if (isSingleEntry(entrypoints) || !existSrc) {
|
48
50
|
message += urls.map(({
|
49
51
|
type,
|
50
52
|
url
|
@@ -58,11 +60,19 @@ export const prettyInstructions = (appContext, config) => {
|
|
58
60
|
message += ` ${chalk.bold(`> ${type}`)}\n`;
|
59
61
|
routes.forEach(({
|
60
62
|
entryName,
|
61
|
-
urlPath
|
63
|
+
urlPath,
|
64
|
+
isSSR
|
62
65
|
}) => {
|
63
|
-
|
66
|
+
if (!checkedEntries.includes(entryName)) {
|
67
|
+
return;
|
68
|
+
}
|
69
|
+
|
70
|
+
message += ` ${chalk.yellowBright(isSSR ? 'λ' : '○')} ${chalk.yellowBright(entryName.padEnd(maxNameLength + 8))}${chalk.cyanBright(normalizeUrl(`${url}/${urlPath}`))}\n`;
|
64
71
|
});
|
65
72
|
});
|
73
|
+
message += '\n';
|
74
|
+
message += chalk.cyanBright(' λ (Server) server-side renders at runtime\n');
|
75
|
+
message += chalk.cyanBright(' ○ (Static) client-side rendered as static HTML\n');
|
66
76
|
}
|
67
77
|
|
68
78
|
return message;
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.requireExistModule = exports.compatRequire = void 0;
|
6
|
+
exports.requireExistModule = exports.compatRequire = exports.cleanRequireCache = void 0;
|
7
7
|
|
8
8
|
var _findExists = require("./findExists");
|
9
9
|
|
@@ -30,4 +30,12 @@ const requireExistModule = (filename, extensions = ['.ts', '.js']) => {
|
|
30
30
|
return compatRequire(exist);
|
31
31
|
};
|
32
32
|
|
33
|
-
exports.requireExistModule = requireExistModule;
|
33
|
+
exports.requireExistModule = requireExistModule;
|
34
|
+
|
35
|
+
const cleanRequireCache = filelist => {
|
36
|
+
filelist.forEach(filepath => {
|
37
|
+
delete require.cache[filepath];
|
38
|
+
});
|
39
|
+
};
|
40
|
+
|
41
|
+
exports.cleanRequireCache = cleanRequireCache;
|
@@ -3,23 +3,11 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
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.
|
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_PLUGINS = exports.HMR_SOCK_PATH = exports.ENTRY_NAME_PATTERN = exports.API_DIR = void 0;
|
7
7
|
|
8
|
-
/**
|
9
|
-
* alias to src directory
|
10
|
-
*/
|
11
|
-
const INTERNAL_SRC_ALIAS = '@_modern_js_src';
|
12
|
-
/**
|
13
|
-
* alias to node_modules/.modern-js
|
14
|
-
*/
|
15
|
-
|
16
|
-
exports.INTERNAL_SRC_ALIAS = INTERNAL_SRC_ALIAS;
|
17
|
-
const INTERNAL_DIR_ALAIS = '@_modern_js_internal';
|
18
8
|
/**
|
19
9
|
* hmr socket connect path
|
20
10
|
*/
|
21
|
-
|
22
|
-
exports.INTERNAL_DIR_ALAIS = INTERNAL_DIR_ALAIS;
|
23
11
|
const HMR_SOCK_PATH = '/_modern_js_hmr_ws';
|
24
12
|
/**
|
25
13
|
* route specification file
|
@@ -63,17 +51,11 @@ const SERVER_RENDER_FUNCTION_NAME = 'serverRender';
|
|
63
51
|
|
64
52
|
exports.SERVER_RENDER_FUNCTION_NAME = SERVER_RENDER_FUNCTION_NAME;
|
65
53
|
const LOADABLE_STATS_FILE = 'loadable-stats.json';
|
66
|
-
/**
|
67
|
-
* real entry generate by modern.js
|
68
|
-
*/
|
69
|
-
|
70
|
-
exports.LOADABLE_STATS_FILE = LOADABLE_STATS_FILE;
|
71
|
-
const HIDE_MODERN_JS_DIR = './node_modules/.modern-js';
|
72
54
|
/**
|
73
55
|
* internal specified folder
|
74
56
|
*/
|
75
57
|
|
76
|
-
exports.
|
58
|
+
exports.LOADABLE_STATS_FILE = LOADABLE_STATS_FILE;
|
77
59
|
const API_DIR = 'api';
|
78
60
|
exports.API_DIR = API_DIR;
|
79
61
|
const SERVER_DIR = 'server';
|
@@ -154,8 +136,8 @@ const INTERNAL_PLUGINS = {
|
|
154
136
|
cli: '@modern-js/plugin-server/cli',
|
155
137
|
server: '@modern-js/plugin-server/server'
|
156
138
|
},
|
157
|
-
'@modern-js/plugin-
|
158
|
-
cli: '@modern-js/plugin-
|
139
|
+
'@modern-js/plugin-garfish': {
|
140
|
+
cli: '@modern-js/plugin-garfish/cli'
|
159
141
|
},
|
160
142
|
'@modern-js/plugin-jarvis': {
|
161
143
|
cli: '@modern-js/plugin-jarvis/cli'
|
@@ -179,6 +161,7 @@ const INTERNAL_PLUGINS = {
|
|
179
161
|
cli: '@modern-js/plugin-static-hosting/cli'
|
180
162
|
},
|
181
163
|
'@modern-js/plugin-polyfill': {
|
164
|
+
cli: '@modern-js/plugin-polyfill/cli',
|
182
165
|
server: '@modern-js/plugin-polyfill'
|
183
166
|
},
|
184
167
|
'@modern-js/plugin-multiprocess': {
|
@@ -322,7 +305,7 @@ const PLUGIN_SCHEMAS = {
|
|
322
305
|
typeof: ['object', 'function']
|
323
306
|
}
|
324
307
|
}],
|
325
|
-
'@modern-js/plugin-
|
308
|
+
'@modern-js/plugin-garfish': [{
|
326
309
|
target: 'runtime.masterApp',
|
327
310
|
schema: {
|
328
311
|
type: ['object']
|
package/dist/js/node/index.js
CHANGED
@@ -432,6 +432,20 @@ Object.keys(_nodeEnv).forEach(function (key) {
|
|
432
432
|
});
|
433
433
|
});
|
434
434
|
|
435
|
+
var _wait = require("./wait");
|
436
|
+
|
437
|
+
Object.keys(_wait).forEach(function (key) {
|
438
|
+
if (key === "default" || key === "__esModule") return;
|
439
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
440
|
+
if (key in exports && exports[key] === _wait[key]) return;
|
441
|
+
Object.defineProperty(exports, key, {
|
442
|
+
enumerable: true,
|
443
|
+
get: function () {
|
444
|
+
return _wait[key];
|
445
|
+
}
|
446
|
+
});
|
447
|
+
});
|
448
|
+
|
435
449
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
436
450
|
|
437
451
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
@@ -52,13 +52,15 @@ const prettyInstructions = (appContext, config) => {
|
|
52
52
|
const {
|
53
53
|
entrypoints,
|
54
54
|
serverRoutes,
|
55
|
-
port
|
55
|
+
port,
|
56
|
+
existSrc,
|
57
|
+
checkedEntries
|
56
58
|
} = appContext;
|
57
59
|
const urls = getAddressUrls(config.dev.https && (0, _is.isDev)() ? 'https' : 'http', port);
|
58
|
-
const routes = serverRoutes.filter(route => route.entryName);
|
60
|
+
const routes = existSrc ? serverRoutes.filter(route => route.entryName) : serverRoutes;
|
59
61
|
let message = 'App running at:\n\n';
|
60
62
|
|
61
|
-
if (isSingleEntry(entrypoints)) {
|
63
|
+
if (isSingleEntry(entrypoints) || !existSrc) {
|
62
64
|
message += urls.map(({
|
63
65
|
type,
|
64
66
|
url
|
@@ -72,11 +74,19 @@ const prettyInstructions = (appContext, config) => {
|
|
72
74
|
message += ` ${_chalk.default.bold(`> ${type}`)}\n`;
|
73
75
|
routes.forEach(({
|
74
76
|
entryName,
|
75
|
-
urlPath
|
77
|
+
urlPath,
|
78
|
+
isSSR
|
76
79
|
}) => {
|
77
|
-
|
80
|
+
if (!checkedEntries.includes(entryName)) {
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
|
84
|
+
message += ` ${_chalk.default.yellowBright(isSSR ? 'λ' : '○')} ${_chalk.default.yellowBright(entryName.padEnd(maxNameLength + 8))}${_chalk.default.cyanBright(normalizeUrl(`${url}/${urlPath}`))}\n`;
|
78
85
|
});
|
79
86
|
});
|
87
|
+
message += '\n';
|
88
|
+
message += _chalk.default.cyanBright(' λ (Server) server-side renders at runtime\n');
|
89
|
+
message += _chalk.default.cyanBright(' ○ (Static) client-side rendered as static HTML\n');
|
80
90
|
}
|
81
91
|
|
82
92
|
return message;
|
@@ -21,4 +21,9 @@ export var requireExistModule = function requireExistModule(filename) {
|
|
21
21
|
}
|
22
22
|
|
23
23
|
return compatRequire(exist);
|
24
|
+
};
|
25
|
+
export var cleanRequireCache = function cleanRequireCache(filelist) {
|
26
|
+
filelist.forEach(function (filepath) {
|
27
|
+
delete require.cache[filepath];
|
28
|
+
});
|
24
29
|
};
|
@@ -1,18 +1,8 @@
|
|
1
1
|
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; }
|
2
2
|
|
3
|
-
/**
|
4
|
-
* alias to src directory
|
5
|
-
*/
|
6
|
-
export var INTERNAL_SRC_ALIAS = '@_modern_js_src';
|
7
|
-
/**
|
8
|
-
* alias to node_modules/.modern-js
|
9
|
-
*/
|
10
|
-
|
11
|
-
export var INTERNAL_DIR_ALAIS = '@_modern_js_internal';
|
12
3
|
/**
|
13
4
|
* hmr socket connect path
|
14
5
|
*/
|
15
|
-
|
16
6
|
export var HMR_SOCK_PATH = '/_modern_js_hmr_ws';
|
17
7
|
/**
|
18
8
|
* route specification file
|
@@ -49,11 +39,6 @@ export var SERVER_RENDER_FUNCTION_NAME = 'serverRender';
|
|
49
39
|
*/
|
50
40
|
|
51
41
|
export var LOADABLE_STATS_FILE = 'loadable-stats.json';
|
52
|
-
/**
|
53
|
-
* real entry generate by modern.js
|
54
|
-
*/
|
55
|
-
|
56
|
-
export var HIDE_MODERN_JS_DIR = './node_modules/.modern-js';
|
57
42
|
/**
|
58
43
|
* internal specified folder
|
59
44
|
*/
|
@@ -135,8 +120,8 @@ export var INTERNAL_PLUGINS = {
|
|
135
120
|
cli: '@modern-js/plugin-server/cli',
|
136
121
|
server: '@modern-js/plugin-server/server'
|
137
122
|
},
|
138
|
-
'@modern-js/plugin-
|
139
|
-
cli: '@modern-js/plugin-
|
123
|
+
'@modern-js/plugin-garfish': {
|
124
|
+
cli: '@modern-js/plugin-garfish/cli'
|
140
125
|
},
|
141
126
|
'@modern-js/plugin-jarvis': {
|
142
127
|
cli: '@modern-js/plugin-jarvis/cli'
|
@@ -160,6 +145,7 @@ export var INTERNAL_PLUGINS = {
|
|
160
145
|
cli: '@modern-js/plugin-static-hosting/cli'
|
161
146
|
},
|
162
147
|
'@modern-js/plugin-polyfill': {
|
148
|
+
cli: '@modern-js/plugin-polyfill/cli',
|
163
149
|
server: '@modern-js/plugin-polyfill'
|
164
150
|
},
|
165
151
|
'@modern-js/plugin-multiprocess': {
|
@@ -300,7 +286,7 @@ export var PLUGIN_SCHEMAS = {
|
|
300
286
|
"typeof": ['object', 'function']
|
301
287
|
}
|
302
288
|
}],
|
303
|
-
'@modern-js/plugin-
|
289
|
+
'@modern-js/plugin-garfish': [{
|
304
290
|
target: 'runtime.masterApp',
|
305
291
|
schema: {
|
306
292
|
type: ['object']
|
@@ -56,14 +56,16 @@ export var prettyInstructions = function prettyInstructions(appContext, config)
|
|
56
56
|
var _ref = appContext,
|
57
57
|
entrypoints = _ref.entrypoints,
|
58
58
|
serverRoutes = _ref.serverRoutes,
|
59
|
-
port = _ref.port
|
59
|
+
port = _ref.port,
|
60
|
+
existSrc = _ref.existSrc,
|
61
|
+
checkedEntries = _ref.checkedEntries;
|
60
62
|
var urls = getAddressUrls(config.dev.https && isDev() ? 'https' : 'http', port);
|
61
|
-
var routes = serverRoutes.filter(function (route) {
|
63
|
+
var routes = existSrc ? serverRoutes.filter(function (route) {
|
62
64
|
return route.entryName;
|
63
|
-
});
|
65
|
+
}) : serverRoutes;
|
64
66
|
var message = 'App running at:\n\n';
|
65
67
|
|
66
|
-
if (isSingleEntry(entrypoints)) {
|
68
|
+
if (isSingleEntry(entrypoints) || !existSrc) {
|
67
69
|
message += urls.map(function (_ref2) {
|
68
70
|
var type = _ref2.type,
|
69
71
|
url = _ref2.url;
|
@@ -79,10 +81,19 @@ export var prettyInstructions = function prettyInstructions(appContext, config)
|
|
79
81
|
message += " ".concat(chalk.bold("> ".concat(type)), "\n");
|
80
82
|
routes.forEach(function (_ref4) {
|
81
83
|
var entryName = _ref4.entryName,
|
82
|
-
urlPath = _ref4.urlPath
|
83
|
-
|
84
|
+
urlPath = _ref4.urlPath,
|
85
|
+
isSSR = _ref4.isSSR;
|
86
|
+
|
87
|
+
if (!checkedEntries.includes(entryName)) {
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
|
91
|
+
message += " ".concat(chalk.yellowBright(isSSR ? 'λ' : '○'), " ").concat(chalk.yellowBright(entryName.padEnd(maxNameLength + 8))).concat(chalk.cyanBright(normalizeUrl("".concat(url, "/").concat(urlPath))), "\n");
|
84
92
|
});
|
85
93
|
});
|
94
|
+
message += '\n';
|
95
|
+
message += chalk.cyanBright(' λ (Server) server-side renders at runtime\n');
|
96
|
+
message += chalk.cyanBright(' ○ (Static) client-side rendered as static HTML\n');
|
86
97
|
}
|
87
98
|
|
88
99
|
return message;
|
@@ -4,4 +4,5 @@
|
|
4
4
|
* @returns module export object.
|
5
5
|
*/
|
6
6
|
export declare const compatRequire: (filePath: string) => any;
|
7
|
-
export declare const requireExistModule: (filename: string, extensions?: string[]) => any;
|
7
|
+
export declare const requireExistModule: (filename: string, extensions?: string[]) => any;
|
8
|
+
export declare const cleanRequireCache: (filelist: string[]) => void;
|
@@ -1,16 +1,6 @@
|
|
1
|
-
/**
|
2
|
-
* alias to src directory
|
3
|
-
*/
|
4
|
-
export declare const INTERNAL_SRC_ALIAS = "@_modern_js_src";
|
5
|
-
/**
|
6
|
-
* alias to node_modules/.modern-js
|
7
|
-
*/
|
8
|
-
|
9
|
-
export declare const INTERNAL_DIR_ALAIS = "@_modern_js_internal";
|
10
1
|
/**
|
11
2
|
* hmr socket connect path
|
12
3
|
*/
|
13
|
-
|
14
4
|
export declare const HMR_SOCK_PATH = "/_modern_js_hmr_ws";
|
15
5
|
/**
|
16
6
|
* route specification file
|
@@ -47,11 +37,6 @@ export declare const SERVER_RENDER_FUNCTION_NAME = "serverRender";
|
|
47
37
|
*/
|
48
38
|
|
49
39
|
export declare const LOADABLE_STATS_FILE = "loadable-stats.json";
|
50
|
-
/**
|
51
|
-
* real entry generate by modern.js
|
52
|
-
*/
|
53
|
-
|
54
|
-
export declare const HIDE_MODERN_JS_DIR = "./node_modules/.modern-js";
|
55
40
|
/**
|
56
41
|
* internal specified folder
|
57
42
|
*/
|
@@ -188,7 +173,7 @@ export declare const PLUGIN_SCHEMAS: {
|
|
188
173
|
typeof: string[];
|
189
174
|
};
|
190
175
|
}[];
|
191
|
-
'@modern-js/plugin-
|
176
|
+
'@modern-js/plugin-garfish': {
|
192
177
|
target: string;
|
193
178
|
schema: {
|
194
179
|
type: string[];
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "1.
|
14
|
+
"version": "1.3.1",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/js/node/index.js",
|
@@ -80,8 +80,7 @@
|
|
80
80
|
"sideEffects": false,
|
81
81
|
"publishConfig": {
|
82
82
|
"registry": "https://registry.npmjs.org/",
|
83
|
-
"access": "public"
|
84
|
-
"types": "./dist/types/index.d.ts"
|
83
|
+
"access": "public"
|
85
84
|
},
|
86
85
|
"scripts": {
|
87
86
|
"new": "modern new",
|
@@ -0,0 +1,19 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`prettyInstructions The src directory does not exist 1`] = `
|
4
|
+
"App running at:
|
5
|
+
|
6
|
+
> Network: http://127.0.0.1:8080/api
|
7
|
+
> Network: http://11.11.111.11:8080/api
|
8
|
+
> Network: http://10.100.100.100:8080/api
|
9
|
+
"
|
10
|
+
`;
|
11
|
+
|
12
|
+
exports[`prettyInstructions basic usage 1`] = `
|
13
|
+
"App running at:
|
14
|
+
|
15
|
+
> Network: http://127.0.0.1:8080/
|
16
|
+
> Network: http://11.11.111.11:8080/
|
17
|
+
> Network: http://10.100.100.100:8080/
|
18
|
+
"
|
19
|
+
`;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import path from 'path';
|
2
|
-
import { compatRequire } from '../src/compatRequire';
|
2
|
+
import { compatRequire, cleanRequireCache } from '../src/compatRequire';
|
3
3
|
|
4
4
|
describe('compat require', () => {
|
5
5
|
const fixturePath = path.resolve(__dirname, './fixtures/compat-require');
|
@@ -19,4 +19,14 @@ describe('compat require', () => {
|
|
19
19
|
test(`should return null`, () => {
|
20
20
|
expect(compatRequire(path.join(fixturePath, 'empty.js'))).toEqual(null);
|
21
21
|
});
|
22
|
+
|
23
|
+
test('should clearn cache after fn', () => {
|
24
|
+
const foo = module.require('./fixtures/compat-require/foo');
|
25
|
+
const requirePath = require.resolve('./fixtures/compat-require/foo.js');
|
26
|
+
expect(foo.name).toBe('foo');
|
27
|
+
expect(require.cache[requirePath]).toBeDefined();
|
28
|
+
cleanRequireCache([requirePath]);
|
29
|
+
jest.resetModules();
|
30
|
+
expect(require.cache[requirePath]).toBeUndefined();
|
31
|
+
});
|
22
32
|
});
|