@modern-js/utils 2.3.0 → 2.4.1-beta.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +20 -0
- package/README.md +14 -18
- package/dist/compatRequire.d.ts +1 -0
- package/dist/compatRequire.js +10 -1
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +5 -1
- package/dist/is/index.d.ts +7 -0
- package/dist/is/index.js +15 -1
- package/dist/is/node-env.d.ts +4 -0
- package/dist/is/node-env.js +9 -4
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# @modern-js/utils
|
2
2
|
|
3
|
+
## 2.4.1-beta.0
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 11c053b: feat: ssr support deploy worker
|
8
|
+
|
9
|
+
feat: ssr 支持边缘部署
|
10
|
+
|
11
|
+
## 2.4.0
|
12
|
+
|
13
|
+
### Patch Changes
|
14
|
+
|
15
|
+
- 98a2733: fix(tailwind): fix webpack cache not work when using twin.macro
|
16
|
+
|
17
|
+
fix(tailwind): 修复使用 twin.macro 时 webpack 缓存不生效的问题
|
18
|
+
|
19
|
+
- 8c2db5f: feat(core): improve support for exporting a function in config file
|
20
|
+
|
21
|
+
feat(core): 完善对配置文件中导出函数的支持
|
22
|
+
|
3
23
|
## 2.3.0
|
4
24
|
|
5
25
|
### Patch Changes
|
package/README.md
CHANGED
@@ -1,30 +1,26 @@
|
|
1
|
-
|
2
1
|
<p align="center">
|
3
2
|
<a href="https://modernjs.dev" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png" width="300" alt="Modern.js Logo" /></a>
|
4
3
|
</p>
|
4
|
+
|
5
|
+
<h1 align="center">Modern.js</h1>
|
6
|
+
|
5
7
|
<p align="center">
|
6
|
-
|
7
|
-
<br/>
|
8
|
-
<a href="https://modernjs.dev" target="blank">
|
9
|
-
modernjs.dev
|
10
|
-
</a>
|
11
|
-
</p>
|
12
|
-
<p align="center">
|
13
|
-
The meta-framework suite designed from scratch for frontend-focused modern web development
|
8
|
+
A Progressive React Framework for modern web development.
|
14
9
|
</p>
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
> 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.
|
11
|
+
## Getting Started
|
19
12
|
|
20
|
-
|
13
|
+
Please follow [Quick Start](https://modernjs.dev/en/guides/get-started/quick-start) to get started with Modern.js.
|
21
14
|
|
22
|
-
##
|
15
|
+
## Documentation
|
23
16
|
|
24
|
-
- [
|
25
|
-
- [
|
26
|
-
- [API References](https://modernjs.dev/docs/apis)
|
17
|
+
- [English Documentation](https://modernjs.dev/en/)
|
18
|
+
- [中文文档](https://modernjs.dev)
|
27
19
|
|
28
20
|
## Contributing
|
29
21
|
|
30
|
-
|
22
|
+
Please read the [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md).
|
23
|
+
|
24
|
+
## License
|
25
|
+
|
26
|
+
Modern.js is [MIT licensed](https://github.com/modern-js-dev/modern.js/blob/main/LICENSE).
|
package/dist/compatRequire.d.ts
CHANGED
package/dist/compatRequire.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.cleanRequireCache = exports.requireExistModule = exports.dynamicImport = exports.compatRequire = void 0;
|
3
|
+
exports.deleteRequireCache = exports.cleanRequireCache = exports.requireExistModule = exports.dynamicImport = exports.compatRequire = void 0;
|
4
4
|
const findExists_1 = require("./findExists");
|
5
5
|
/**
|
6
6
|
* Require function compatible with esm and cjs module.
|
@@ -35,3 +35,12 @@ const cleanRequireCache = (filelist) => {
|
|
35
35
|
});
|
36
36
|
};
|
37
37
|
exports.cleanRequireCache = cleanRequireCache;
|
38
|
+
function deleteRequireCache(path) {
|
39
|
+
if (require.cache[path]) {
|
40
|
+
delete require.cache[path];
|
41
|
+
}
|
42
|
+
if (module.children) {
|
43
|
+
module.children = module.children.filter(item => item.filename !== path);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
exports.deleteRequireCache = deleteRequireCache;
|
package/dist/constants.d.ts
CHANGED
@@ -19,6 +19,10 @@ export declare const LAUNCH_EDITOR_ENDPOINT = "/__open-stack-frame-in-editor";
|
|
19
19
|
* server side bundles directory, which relative to dist.
|
20
20
|
*/
|
21
21
|
export declare const SERVER_BUNDLE_DIRECTORY = "bundles";
|
22
|
+
/**
|
23
|
+
* server side bundles directory, which relative to dist.
|
24
|
+
*/
|
25
|
+
export declare const SERVER_WORKER_BUNDLE_DIRECTORY = "worker";
|
22
26
|
/**
|
23
27
|
* entry name pattern used for ajv pattern properties.
|
24
28
|
*/
|
package/dist/constants.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.PLUGIN_SCHEMAS = exports.INTERNAL_SERVER_PLUGINS = exports.SERVER_PLUGIN_POLYFILL = exports.SERVER_PLUGIN_SERVER = exports.SERVER_PLUGIN_NEST = exports.SERVER_PLUGIN_KOA = exports.SERVER_PLUGIN_EGG = exports.SERVER_PLUGIN_EXPRESS = exports.SERVER_PLUGIN_BFF = exports.INTERNAL_CLI_PLUGINS = exports.INTERNAL_DOC_TOOLS_PLUGINS = exports.INTERNAL_MONOREPO_TOOLS_PLUGINS = exports.INTERNAL_MODULE_TOOLS_PLUGINS = exports.INTERNAL_APP_TOOLS_RUNTIME_PLUGINS = exports.INTERNAL_APP_TOOLS_PLUGINS = exports.LOADER_ROUTES_DIR = exports.ROUTE_MANIFEST = exports.ROUTE_MINIFEST_FILE = exports.DEFAULT_SERVER_CONFIG = exports.OUTPUT_CONFIG_FILE = exports.CONFIG_FILE_EXTENSIONS = exports.CONFIG_CACHE_DIR = exports.SHARED_DIR = exports.SERVER_DIR = exports.API_DIR = exports.LOADABLE_STATS_FILE = exports.SERVER_RENDER_FUNCTION_NAME = exports.ENTRY_NAME_PATTERN = exports.SERVER_BUNDLE_DIRECTORY = exports.LAUNCH_EDITOR_ENDPOINT = exports.MAIN_ENTRY_NAME = exports.ROUTE_SPEC_FILE = exports.HMR_SOCK_PATH = void 0;
|
3
|
+
exports.PLUGIN_SCHEMAS = exports.INTERNAL_SERVER_PLUGINS = exports.SERVER_PLUGIN_POLYFILL = exports.SERVER_PLUGIN_SERVER = exports.SERVER_PLUGIN_NEST = exports.SERVER_PLUGIN_KOA = exports.SERVER_PLUGIN_EGG = exports.SERVER_PLUGIN_EXPRESS = exports.SERVER_PLUGIN_BFF = exports.INTERNAL_CLI_PLUGINS = exports.INTERNAL_DOC_TOOLS_PLUGINS = exports.INTERNAL_MONOREPO_TOOLS_PLUGINS = exports.INTERNAL_MODULE_TOOLS_PLUGINS = exports.INTERNAL_APP_TOOLS_RUNTIME_PLUGINS = exports.INTERNAL_APP_TOOLS_PLUGINS = exports.LOADER_ROUTES_DIR = exports.ROUTE_MANIFEST = exports.ROUTE_MINIFEST_FILE = exports.DEFAULT_SERVER_CONFIG = exports.OUTPUT_CONFIG_FILE = exports.CONFIG_FILE_EXTENSIONS = exports.CONFIG_CACHE_DIR = exports.SHARED_DIR = exports.SERVER_DIR = exports.API_DIR = exports.LOADABLE_STATS_FILE = exports.SERVER_RENDER_FUNCTION_NAME = exports.ENTRY_NAME_PATTERN = exports.SERVER_WORKER_BUNDLE_DIRECTORY = exports.SERVER_BUNDLE_DIRECTORY = exports.LAUNCH_EDITOR_ENDPOINT = exports.MAIN_ENTRY_NAME = exports.ROUTE_SPEC_FILE = exports.HMR_SOCK_PATH = void 0;
|
4
4
|
/**
|
5
5
|
* hmr socket connect path
|
6
6
|
*/
|
@@ -21,6 +21,10 @@ exports.LAUNCH_EDITOR_ENDPOINT = '/__open-stack-frame-in-editor';
|
|
21
21
|
* server side bundles directory, which relative to dist.
|
22
22
|
*/
|
23
23
|
exports.SERVER_BUNDLE_DIRECTORY = 'bundles';
|
24
|
+
/**
|
25
|
+
* server side bundles directory, which relative to dist.
|
26
|
+
*/
|
27
|
+
exports.SERVER_WORKER_BUNDLE_DIRECTORY = 'worker';
|
24
28
|
/**
|
25
29
|
* entry name pattern used for ajv pattern properties.
|
26
30
|
*/
|
package/dist/is/index.d.ts
CHANGED
@@ -28,6 +28,13 @@ export declare const isEmpty: (o: Record<string, unknown>) => boolean;
|
|
28
28
|
*/
|
29
29
|
export declare const isSSR: (config: any) => boolean;
|
30
30
|
export declare const isUseSSRBundle: (config: any) => boolean;
|
31
|
+
/**
|
32
|
+
* Is Worker project
|
33
|
+
*
|
34
|
+
* @param config - User config.
|
35
|
+
* @returns Whether to use worker deploy.
|
36
|
+
*/
|
37
|
+
export declare const isServiceWorker: (config: any) => boolean;
|
31
38
|
export declare const isFastRefresh: () => boolean;
|
32
39
|
export * from './node-env';
|
33
40
|
export * from './platform';
|
package/dist/is/index.js
CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
18
18
|
};
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
20
|
-
exports.isFastRefresh = exports.isUseSSRBundle = exports.isSSR = exports.isEmpty = exports.isTypescript = exports.isDepExists = void 0;
|
20
|
+
exports.isFastRefresh = exports.isServiceWorker = exports.isUseSSRBundle = exports.isSSR = exports.isEmpty = exports.isTypescript = exports.isDepExists = void 0;
|
21
21
|
const fs_1 = __importDefault(require("fs"));
|
22
22
|
const path_1 = __importDefault(require("path"));
|
23
23
|
const debug_1 = require("../debug");
|
@@ -86,6 +86,20 @@ const isUseSSRBundle = (config) => {
|
|
86
86
|
return (0, exports.isSSR)(config);
|
87
87
|
};
|
88
88
|
exports.isUseSSRBundle = isUseSSRBundle;
|
89
|
+
/**
|
90
|
+
* Is Worker project
|
91
|
+
*
|
92
|
+
* @param config - User config.
|
93
|
+
* @returns Whether to use worker deploy.
|
94
|
+
*/
|
95
|
+
const isServiceWorker = (config) => {
|
96
|
+
const { output, server } = config;
|
97
|
+
if ((server === null || server === void 0 ? void 0 : server.worker) && ((output === null || output === void 0 ? void 0 : output.ssg) || (0, exports.isSSR)(config))) {
|
98
|
+
return true;
|
99
|
+
}
|
100
|
+
return false;
|
101
|
+
};
|
102
|
+
exports.isServiceWorker = isServiceWorker;
|
89
103
|
const isFastRefresh = () => (0, node_env_1.isDev)() && process.env.FAST_REFRESH !== 'false';
|
90
104
|
exports.isFastRefresh = isFastRefresh;
|
91
105
|
__exportStar(require("./node-env"), exports);
|
package/dist/is/node-env.d.ts
CHANGED
package/dist/is/node-env.js
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.isProdProfile = exports.isTest = exports.isProd = exports.isDev = void 0;
|
4
|
-
|
3
|
+
exports.isProdProfile = exports.isTest = exports.isProd = exports.isDev = exports.getNodeEnv = void 0;
|
4
|
+
/**
|
5
|
+
* Get the current NODE_ENV, or default to 'development' if not set.
|
6
|
+
*/
|
7
|
+
const getNodeEnv = () => process.env.NODE_ENV || 'development';
|
8
|
+
exports.getNodeEnv = getNodeEnv;
|
9
|
+
const isDev = () => (0, exports.getNodeEnv)() === 'development';
|
5
10
|
exports.isDev = isDev;
|
6
|
-
const isProd = () =>
|
11
|
+
const isProd = () => (0, exports.getNodeEnv)() === 'production';
|
7
12
|
exports.isProd = isProd;
|
8
|
-
const isTest = () =>
|
13
|
+
const isTest = () => (0, exports.getNodeEnv)() === 'test';
|
9
14
|
exports.isTest = isTest;
|
10
15
|
// Variable used for enabling profiling in Production.
|
11
16
|
const isProdProfile = () => (0, exports.isProd)() && process.argv.includes('--profile');
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@modern-js/utils",
|
3
|
-
"description": "
|
3
|
+
"description": "A Progressive React Framework for modern web development.",
|
4
4
|
"homepage": "https://modernjs.dev",
|
5
5
|
"bugs": "https://github.com/modern-js-dev/modern.js/issues",
|
6
6
|
"repository": "modern-js-dev/modern.js",
|
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "2.
|
14
|
+
"version": "2.4.1-beta.0",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/index.d.ts",
|
17
17
|
"main": "./dist/index.js",
|
@@ -134,9 +134,9 @@
|
|
134
134
|
"jest": "^27",
|
135
135
|
"typescript": "^4",
|
136
136
|
"webpack": "^5.75.0",
|
137
|
-
"@modern-js/types": "2.
|
138
|
-
"@scripts/
|
139
|
-
"@scripts/
|
137
|
+
"@modern-js/types": "2.4.0",
|
138
|
+
"@scripts/jest-config": "2.4.0",
|
139
|
+
"@scripts/build": "2.4.0"
|
140
140
|
},
|
141
141
|
"sideEffects": false,
|
142
142
|
"scripts": {
|