@modern-js/utils 1.15.0 → 1.16.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +29 -0
- package/dist/analyzeProject.d.ts +1 -1
- package/dist/analyzeProject.js +2 -2
- package/dist/chainId.d.ts +8 -0
- package/dist/chainId.js +8 -0
- package/dist/constants.js +0 -10
- package/dist/format.d.ts +0 -3
- package/dist/format.js +1 -26
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/reactVersion.d.ts +1 -0
- package/dist/reactVersion.js +24 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
# @modern-js/utils
|
2
2
|
|
3
|
+
## 1.16.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- 1100dd58c: chore: support react 18
|
8
|
+
|
9
|
+
chore: 支持 React 18
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- 641592f52: feat(utils): add html-cross-origin to CHAIN_ID
|
14
|
+
|
15
|
+
feat(utils): CHAIN_ID 常量新增 html-cross-origin 值
|
16
|
+
|
17
|
+
- 3904b30a5: fix: check apiOnly while has source.entriesDir
|
18
|
+
|
19
|
+
fix: 当配置 source.entriesDir 存在时,apiOnly 检查错误
|
20
|
+
|
21
|
+
- e04e6e76a: feat: add media rule name to CHAIN_ID constant
|
22
|
+
|
23
|
+
feat: 在 CHAIN_ID 常量中新增 media rule
|
24
|
+
|
25
|
+
- 81c66e4a4: fix: compatibility issues of dev server in iOS 10
|
26
|
+
|
27
|
+
fix: 修复 dev server 代码在 iOS 10 下的兼容性问题
|
28
|
+
|
29
|
+
- 2c305b6f5: chore: remove all deploy logic and package
|
30
|
+
chore: 删除所有部署相关的逻辑和包
|
31
|
+
|
3
32
|
## 1.15.0
|
4
33
|
|
5
34
|
### Patch Changes
|
package/dist/analyzeProject.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export declare const isApiOnly: (appDirectory: string) => Promise<boolean>;
|
1
|
+
export declare const isApiOnly: (appDirectory: string, entryDir?: string) => Promise<boolean>;
|
package/dist/analyzeProject.js
CHANGED
@@ -26,8 +26,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.isApiOnly = void 0;
|
27
27
|
const path = __importStar(require("path"));
|
28
28
|
const compiled_1 = require("./compiled");
|
29
|
-
const isApiOnly = async (appDirectory) => {
|
30
|
-
const srcDir = path.join(appDirectory, 'src');
|
29
|
+
const isApiOnly = async (appDirectory, entryDir) => {
|
30
|
+
const srcDir = path.join(appDirectory, entryDir !== null && entryDir !== void 0 ? entryDir : 'src');
|
31
31
|
const existSrc = await compiled_1.fs.pathExists(srcDir);
|
32
32
|
const options = (0, compiled_1.minimist)(process.argv.slice(2));
|
33
33
|
return !existSrc || Boolean(options['api-only']);
|
package/dist/chainId.d.ts
CHANGED
@@ -9,6 +9,8 @@ export declare const CHAIN_ID: {
|
|
9
9
|
readonly FONT: "font";
|
10
10
|
/** Rule for images */
|
11
11
|
readonly IMAGE: "image";
|
12
|
+
/** Rule for media */
|
13
|
+
readonly MEDIA: "media";
|
12
14
|
/** Rule for js */
|
13
15
|
readonly JS: "js";
|
14
16
|
/** Rule for ts */
|
@@ -19,6 +21,10 @@ export declare const CHAIN_ID: {
|
|
19
21
|
readonly LESS: "less";
|
20
22
|
/** Rule for sass */
|
21
23
|
readonly SASS: "sass";
|
24
|
+
/** Rule for svg */
|
25
|
+
readonly SVG: "svg";
|
26
|
+
readonly SVG_INLINE: "svg-inline";
|
27
|
+
readonly SVG_URL: "svg-url";
|
22
28
|
};
|
23
29
|
/** Predefined rule groups */
|
24
30
|
readonly ONE_OF: {
|
@@ -107,6 +113,8 @@ export declare const CHAIN_ID: {
|
|
107
113
|
readonly BUNDLE_ANALYZER: "bundle-analyze";
|
108
114
|
/** BottomTemplatePlugin */
|
109
115
|
readonly BOTTOM_TEMPLATE: "bottom-template";
|
116
|
+
/** HtmlCrossOriginPlugin */
|
117
|
+
readonly HTML_CROSS_ORIGIN: "html-cross-origin";
|
110
118
|
/** MiniCssExtractPlugin */
|
111
119
|
readonly MINI_CSS_EXTRACT: "mini-css-extract";
|
112
120
|
/** ReactFastRefreshPlugin */
|
package/dist/chainId.js
CHANGED
@@ -12,6 +12,8 @@ exports.CHAIN_ID = {
|
|
12
12
|
FONT: 'font',
|
13
13
|
/** Rule for images */
|
14
14
|
IMAGE: 'image',
|
15
|
+
/** Rule for media */
|
16
|
+
MEDIA: 'media',
|
15
17
|
/** Rule for js */
|
16
18
|
JS: 'js',
|
17
19
|
/** Rule for ts */
|
@@ -22,6 +24,10 @@ exports.CHAIN_ID = {
|
|
22
24
|
LESS: 'less',
|
23
25
|
/** Rule for sass */
|
24
26
|
SASS: 'sass',
|
27
|
+
/** Rule for svg */
|
28
|
+
SVG: 'svg',
|
29
|
+
SVG_INLINE: 'svg-inline',
|
30
|
+
SVG_URL: 'svg-url',
|
25
31
|
},
|
26
32
|
/** Predefined rule groups */
|
27
33
|
ONE_OF: {
|
@@ -110,6 +116,8 @@ exports.CHAIN_ID = {
|
|
110
116
|
BUNDLE_ANALYZER: 'bundle-analyze',
|
111
117
|
/** BottomTemplatePlugin */
|
112
118
|
BOTTOM_TEMPLATE: 'bottom-template',
|
119
|
+
/** HtmlCrossOriginPlugin */
|
120
|
+
HTML_CROSS_ORIGIN: 'html-cross-origin',
|
113
121
|
/** MiniCssExtractPlugin */
|
114
122
|
MINI_CSS_EXTRACT: 'mini-css-extract',
|
115
123
|
/** ReactFastRefreshPlugin */
|
package/dist/constants.js
CHANGED
@@ -98,20 +98,10 @@ exports.INTERNAL_PLUGINS = {
|
|
98
98
|
cli: '@modern-js/plugin-garfish/cli',
|
99
99
|
},
|
100
100
|
'@modern-js/plugin-tailwindcss': { cli: '@modern-js/plugin-tailwindcss/cli' },
|
101
|
-
'@modern-js/plugin-lambda-fc': { cli: '@modern-js/plugin-lambda-fc/cli' },
|
102
|
-
'@modern-js/plugin-lambda-scf': { cli: '@modern-js/plugin-lambda-scf/cli' },
|
103
|
-
'@modern-js/plugin-cdn-oss': { cli: '@modern-js/plugin-cdn-oss/cli' },
|
104
|
-
'@modern-js/plugin-cdn-cos': { cli: '@modern-js/plugin-cdn-cos/cli' },
|
105
|
-
'@modern-js/plugin-static-hosting': {
|
106
|
-
cli: '@modern-js/plugin-static-hosting/cli',
|
107
|
-
},
|
108
101
|
'@modern-js/plugin-polyfill': {
|
109
102
|
cli: '@modern-js/plugin-polyfill/cli',
|
110
103
|
server: '@modern-js/plugin-polyfill',
|
111
104
|
},
|
112
|
-
'@modern-js/plugin-multiprocess': {
|
113
|
-
cli: '@modern-js/plugin-multiprocess/cli',
|
114
|
-
},
|
115
105
|
// TODO: Maybe can remove it
|
116
106
|
'@modern-js/plugin-nocode': { cli: '@modern-js/plugin-nocode/cli' },
|
117
107
|
};
|
package/dist/format.d.ts
CHANGED
@@ -6,11 +6,8 @@
|
|
6
6
|
* https://github.com/facebook/create-react-app/blob/master/LICENSE
|
7
7
|
*/
|
8
8
|
import type { StatsCompilation } from 'webpack';
|
9
|
-
import type { ProxyDetail, BffProxyOptions } from '@modern-js/types';
|
10
9
|
declare function formatWebpackMessages(json: StatsCompilation): {
|
11
10
|
errors: string[];
|
12
11
|
warnings: string[];
|
13
12
|
};
|
14
13
|
export { formatWebpackMessages };
|
15
|
-
declare function formatProxyOptions(proxyOptions: BffProxyOptions): ProxyDetail[];
|
16
|
-
export { formatProxyOptions };
|
package/dist/format.js
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
* https://github.com/facebook/create-react-app/blob/master/LICENSE
|
8
8
|
*/
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
10
|
-
exports.
|
10
|
+
exports.formatWebpackMessages = void 0;
|
11
11
|
const friendlySyntaxErrorLabel = 'SyntaxError:';
|
12
12
|
function isLikelyASyntaxError(message) {
|
13
13
|
return message.includes(friendlySyntaxErrorLabel);
|
@@ -86,28 +86,3 @@ function formatWebpackMessages(json) {
|
|
86
86
|
return result;
|
87
87
|
}
|
88
88
|
exports.formatWebpackMessages = formatWebpackMessages;
|
89
|
-
function formatProxyOptions(proxyOptions) {
|
90
|
-
const formattedProxy = [];
|
91
|
-
if (!Array.isArray(proxyOptions)) {
|
92
|
-
if ('target' in proxyOptions) {
|
93
|
-
formattedProxy.push(proxyOptions);
|
94
|
-
}
|
95
|
-
else {
|
96
|
-
Array.prototype.push.apply(formattedProxy, Object.keys(proxyOptions).reduce((total, source) => {
|
97
|
-
const option = proxyOptions[source];
|
98
|
-
total.push({
|
99
|
-
context: source,
|
100
|
-
changeOrigin: true,
|
101
|
-
logLevel: 'warn',
|
102
|
-
...(typeof option === 'string' ? { target: option } : option),
|
103
|
-
});
|
104
|
-
return total;
|
105
|
-
}, []));
|
106
|
-
}
|
107
|
-
}
|
108
|
-
else {
|
109
|
-
formattedProxy.push(...proxyOptions);
|
110
|
-
}
|
111
|
-
return formattedProxy;
|
112
|
-
}
|
113
|
-
exports.formatProxyOptions = formatProxyOptions;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
export declare const isReact18: (cwd: string) => boolean;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.isReact18 = void 0;
|
7
|
+
const path_1 = __importDefault(require("path"));
|
8
|
+
const compiled_1 = require("./compiled");
|
9
|
+
const isReact18 = (cwd) => {
|
10
|
+
const pkgPath = path_1.default.join(cwd, 'package.json');
|
11
|
+
if (!compiled_1.fs.existsSync(pkgPath)) {
|
12
|
+
return false;
|
13
|
+
}
|
14
|
+
const pkgInfo = JSON.parse(compiled_1.fs.readFileSync(pkgPath, 'utf8'));
|
15
|
+
const deps = {
|
16
|
+
...pkgInfo.devDependencies,
|
17
|
+
...pkgInfo.dependencies,
|
18
|
+
};
|
19
|
+
if (typeof deps.react !== 'string') {
|
20
|
+
return false;
|
21
|
+
}
|
22
|
+
return compiled_1.semver.satisfies(compiled_1.semver.minVersion(deps.react), '>=18.0.0');
|
23
|
+
};
|
24
|
+
exports.isReact18 = isReact18;
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "1.
|
14
|
+
"version": "1.16.0",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/index.d.ts",
|
17
17
|
"main": "./dist/index.js",
|
@@ -121,7 +121,7 @@
|
|
121
121
|
"lodash": "^4.17.21"
|
122
122
|
},
|
123
123
|
"devDependencies": {
|
124
|
-
"@modern-js/types": "1.
|
124
|
+
"@modern-js/types": "1.16.0",
|
125
125
|
"@scripts/build": "1.15.0",
|
126
126
|
"@scripts/jest-config": "1.15.0",
|
127
127
|
"@types/jest": "^27",
|