@modern-js/utils 2.4.0 → 2.5.0-alpha.0
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 +14 -0
- package/dist/FileSizeReporter.d.ts +5 -5
- package/dist/FileSizeReporter.js +143 -136
- package/dist/alias.d.ts +16 -14
- package/dist/alias.js +94 -54
- package/dist/analyzeProject.d.ts +1 -1
- package/dist/analyzeProject.js +58 -33
- package/dist/applyOptionsChain.d.ts +1 -1
- package/dist/applyOptionsChain.js +55 -27
- package/dist/chainId.d.ts +256 -184
- package/dist/chainId.js +132 -187
- package/dist/clearConsole.d.ts +1 -1
- package/dist/clearConsole.js +29 -7
- package/dist/commands.d.ts +1 -1
- package/dist/commands.js +33 -10
- package/dist/compatRequire.d.ts +3 -3
- package/dist/compatRequire.js +74 -38
- package/dist/compiled.d.ts +2 -1
- package/dist/compiled.js +137 -72
- package/dist/constants.d.ts +131 -105
- package/dist/constants.js +298 -277
- package/dist/debug.d.ts +1 -1
- package/dist/debug.js +28 -11
- package/dist/emptyDir.d.ts +1 -1
- package/dist/emptyDir.js +51 -9
- package/dist/ensureAbsolutePath.d.ts +1 -1
- package/dist/ensureAbsolutePath.js +33 -14
- package/dist/ensureArray.d.ts +1 -1
- package/dist/ensureArray.js +30 -8
- package/dist/findExists.d.ts +1 -1
- package/dist/findExists.js +37 -17
- package/dist/format.d.ts +3 -3
- package/dist/format.js +93 -81
- package/dist/generateMetaTags.d.ts +4 -4
- package/dist/generateMetaTags.js +56 -43
- package/dist/getBrowserslist.d.ts +1 -1
- package/dist/getBrowserslist.js +31 -7
- package/dist/getCoreJsVersion.d.ts +1 -1
- package/dist/getCoreJsVersion.js +39 -35
- package/dist/getEntryOptions.d.ts +1 -1
- package/dist/getEntryOptions.js +51 -24
- package/dist/getPackageManager.d.ts +1 -1
- package/dist/getPackageManager.js +75 -28
- package/dist/getPort.d.ts +7 -4
- package/dist/getPort.js +104 -58
- package/dist/getServerConfig.d.ts +1 -1
- package/dist/getServerConfig.js +61 -32
- package/dist/import.d.ts +2 -2
- package/dist/import.js +31 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.js +61 -59
- package/dist/is/index.d.ts +12 -1
- package/dist/is/index.js +83 -82
- package/dist/is/node-env.d.ts +1 -1
- package/dist/is/node-env.js +39 -17
- package/dist/is/platform.d.ts +1 -1
- package/dist/is/platform.js +30 -10
- package/dist/is/type.d.ts +1 -1
- package/dist/is/type.js +48 -22
- package/dist/logger.d.ts +51 -51
- package/dist/logger.js +127 -95
- package/dist/monorepo.d.ts +3 -3
- package/dist/monorepo.js +117 -74
- package/dist/nestedRoutes.d.ts +9 -0
- package/dist/nestedRoutes.js +144 -0
- package/dist/nodeEnv.d.ts +1 -1
- package/dist/nodeEnv.js +72 -25
- package/dist/path.d.ts +3 -1
- package/dist/path.js +76 -59
- package/dist/pathSerializer.d.ts +7 -7
- package/dist/pathSerializer.js +65 -43
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +45 -26
- package/dist/prettyInstructions.d.ts +4 -4
- package/dist/prettyInstructions.js +107 -65
- package/dist/printBuildError.d.ts +1 -1
- package/dist/printBuildError.js +54 -40
- package/dist/react.d.ts +1 -1
- package/dist/react.js +57 -21
- package/dist/readTsConfig.d.ts +1 -1
- package/dist/readTsConfig.js +38 -12
- package/dist/remix-router.d.ts +1 -0
- package/dist/remix-router.js +17 -0
- package/dist/removeSlash.d.ts +1 -1
- package/dist/removeSlash.js +33 -9
- package/dist/routes.d.ts +1 -1
- package/dist/routes.js +49 -22
- package/dist/runtimeExports.d.ts +3 -3
- package/dist/runtimeExports.js +59 -39
- package/dist/serialize.d.ts +1 -0
- package/dist/serialize.js +36 -0
- package/dist/ssr.d.ts +2 -1
- package/dist/ssr.js +30 -7
- package/dist/storage.d.ts +3 -3
- package/dist/storage.js +65 -59
- package/dist/test-utils.d.ts +1 -1
- package/dist/test-utils.js +30 -24
- package/dist/tryResolve.d.ts +2 -1
- package/dist/tryResolve.js +45 -33
- package/dist/types.d.ts +1 -1
- package/dist/types.js +15 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +83 -24
- package/dist/wait.d.ts +1 -1
- package/dist/wait.js +28 -6
- package/dist/watch.d.ts +5 -5
- package/dist/watch.js +82 -55
- package/package.json +31 -9
@@ -0,0 +1,144 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __defProps = Object.defineProperties;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
10
|
+
var __spreadValues = (a, b) => {
|
11
|
+
for (var prop in b || (b = {}))
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
14
|
+
if (__getOwnPropSymbols)
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
16
|
+
if (__propIsEnum.call(b, prop))
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
18
|
+
}
|
19
|
+
return a;
|
20
|
+
};
|
21
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
22
|
+
var __export = (target, all) => {
|
23
|
+
for (var name in all)
|
24
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
25
|
+
};
|
26
|
+
var __copyProps = (to, from, except, desc) => {
|
27
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
28
|
+
for (let key of __getOwnPropNames(from))
|
29
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
30
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
31
|
+
}
|
32
|
+
return to;
|
33
|
+
};
|
34
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
35
|
+
var nestedRoutes_exports = {};
|
36
|
+
__export(nestedRoutes_exports, {
|
37
|
+
renderNestedRoute: () => renderNestedRoute,
|
38
|
+
transformNestedRoutes: () => transformNestedRoutes
|
39
|
+
});
|
40
|
+
module.exports = __toCommonJS(nestedRoutes_exports);
|
41
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
42
|
+
var import_react = require("react");
|
43
|
+
var import_react_router_dom = require("react-router-dom");
|
44
|
+
const transformNestedRoutes = (routes) => {
|
45
|
+
const routeElements = [];
|
46
|
+
for (const route of routes) {
|
47
|
+
const routeElement = renderNestedRoute(route);
|
48
|
+
routeElements.push(routeElement);
|
49
|
+
}
|
50
|
+
return (0, import_react_router_dom.createRoutesFromElements)(routeElements);
|
51
|
+
};
|
52
|
+
const renderNestedRoute = (nestedRoute, options = {}) => {
|
53
|
+
const { children, index, id, component, isRoot } = nestedRoute;
|
54
|
+
const Component = component;
|
55
|
+
const { parent, DeferredDataComponent } = options;
|
56
|
+
const routeProps = {
|
57
|
+
caseSensitive: nestedRoute.caseSensitive,
|
58
|
+
path: nestedRoute.path,
|
59
|
+
id: nestedRoute.id,
|
60
|
+
loader: createLoader(nestedRoute),
|
61
|
+
action: nestedRoute.action,
|
62
|
+
hasErrorBoundary: nestedRoute.hasErrorBoundary,
|
63
|
+
shouldRevalidate: nestedRoute.shouldRevalidate,
|
64
|
+
handle: nestedRoute.handle,
|
65
|
+
index: nestedRoute.index,
|
66
|
+
element: nestedRoute.element,
|
67
|
+
errorElement: nestedRoute.errorElement
|
68
|
+
};
|
69
|
+
if (nestedRoute.error) {
|
70
|
+
const errorElement = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(nestedRoute.error, {});
|
71
|
+
routeProps.errorElement = errorElement;
|
72
|
+
}
|
73
|
+
let element;
|
74
|
+
if (Component) {
|
75
|
+
if (parent == null ? void 0 : parent.loading) {
|
76
|
+
const Loading = parent.loading;
|
77
|
+
if (isLoadableComponent(Component)) {
|
78
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
|
79
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {})
|
80
|
+
});
|
81
|
+
} else {
|
82
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, {
|
83
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {}),
|
84
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {})
|
85
|
+
});
|
86
|
+
}
|
87
|
+
} else if (isLoadableComponent(Component)) {
|
88
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
|
89
|
+
} else if (isRoot) {
|
90
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
91
|
+
children: [
|
92
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}),
|
93
|
+
typeof document === "undefined" && DeferredDataComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DeferredDataComponent, {})
|
94
|
+
]
|
95
|
+
});
|
96
|
+
} else {
|
97
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, {
|
98
|
+
fallback: null,
|
99
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {})
|
100
|
+
});
|
101
|
+
}
|
102
|
+
} else {
|
103
|
+
nestedRoute.loading = parent == null ? void 0 : parent.loading;
|
104
|
+
}
|
105
|
+
if (element) {
|
106
|
+
routeProps.element = element;
|
107
|
+
}
|
108
|
+
const childElements = children == null ? void 0 : children.map((childRoute) => {
|
109
|
+
return renderNestedRoute(childRoute, { parent: nestedRoute });
|
110
|
+
});
|
111
|
+
const routeElement = index ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Route, __spreadProps(__spreadValues({}, routeProps), {
|
112
|
+
index: true
|
113
|
+
}), id) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Route, __spreadProps(__spreadValues({}, routeProps), {
|
114
|
+
index: false,
|
115
|
+
children: childElements
|
116
|
+
}), id);
|
117
|
+
return routeElement;
|
118
|
+
};
|
119
|
+
function createLoader(route) {
|
120
|
+
const { loader } = route;
|
121
|
+
if (loader) {
|
122
|
+
return (args) => {
|
123
|
+
if (typeof route.lazyImport === "function") {
|
124
|
+
route.lazyImport();
|
125
|
+
}
|
126
|
+
return loader(args);
|
127
|
+
};
|
128
|
+
} else {
|
129
|
+
return () => {
|
130
|
+
if (typeof route.lazyImport === "function") {
|
131
|
+
route.lazyImport();
|
132
|
+
}
|
133
|
+
return null;
|
134
|
+
};
|
135
|
+
}
|
136
|
+
}
|
137
|
+
function isLoadableComponent(component) {
|
138
|
+
return component && component.displayName === "Loadable" && component.preload && typeof component.preload === "function";
|
139
|
+
}
|
140
|
+
// Annotate the CommonJS export names for ESM import in node:
|
141
|
+
0 && (module.exports = {
|
142
|
+
renderNestedRoute,
|
143
|
+
transformNestedRoutes
|
144
|
+
});
|
package/dist/nodeEnv.d.ts
CHANGED
package/dist/nodeEnv.js
CHANGED
@@ -1,34 +1,81 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
var __async = (__this, __arguments, generator) => {
|
19
|
+
return new Promise((resolve, reject) => {
|
20
|
+
var fulfilled = (value) => {
|
21
|
+
try {
|
22
|
+
step(generator.next(value));
|
23
|
+
} catch (e) {
|
24
|
+
reject(e);
|
25
|
+
}
|
26
|
+
};
|
27
|
+
var rejected = (value) => {
|
28
|
+
try {
|
29
|
+
step(generator.throw(value));
|
30
|
+
} catch (e) {
|
31
|
+
reject(e);
|
32
|
+
}
|
33
|
+
};
|
34
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
35
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
36
|
+
});
|
37
|
+
};
|
38
|
+
var nodeEnv_exports = {};
|
39
|
+
__export(nodeEnv_exports, {
|
40
|
+
canUseNpm: () => canUseNpm,
|
41
|
+
canUsePnpm: () => canUsePnpm,
|
42
|
+
canUseYarn: () => canUseYarn
|
43
|
+
});
|
44
|
+
module.exports = __toCommonJS(nodeEnv_exports);
|
45
|
+
var import_compiled = require("./compiled");
|
46
|
+
function canUseNpm() {
|
47
|
+
return __async(this, null, function* () {
|
6
48
|
try {
|
7
|
-
|
8
|
-
|
9
|
-
}
|
10
|
-
|
11
|
-
return false;
|
49
|
+
yield (0, import_compiled.execa)("npm", ["--version"], { env: process.env });
|
50
|
+
return true;
|
51
|
+
} catch (e) {
|
52
|
+
return false;
|
12
53
|
}
|
54
|
+
});
|
13
55
|
}
|
14
|
-
|
15
|
-
|
56
|
+
function canUseYarn() {
|
57
|
+
return __async(this, null, function* () {
|
16
58
|
try {
|
17
|
-
|
18
|
-
|
19
|
-
}
|
20
|
-
|
21
|
-
return false;
|
59
|
+
yield (0, import_compiled.execa)("yarn", ["--version"], { env: process.env });
|
60
|
+
return true;
|
61
|
+
} catch (e) {
|
62
|
+
return false;
|
22
63
|
}
|
64
|
+
});
|
23
65
|
}
|
24
|
-
|
25
|
-
|
66
|
+
function canUsePnpm() {
|
67
|
+
return __async(this, null, function* () {
|
26
68
|
try {
|
27
|
-
|
28
|
-
|
29
|
-
}
|
30
|
-
|
31
|
-
return false;
|
69
|
+
yield (0, import_compiled.execa)("pnpm", ["--version"], { env: process.env });
|
70
|
+
return true;
|
71
|
+
} catch (e) {
|
72
|
+
return false;
|
32
73
|
}
|
74
|
+
});
|
33
75
|
}
|
34
|
-
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
77
|
+
0 && (module.exports = {
|
78
|
+
canUseNpm,
|
79
|
+
canUsePnpm,
|
80
|
+
canUseYarn
|
81
|
+
});
|
package/dist/path.d.ts
CHANGED
@@ -8,9 +8,11 @@ export declare const getTemplatePath: (prefix?: string) => string;
|
|
8
8
|
* Compile path string to RegExp.
|
9
9
|
* @note Only support posix path.
|
10
10
|
*/
|
11
|
+
|
11
12
|
export declare function compilePathMatcherRegExp(match: string | RegExp): RegExp;
|
12
13
|
/** @internal @see {@link upwardPaths} */
|
14
|
+
|
13
15
|
export declare const _joinPathParts: (_part: unknown, i: number, parts: _.List<string>) => string;
|
14
16
|
export declare function upwardPaths(start: string): string[];
|
15
17
|
export declare function getRealTemporaryDirectory(): string | null;
|
16
|
-
export declare function splitPathString(str: string): string[];
|
18
|
+
export declare function splitPathString(str: string): string[];
|
package/dist/path.js
CHANGED
@@ -1,71 +1,88 @@
|
|
1
|
-
|
2
|
-
var
|
3
|
-
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __export = (target, all) => {
|
8
|
+
for (var name in all)
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
4
10
|
};
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
+
for (let key of __getOwnPropNames(from))
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
+
}
|
17
|
+
return to;
|
18
|
+
};
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
21
|
+
mod
|
22
|
+
));
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
24
|
+
var path_exports = {};
|
25
|
+
__export(path_exports, {
|
26
|
+
_joinPathParts: () => _joinPathParts,
|
27
|
+
compilePathMatcherRegExp: () => compilePathMatcherRegExp,
|
28
|
+
getRealTemporaryDirectory: () => getRealTemporaryDirectory,
|
29
|
+
getTemplatePath: () => getTemplatePath,
|
30
|
+
isPathString: () => isPathString,
|
31
|
+
isRelativePath: () => isRelativePath,
|
32
|
+
normalizeOutputPath: () => normalizeOutputPath,
|
33
|
+
normalizeToPosixPath: () => normalizeToPosixPath,
|
34
|
+
splitPathString: () => splitPathString,
|
35
|
+
upwardPaths: () => upwardPaths
|
36
|
+
});
|
37
|
+
module.exports = __toCommonJS(path_exports);
|
38
|
+
var import_path = __toESM(require("path"));
|
39
|
+
var import_os = __toESM(require("os"));
|
40
|
+
var import_fs = __toESM(require("fs"));
|
41
|
+
var import_compiled = require("./compiled");
|
42
|
+
const isPathString = (test) => import_path.default.posix.basename(test) !== test || import_path.default.win32.basename(test) !== test;
|
13
43
|
const isRelativePath = (test) => /^\.\.?($|[\\/])/.test(test);
|
14
|
-
|
15
|
-
const
|
16
|
-
exports.normalizeOutputPath = normalizeOutputPath;
|
17
|
-
const normalizeToPosixPath = (p) => compiled_1.upath
|
18
|
-
.normalizeSafe(path_1.default.normalize(p || ''))
|
19
|
-
.replace(/^([a-zA-Z]+):/, (_, m) => `/${m.toLowerCase()}`);
|
20
|
-
exports.normalizeToPosixPath = normalizeToPosixPath;
|
44
|
+
const normalizeOutputPath = (s) => s.replace(/\\/g, "\\\\");
|
45
|
+
const normalizeToPosixPath = (p) => import_compiled.upath.normalizeSafe(import_path.default.normalize(p || "")).replace(/^([a-zA-Z]+):/, (_2, m) => `/${m.toLowerCase()}`);
|
21
46
|
const getTemplatePath = (prefix) => {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
47
|
+
const tmpRoot = import_fs.default.realpathSync(import_os.default.tmpdir());
|
48
|
+
const parts = [tmpRoot];
|
49
|
+
prefix && parts.push(prefix);
|
50
|
+
parts.push((0, import_compiled.nanoid)());
|
51
|
+
return import_path.default.resolve(...parts);
|
27
52
|
};
|
28
|
-
exports.getTemplatePath = getTemplatePath;
|
29
|
-
/**
|
30
|
-
* Compile path string to RegExp.
|
31
|
-
* @note Only support posix path.
|
32
|
-
*/
|
33
53
|
function compilePathMatcherRegExp(match) {
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
54
|
+
if (typeof match !== "string") {
|
55
|
+
return match;
|
56
|
+
}
|
57
|
+
const escaped = import_compiled.lodash.escapeRegExp(match);
|
58
|
+
return new RegExp(`(?<=\\W|^)${escaped}(?=\\W|$)`);
|
39
59
|
}
|
40
|
-
|
41
|
-
/** @internal @see {@link upwardPaths} */
|
42
|
-
const _joinPathParts = (_part, i, parts) => (0, compiled_1.lodash)(parts)
|
43
|
-
.filter(part => !['/', '\\'].includes(part))
|
44
|
-
.tap(parts => parts.unshift(''))
|
45
|
-
.slice(0, i + 2)
|
46
|
-
.join('/');
|
47
|
-
exports._joinPathParts = _joinPathParts;
|
60
|
+
const _joinPathParts = (_part, i, parts) => (0, import_compiled.lodash)(parts).filter((part) => !["/", "\\"].includes(part)).tap((parts2) => parts2.unshift("")).slice(0, i + 2).join("/");
|
48
61
|
function upwardPaths(start) {
|
49
|
-
|
50
|
-
.split(/[/\\]/)
|
51
|
-
.filter(Boolean)
|
52
|
-
.map(exports._joinPathParts)
|
53
|
-
.reverse()
|
54
|
-
.push('/')
|
55
|
-
.value();
|
62
|
+
return (0, import_compiled.lodash)(start).split(/[/\\]/).filter(Boolean).map(_joinPathParts).reverse().push("/").value();
|
56
63
|
}
|
57
|
-
exports.upwardPaths = upwardPaths;
|
58
64
|
function getRealTemporaryDirectory() {
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
65
|
+
let ret = null;
|
66
|
+
try {
|
67
|
+
ret = import_os.default.tmpdir();
|
68
|
+
ret = import_fs.default.realpathSync(ret);
|
69
|
+
} catch (e) {
|
70
|
+
}
|
71
|
+
return ret;
|
66
72
|
}
|
67
|
-
exports.getRealTemporaryDirectory = getRealTemporaryDirectory;
|
68
73
|
function splitPathString(str) {
|
69
|
-
|
74
|
+
return str.split(/[\\/]/);
|
70
75
|
}
|
71
|
-
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
77
|
+
0 && (module.exports = {
|
78
|
+
_joinPathParts,
|
79
|
+
compilePathMatcherRegExp,
|
80
|
+
getRealTemporaryDirectory,
|
81
|
+
getTemplatePath,
|
82
|
+
isPathString,
|
83
|
+
isRelativePath,
|
84
|
+
normalizeOutputPath,
|
85
|
+
normalizeToPosixPath,
|
86
|
+
splitPathString,
|
87
|
+
upwardPaths
|
88
|
+
});
|
package/dist/pathSerializer.d.ts
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
/** Different from */
|
2
|
-
export type PathMatchExpression = string | RegExp;
|
2
|
+
export declare type PathMatchExpression = string | RegExp;
|
3
3
|
export interface PathMatcher {
|
4
|
-
|
5
|
-
|
4
|
+
match: PathMatchExpression;
|
5
|
+
mark: string | ((substring: string, ...args: any[]) => string);
|
6
6
|
}
|
7
7
|
export declare const matchUpwardPathsAsUnknown: (p: string) => {
|
8
|
-
|
9
|
-
|
8
|
+
match: string;
|
9
|
+
mark: string;
|
10
10
|
}[];
|
11
11
|
export interface ApplyPathMatcherOptions {
|
12
|
-
|
12
|
+
minPartials?: number;
|
13
13
|
}
|
14
14
|
export declare function applyPathMatcher(matcher: PathMatcher, str: string, options?: ApplyPathMatcherOptions): string;
|
15
15
|
export declare function applyMatcherReplacement(matchers: PathMatcher[], str: string, options?: ApplyPathMatcherOptions): string;
|
16
|
-
export declare const createDefaultPathMatchers: (root: string) => PathMatcher[];
|
16
|
+
export declare const createDefaultPathMatchers: (root: string) => PathMatcher[];
|
package/dist/pathSerializer.js
CHANGED
@@ -1,50 +1,72 @@
|
|
1
|
-
|
2
|
-
var
|
3
|
-
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __export = (target, all) => {
|
8
|
+
for (var name in all)
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
4
10
|
};
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
+
for (let key of __getOwnPropNames(from))
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
+
}
|
17
|
+
return to;
|
18
|
+
};
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
21
|
+
mod
|
22
|
+
));
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
24
|
+
var pathSerializer_exports = {};
|
25
|
+
__export(pathSerializer_exports, {
|
26
|
+
applyMatcherReplacement: () => applyMatcherReplacement,
|
27
|
+
applyPathMatcher: () => applyPathMatcher,
|
28
|
+
createDefaultPathMatchers: () => createDefaultPathMatchers,
|
29
|
+
matchUpwardPathsAsUnknown: () => matchUpwardPathsAsUnknown
|
30
|
+
});
|
31
|
+
module.exports = __toCommonJS(pathSerializer_exports);
|
32
|
+
var import_os = __toESM(require("os"));
|
33
|
+
var import_lodash = __toESM(require("../compiled/lodash"));
|
34
|
+
var import_path = require("./path");
|
35
|
+
const matchUpwardPathsAsUnknown = (p) => (0, import_lodash.default)((0, import_path.upwardPaths)((0, import_path.normalizeToPosixPath)(p))).map((match) => ({ match, mark: "unknown" })).slice(1, -1).value();
|
15
36
|
function applyPathMatcher(matcher, str, options = {}) {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
return `<${lodash_1.default.snakeCase(ret).toUpperCase()}>`;
|
26
|
-
};
|
27
|
-
return str.replace(regex, replacer);
|
37
|
+
const regex = (0, import_path.compilePathMatcherRegExp)(matcher.match);
|
38
|
+
const replacer = (substring, ...args) => {
|
39
|
+
if (options.minPartials && (0, import_path.splitPathString)(substring).length < options.minPartials) {
|
40
|
+
return substring;
|
41
|
+
}
|
42
|
+
const ret = typeof matcher.mark === "string" ? matcher.mark : matcher.mark(substring, ...args);
|
43
|
+
return `<${import_lodash.default.snakeCase(ret).toUpperCase()}>`;
|
44
|
+
};
|
45
|
+
return str.replace(regex, replacer);
|
28
46
|
}
|
29
|
-
exports.applyPathMatcher = applyPathMatcher;
|
30
47
|
function applyMatcherReplacement(matchers, str, options = {}) {
|
31
|
-
|
32
|
-
|
33
|
-
|
48
|
+
return matchers.reduce((ret, matcher) => {
|
49
|
+
return applyPathMatcher(matcher, ret, options);
|
50
|
+
}, str);
|
34
51
|
}
|
35
|
-
exports.applyMatcherReplacement = applyMatcherReplacement;
|
36
52
|
const createDefaultPathMatchers = (root) => {
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
53
|
+
const ret = [
|
54
|
+
{
|
55
|
+
match: new RegExp("(?<=\\/)(\\.pnpm\\/.+?\\/node_modules)(?=\\/)"),
|
56
|
+
mark: "pnpmInner"
|
57
|
+
}
|
58
|
+
];
|
59
|
+
const tmpdir = (0, import_path.getRealTemporaryDirectory)();
|
60
|
+
tmpdir && ret.push({ match: tmpdir, mark: "temp" });
|
61
|
+
ret.push({ match: import_os.default.tmpdir(), mark: "temp" });
|
62
|
+
ret.push({ match: import_os.default.homedir(), mark: "home" });
|
63
|
+
ret.push(...matchUpwardPathsAsUnknown(root));
|
64
|
+
return ret;
|
49
65
|
};
|
50
|
-
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
67
|
+
0 && (module.exports = {
|
68
|
+
applyMatcherReplacement,
|
69
|
+
applyPathMatcher,
|
70
|
+
createDefaultPathMatchers,
|
71
|
+
matchUpwardPathsAsUnknown
|
72
|
+
});
|
package/dist/plugin.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
import { InternalPlugins } from '@modern-js/types';
|
2
|
-
export declare function getInternalPlugins(appDirectory: string, internalPlugins?: InternalPlugins): string[];
|
2
|
+
export declare function getInternalPlugins(appDirectory: string, internalPlugins?: InternalPlugins): string[];
|
package/dist/plugin.js
CHANGED
@@ -1,27 +1,46 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
var plugin_exports = {};
|
19
|
+
__export(plugin_exports, {
|
20
|
+
getInternalPlugins: () => getInternalPlugins
|
21
|
+
});
|
22
|
+
module.exports = __toCommonJS(plugin_exports);
|
23
|
+
var import_constants = require("./constants");
|
24
|
+
var import_is = require("./is");
|
25
|
+
function getInternalPlugins(appDirectory, internalPlugins = import_constants.INTERNAL_CLI_PLUGINS) {
|
26
|
+
return [
|
27
|
+
...Object.keys(internalPlugins).filter((name) => {
|
28
|
+
const config = internalPlugins[name];
|
29
|
+
if (typeof config !== "string" && config.forced === true) {
|
30
|
+
return true;
|
31
|
+
}
|
32
|
+
return (0, import_is.isDepExists)(appDirectory, name);
|
33
|
+
}).map((name) => {
|
34
|
+
const config = internalPlugins[name];
|
35
|
+
if (typeof config !== "string") {
|
36
|
+
return config.path;
|
37
|
+
} else {
|
38
|
+
return config;
|
39
|
+
}
|
40
|
+
})
|
41
|
+
];
|
26
42
|
}
|
27
|
-
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
44
|
+
0 && (module.exports = {
|
45
|
+
getInternalPlugins
|
46
|
+
});
|