@modern-js/utils 2.23.0 → 2.24.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +27 -0
- package/dist/cjs/cli/constants/chainId.js +13 -5
- package/dist/cjs/cli/get/config.js +2 -3
- package/dist/cjs/cli/index.js +0 -1
- package/dist/cjs/cli/is/project.js +5 -2
- package/dist/esm/cli/constants/chainId.js +13 -5
- package/dist/esm/cli/get/config.js +2 -3
- package/dist/esm/cli/index.js +0 -1
- package/dist/esm/cli/is/project.js +5 -2
- package/dist/types/cli/constants/chainId.d.ts +12 -4
- package/dist/types/cli/get/config.d.ts +1 -1
- package/dist/types/cli/index.d.ts +0 -1
- package/package.json +5 -5
- package/dist/cjs/cli/routes.js +0 -29
- package/dist/esm/cli/routes.js +0 -18
- package/dist/types/cli/routes.d.ts +0 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,32 @@
|
|
1
1
|
# @modern-js/utils
|
2
2
|
|
3
|
+
## 2.24.0
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- c882fbd: feat: support config main entry name
|
8
|
+
|
9
|
+
feat: 支持配置主入口名称
|
10
|
+
|
11
|
+
- 4a82c3b: fix: export `@remix-run/router` cjs instead of `react-router-dom`
|
12
|
+
fix: 暴露 `@remix-run/router` 的 cjs 导出代替 `react-router-dom`
|
13
|
+
|
14
|
+
## 2.23.1
|
15
|
+
|
16
|
+
### Patch Changes
|
17
|
+
|
18
|
+
- f08bbfc: feat(builder): add basic Vue 3 plugin
|
19
|
+
|
20
|
+
feat(builder): 增加基础的 Vue 3 插件
|
21
|
+
|
22
|
+
- a6b313a: fix(builder): can't use new React JSX with parent's package.json
|
23
|
+
|
24
|
+
fix(builder): 修复 package.json 在父级目录时无法使用新版 react jsx 的问题
|
25
|
+
|
26
|
+
- 8f2cab0: feat(builder): support using new URL to handle wasm assets
|
27
|
+
|
28
|
+
feat(builder): 支持通过 new URL 来处理 wasm 资源
|
29
|
+
|
3
30
|
## 2.23.0
|
4
31
|
|
5
32
|
### Patch Changes
|
@@ -39,10 +39,14 @@ const CHAIN_ID = {
|
|
39
39
|
SVG: "svg",
|
40
40
|
/** Rule for pug */
|
41
41
|
PUG: "pug",
|
42
|
+
/** Rule for Vue */
|
43
|
+
VUE: "vue",
|
42
44
|
/** Rule for toml */
|
43
45
|
TOML: "toml",
|
44
46
|
/** Rule for yaml */
|
45
47
|
YAML: "yaml",
|
48
|
+
/** Rule for wasm */
|
49
|
+
WASM: "wasm",
|
46
50
|
/** Rule for bff */
|
47
51
|
JS_BFF_API: "js-bff-api"
|
48
52
|
},
|
@@ -69,6 +73,8 @@ const CHAIN_ID = {
|
|
69
73
|
URL: "url",
|
70
74
|
/** pug-loader */
|
71
75
|
PUG: "pug",
|
76
|
+
/** vue-loader */
|
77
|
+
VUE: "vue",
|
72
78
|
/** file-loader */
|
73
79
|
FILE: "file",
|
74
80
|
/** @svgr/webpack */
|
@@ -138,12 +144,16 @@ const CHAIN_ID = {
|
|
138
144
|
BUNDLE_ANALYZER: "bundle-analyze",
|
139
145
|
/** BottomTemplatePlugin */
|
140
146
|
BOTTOM_TEMPLATE: "bottom-template",
|
141
|
-
/**
|
142
|
-
|
147
|
+
/** HtmlTagsPlugin */
|
148
|
+
HTML_TAGS: "html-tags",
|
143
149
|
/** HtmlNoncePlugin */
|
144
150
|
HTML_NONCE: "html-nonce",
|
151
|
+
/** HtmlCrossOriginPlugin */
|
152
|
+
HTML_CROSS_ORIGIN: "html-cross-origin",
|
145
153
|
/** MiniCssExtractPlugin */
|
146
154
|
MINI_CSS_EXTRACT: "mini-css-extract",
|
155
|
+
/** VueLoaderPlugin */
|
156
|
+
VUE_LOADER_PLUGIN: "vue-loader-plugin",
|
147
157
|
/** ReactFastRefreshPlugin */
|
148
158
|
REACT_FAST_REFRESH: "react-fast-refresh",
|
149
159
|
/** ProvidePlugin for node polyfill */
|
@@ -157,9 +167,7 @@ const CHAIN_ID = {
|
|
157
167
|
/** HtmlAsyncChunkPlugin */
|
158
168
|
HTML_ASYNC_CHUNK: "html-async-chunk",
|
159
169
|
/** SWC_POLYFILL_CHECKER */
|
160
|
-
SWC_POLYFILL_CHECKER: "swc-polyfill-checker-plugin"
|
161
|
-
/** HtmlTagsPlugin */
|
162
|
-
HTML_TAGS: "html-tags"
|
170
|
+
SWC_POLYFILL_CHECKER: "swc-polyfill-checker-plugin"
|
163
171
|
},
|
164
172
|
/** Predefined minimizers */
|
165
173
|
MINIMIZER: {
|
@@ -9,11 +9,10 @@ Object.defineProperty(exports, "getEntryOptions", {
|
|
9
9
|
}
|
10
10
|
});
|
11
11
|
const _is = require("../is");
|
12
|
-
const
|
13
|
-
const getEntryOptions = (name, baseOptions, optionsByEntries, packageName) => {
|
12
|
+
const getEntryOptions = (name, isMainEntry, baseOptions, optionsByEntries, packageName) => {
|
14
13
|
if (optionsByEntries) {
|
15
14
|
let optionsByEntry = getOptionsByEntryName(name, optionsByEntries);
|
16
|
-
if (optionsByEntry === void 0 &&
|
15
|
+
if (optionsByEntry === void 0 && isMainEntry && packageName) {
|
17
16
|
optionsByEntry = getOptionsByEntryName(packageName, optionsByEntries);
|
18
17
|
}
|
19
18
|
return optionsByEntry !== void 0 ? (0, _is.isPlainObject)(optionsByEntry) && (0, _is.isPlainObject)(baseOptions) ? {
|
package/dist/cjs/cli/index.js
CHANGED
@@ -22,6 +22,5 @@ _export_star._(require("./port"), exports);
|
|
22
22
|
_export_star._(require("./prettyInstructions"), exports);
|
23
23
|
_export_star._(require("./print"), exports);
|
24
24
|
_export_star._(require("./require"), exports);
|
25
|
-
_export_star._(require("./routes"), exports);
|
26
25
|
_export_star._(require("./runtimeExports"), exports);
|
27
26
|
_export_star._(require("./watch"), exports);
|
@@ -34,6 +34,7 @@ _export(exports, {
|
|
34
34
|
});
|
35
35
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
36
36
|
const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
|
37
|
+
const _pkgup = /* @__PURE__ */ _interop_require_default._(require("../../../compiled/pkg-up"));
|
37
38
|
const _commands = require("../commands");
|
38
39
|
const _compiled = require("../../compiled");
|
39
40
|
const _common = require("../common");
|
@@ -73,8 +74,10 @@ const isWebOnly = async () => {
|
|
73
74
|
return Boolean(options["web-only"]);
|
74
75
|
};
|
75
76
|
const isBeyondReact17 = (cwd) => {
|
76
|
-
const pkgPath =
|
77
|
-
|
77
|
+
const pkgPath = _pkgup.default.sync({
|
78
|
+
cwd
|
79
|
+
});
|
80
|
+
if (!pkgPath) {
|
78
81
|
return false;
|
79
82
|
}
|
80
83
|
const pkgInfo = JSON.parse(_compiled.fs.readFileSync(pkgPath, "utf8"));
|
@@ -29,10 +29,14 @@ export const CHAIN_ID = {
|
|
29
29
|
SVG: "svg",
|
30
30
|
/** Rule for pug */
|
31
31
|
PUG: "pug",
|
32
|
+
/** Rule for Vue */
|
33
|
+
VUE: "vue",
|
32
34
|
/** Rule for toml */
|
33
35
|
TOML: "toml",
|
34
36
|
/** Rule for yaml */
|
35
37
|
YAML: "yaml",
|
38
|
+
/** Rule for wasm */
|
39
|
+
WASM: "wasm",
|
36
40
|
/** Rule for bff */
|
37
41
|
JS_BFF_API: "js-bff-api"
|
38
42
|
},
|
@@ -59,6 +63,8 @@ export const CHAIN_ID = {
|
|
59
63
|
URL: "url",
|
60
64
|
/** pug-loader */
|
61
65
|
PUG: "pug",
|
66
|
+
/** vue-loader */
|
67
|
+
VUE: "vue",
|
62
68
|
/** file-loader */
|
63
69
|
FILE: "file",
|
64
70
|
/** @svgr/webpack */
|
@@ -128,12 +134,16 @@ export const CHAIN_ID = {
|
|
128
134
|
BUNDLE_ANALYZER: "bundle-analyze",
|
129
135
|
/** BottomTemplatePlugin */
|
130
136
|
BOTTOM_TEMPLATE: "bottom-template",
|
131
|
-
/**
|
132
|
-
|
137
|
+
/** HtmlTagsPlugin */
|
138
|
+
HTML_TAGS: "html-tags",
|
133
139
|
/** HtmlNoncePlugin */
|
134
140
|
HTML_NONCE: "html-nonce",
|
141
|
+
/** HtmlCrossOriginPlugin */
|
142
|
+
HTML_CROSS_ORIGIN: "html-cross-origin",
|
135
143
|
/** MiniCssExtractPlugin */
|
136
144
|
MINI_CSS_EXTRACT: "mini-css-extract",
|
145
|
+
/** VueLoaderPlugin */
|
146
|
+
VUE_LOADER_PLUGIN: "vue-loader-plugin",
|
137
147
|
/** ReactFastRefreshPlugin */
|
138
148
|
REACT_FAST_REFRESH: "react-fast-refresh",
|
139
149
|
/** ProvidePlugin for node polyfill */
|
@@ -147,9 +157,7 @@ export const CHAIN_ID = {
|
|
147
157
|
/** HtmlAsyncChunkPlugin */
|
148
158
|
HTML_ASYNC_CHUNK: "html-async-chunk",
|
149
159
|
/** SWC_POLYFILL_CHECKER */
|
150
|
-
SWC_POLYFILL_CHECKER: "swc-polyfill-checker-plugin"
|
151
|
-
/** HtmlTagsPlugin */
|
152
|
-
HTML_TAGS: "html-tags"
|
160
|
+
SWC_POLYFILL_CHECKER: "swc-polyfill-checker-plugin"
|
153
161
|
},
|
154
162
|
/** Predefined minimizers */
|
155
163
|
MINIMIZER: {
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import { isPlainObject } from "../is";
|
2
|
-
|
3
|
-
export const getEntryOptions = (name, baseOptions, optionsByEntries, packageName) => {
|
2
|
+
export const getEntryOptions = (name, isMainEntry, baseOptions, optionsByEntries, packageName) => {
|
4
3
|
if (optionsByEntries) {
|
5
4
|
let optionsByEntry = getOptionsByEntryName(name, optionsByEntries);
|
6
|
-
if (optionsByEntry === void 0 &&
|
5
|
+
if (optionsByEntry === void 0 && isMainEntry && packageName) {
|
7
6
|
optionsByEntry = getOptionsByEntryName(packageName, optionsByEntries);
|
8
7
|
}
|
9
8
|
return optionsByEntry !== void 0 ? isPlainObject(optionsByEntry) && isPlainObject(baseOptions) ? {
|
package/dist/esm/cli/index.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import path from "path";
|
2
|
+
import pkgUp from "../../../compiled/pkg-up";
|
2
3
|
import { getArgv } from "../commands";
|
3
4
|
import { fs, minimist, semver } from "../../compiled";
|
4
5
|
import { createDebugger } from "../common";
|
@@ -38,8 +39,10 @@ export const isWebOnly = async () => {
|
|
38
39
|
return Boolean(options["web-only"]);
|
39
40
|
};
|
40
41
|
export const isBeyondReact17 = (cwd) => {
|
41
|
-
const pkgPath =
|
42
|
-
|
42
|
+
const pkgPath = pkgUp.sync({
|
43
|
+
cwd
|
44
|
+
});
|
45
|
+
if (!pkgPath) {
|
43
46
|
return false;
|
44
47
|
}
|
45
48
|
const pkgInfo = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
@@ -29,10 +29,14 @@ export declare const CHAIN_ID: {
|
|
29
29
|
readonly SVG: "svg";
|
30
30
|
/** Rule for pug */
|
31
31
|
readonly PUG: "pug";
|
32
|
+
/** Rule for Vue */
|
33
|
+
readonly VUE: "vue";
|
32
34
|
/** Rule for toml */
|
33
35
|
readonly TOML: "toml";
|
34
36
|
/** Rule for yaml */
|
35
37
|
readonly YAML: "yaml";
|
38
|
+
/** Rule for wasm */
|
39
|
+
readonly WASM: "wasm";
|
36
40
|
/** Rule for bff */
|
37
41
|
readonly JS_BFF_API: "js-bff-api";
|
38
42
|
};
|
@@ -59,6 +63,8 @@ export declare const CHAIN_ID: {
|
|
59
63
|
readonly URL: "url";
|
60
64
|
/** pug-loader */
|
61
65
|
readonly PUG: "pug";
|
66
|
+
/** vue-loader */
|
67
|
+
readonly VUE: "vue";
|
62
68
|
/** file-loader */
|
63
69
|
readonly FILE: "file";
|
64
70
|
/** @svgr/webpack */
|
@@ -128,12 +134,16 @@ export declare const CHAIN_ID: {
|
|
128
134
|
readonly BUNDLE_ANALYZER: "bundle-analyze";
|
129
135
|
/** BottomTemplatePlugin */
|
130
136
|
readonly BOTTOM_TEMPLATE: "bottom-template";
|
131
|
-
/**
|
132
|
-
readonly
|
137
|
+
/** HtmlTagsPlugin */
|
138
|
+
readonly HTML_TAGS: "html-tags";
|
133
139
|
/** HtmlNoncePlugin */
|
134
140
|
readonly HTML_NONCE: "html-nonce";
|
141
|
+
/** HtmlCrossOriginPlugin */
|
142
|
+
readonly HTML_CROSS_ORIGIN: "html-cross-origin";
|
135
143
|
/** MiniCssExtractPlugin */
|
136
144
|
readonly MINI_CSS_EXTRACT: "mini-css-extract";
|
145
|
+
/** VueLoaderPlugin */
|
146
|
+
readonly VUE_LOADER_PLUGIN: "vue-loader-plugin";
|
137
147
|
/** ReactFastRefreshPlugin */
|
138
148
|
readonly REACT_FAST_REFRESH: "react-fast-refresh";
|
139
149
|
/** ProvidePlugin for node polyfill */
|
@@ -148,8 +158,6 @@ export declare const CHAIN_ID: {
|
|
148
158
|
readonly HTML_ASYNC_CHUNK: "html-async-chunk";
|
149
159
|
/** SWC_POLYFILL_CHECKER */
|
150
160
|
readonly SWC_POLYFILL_CHECKER: "swc-polyfill-checker-plugin";
|
151
|
-
/** HtmlTagsPlugin */
|
152
|
-
readonly HTML_TAGS: "html-tags";
|
153
161
|
};
|
154
162
|
/** Predefined minimizers */
|
155
163
|
readonly MINIMIZER: {
|
@@ -1 +1 @@
|
|
1
|
-
export declare const getEntryOptions: <T>(name: string, baseOptions?: T | undefined, optionsByEntries?: Record<string, T> | undefined, packageName?: string) => T | undefined;
|
1
|
+
export declare const getEntryOptions: <T>(name: string, isMainEntry: boolean, baseOptions?: T | undefined, optionsByEntries?: Record<string, T> | undefined, packageName?: string) => T | undefined;
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.
|
18
|
+
"version": "2.24.0",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -36,11 +36,11 @@
|
|
36
36
|
},
|
37
37
|
"./runtime/router": {
|
38
38
|
"types": "./dist/types/runtime/router.d.ts",
|
39
|
-
"require": "./dist/cjs/runtime/router.js",
|
40
39
|
"default": "./dist/esm/runtime/router.js"
|
41
40
|
},
|
42
41
|
"./runtime/remix-router": {
|
43
42
|
"types": "./dist/types/runtime/remixRouter.d.ts",
|
43
|
+
"require": "./dist/cjs/runtime/remixRouter.js",
|
44
44
|
"default": "./dist/esm/runtime/remixRouter.js"
|
45
45
|
},
|
46
46
|
"./runtime/nested-routes": {
|
@@ -235,9 +235,9 @@
|
|
235
235
|
"typescript": "^5",
|
236
236
|
"webpack": "^5.82.1",
|
237
237
|
"@types/serialize-javascript": "^5.0.1",
|
238
|
-
"@modern-js/types": "2.
|
239
|
-
"@scripts/build": "2.
|
240
|
-
"@scripts/jest-config": "2.
|
238
|
+
"@modern-js/types": "2.24.0",
|
239
|
+
"@scripts/build": "2.24.0",
|
240
|
+
"@scripts/jest-config": "2.24.0"
|
241
241
|
},
|
242
242
|
"sideEffects": false,
|
243
243
|
"scripts": {
|
package/dist/cjs/cli/routes.js
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "getRouteId", {
|
6
|
-
enumerable: true,
|
7
|
-
get: function() {
|
8
|
-
return getRouteId;
|
9
|
-
}
|
10
|
-
});
|
11
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
12
|
-
const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
|
13
|
-
const _constants = require("./constants");
|
14
|
-
const _path1 = require("./path");
|
15
|
-
const getPathWithoutExt = (filename) => {
|
16
|
-
const extname = _path.default.extname(filename);
|
17
|
-
return filename.slice(0, -extname.length);
|
18
|
-
};
|
19
|
-
const getRouteId = (componentPath, routesDir, entryName) => {
|
20
|
-
const relativePath = (0, _path1.normalizeToPosixPath)(_path.default.relative(routesDir, componentPath));
|
21
|
-
const pathWithoutExt = getPathWithoutExt(relativePath);
|
22
|
-
let id = ``;
|
23
|
-
if (entryName === _constants.MAIN_ENTRY_NAME) {
|
24
|
-
id = pathWithoutExt;
|
25
|
-
} else {
|
26
|
-
id = `${entryName}_${pathWithoutExt}`;
|
27
|
-
}
|
28
|
-
return id.replace(/\[(.*?)\]/g, "($1)");
|
29
|
-
};
|
package/dist/esm/cli/routes.js
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
import path from "path";
|
2
|
-
import { MAIN_ENTRY_NAME } from "./constants";
|
3
|
-
import { normalizeToPosixPath } from "./path";
|
4
|
-
const getPathWithoutExt = (filename) => {
|
5
|
-
const extname = path.extname(filename);
|
6
|
-
return filename.slice(0, -extname.length);
|
7
|
-
};
|
8
|
-
export const getRouteId = (componentPath, routesDir, entryName) => {
|
9
|
-
const relativePath = normalizeToPosixPath(path.relative(routesDir, componentPath));
|
10
|
-
const pathWithoutExt = getPathWithoutExt(relativePath);
|
11
|
-
let id = ``;
|
12
|
-
if (entryName === MAIN_ENTRY_NAME) {
|
13
|
-
id = pathWithoutExt;
|
14
|
-
} else {
|
15
|
-
id = `${entryName}_${pathWithoutExt}`;
|
16
|
-
}
|
17
|
-
return id.replace(/\[(.*?)\]/g, "($1)");
|
18
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const getRouteId: (componentPath: string, routesDir: string, entryName: string) => string;
|