@modern-js/utils 2.22.1-alpha.3 → 2.22.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +10 -0
- package/dist/cjs/cli/constants/index.js +0 -4
- package/dist/cjs/cli/prettyInstructions.js +3 -2
- package/dist/cjs/runtime/nestedRoutes.js +3 -1
- package/dist/cjs/runtime-node/index.js +0 -2
- package/dist/cjs/universal/constants.js +0 -4
- package/dist/esm/cli/constants/index.js +0 -1
- package/dist/esm/cli/prettyInstructions.js +3 -2
- package/dist/esm/runtime/nestedRoutes.js +3 -1
- package/dist/esm/runtime-node/index.js +0 -1
- package/dist/esm/universal/constants.js +0 -1
- package/dist/types/cli/constants/index.d.ts +0 -4
- package/dist/types/runtime/nestedRoutes.d.ts +6 -2
- package/dist/types/runtime-node/index.d.ts +1 -2
- package/dist/types/universal/constants.d.ts +1 -5
- package/package.json +4 -13
- package/dist/FileSizeReporter.d.ts +0 -16
- package/dist/FileSizeReporter.js +0 -162
- package/dist/alias.d.ts +0 -25
- package/dist/alias.js +0 -108
- package/dist/analyzeProject.d.ts +0 -2
- package/dist/analyzeProject.js +0 -71
- package/dist/applyOptionsChain.d.ts +0 -3
- package/dist/applyOptionsChain.js +0 -58
- package/dist/babel.d.ts +0 -3
- package/dist/babel.js +0 -136
- package/dist/chainId.d.ts +0 -244
- package/dist/chainId.js +0 -196
- package/dist/cjs/runtime-node/nestedRoutes.js +0 -28
- package/dist/clearConsole.d.ts +0 -1
- package/dist/clearConsole.js +0 -31
- package/dist/commands.d.ts +0 -4
- package/dist/commands.js +0 -48
- package/dist/compatRequire.d.ts +0 -13
- package/dist/compatRequire.js +0 -82
- package/dist/compiled.d.ts +0 -43
- package/dist/compiled.js +0 -142
- package/dist/constants.d.ts +0 -244
- package/dist/constants.js +0 -320
- package/dist/debug.d.ts +0 -6
- package/dist/debug.js +0 -28
- package/dist/emptyDir.d.ts +0 -1
- package/dist/emptyDir.js +0 -52
- package/dist/ensureAbsolutePath.d.ts +0 -7
- package/dist/ensureAbsolutePath.js +0 -38
- package/dist/ensureArray.d.ts +0 -1
- package/dist/ensureArray.js +0 -32
- package/dist/esm/runtime-node/nestedRoutes.js +0 -18
- package/dist/findExists.d.ts +0 -6
- package/dist/findExists.js +0 -45
- package/dist/generateMetaTags.d.ts +0 -16
- package/dist/generateMetaTags.js +0 -61
- package/dist/getBrowserslist.d.ts +0 -2
- package/dist/getBrowserslist.js +0 -31
- package/dist/getCoreJsVersion.d.ts +0 -1
- package/dist/getCoreJsVersion.js +0 -46
- package/dist/getEntryOptions.d.ts +0 -1
- package/dist/getEntryOptions.js +0 -54
- package/dist/getPackageManager.d.ts +0 -1
- package/dist/getPackageManager.js +0 -87
- package/dist/getPort.d.ts +0 -14
- package/dist/getPort.js +0 -112
- package/dist/getServerConfig.d.ts +0 -1
- package/dist/getServerConfig.js +0 -67
- package/dist/getTargetDir.d.ts +0 -1
- package/dist/getTargetDir.js +0 -41
- package/dist/import.d.ts +0 -5
- package/dist/import.js +0 -33
- package/dist/index.d.ts +0 -44
- package/dist/index.js +0 -60
- package/dist/is/index.d.ts +0 -58
- package/dist/is/index.js +0 -114
- package/dist/is/nodeEnv.d.ts +0 -8
- package/dist/is/nodeEnv.js +0 -39
- package/dist/is/platform.d.ts +0 -2
- package/dist/is/platform.js +0 -30
- package/dist/is/type.d.ts +0 -8
- package/dist/is/type.js +0 -64
- package/dist/logger.d.ts +0 -65
- package/dist/logger.js +0 -145
- package/dist/monorepo.d.ts +0 -11
- package/dist/monorepo.js +0 -137
- package/dist/nodeEnv.d.ts +0 -3
- package/dist/nodeEnv.js +0 -81
- package/dist/path.d.ts +0 -18
- package/dist/path.js +0 -92
- package/dist/pathSerializer.d.ts +0 -16
- package/dist/pathSerializer.js +0 -76
- package/dist/plugin.d.ts +0 -2
- package/dist/plugin.js +0 -46
- package/dist/prettyInstructions.d.ts +0 -9
- package/dist/prettyInstructions.js +0 -112
- package/dist/printBuildError.d.ts +0 -8
- package/dist/printBuildError.js +0 -57
- package/dist/react.d.ts +0 -1
- package/dist/react.js +0 -64
- package/dist/readTsConfig.d.ts +0 -2
- package/dist/readTsConfig.js +0 -47
- package/dist/removeSlash.d.ts +0 -3
- package/dist/removeSlash.js +0 -33
- package/dist/resolve.d.ts +0 -13
- package/dist/resolve.js +0 -63
- package/dist/routes.d.ts +0 -2
- package/dist/routes.js +0 -58
- package/dist/runtimeExports.d.ts +0 -4
- package/dist/runtimeExports.js +0 -73
- package/dist/ssr.d.ts +0 -8
- package/dist/ssr.js +0 -30
- package/dist/storage.d.ts +0 -5
- package/dist/storage.js +0 -75
- package/dist/testUtils.d.ts +0 -5
- package/dist/testUtils.js +0 -38
- package/dist/types/runtime-node/nestedRoutes.d.ts +0 -3
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -15
- package/dist/universal/constants.d.ts +0 -9
- package/dist/universal/constants.js +0 -30
- package/dist/universal/formatWebpack.d.ts +0 -13
- package/dist/universal/formatWebpack.js +0 -100
- package/dist/universal/nestedRoutes.d.ts +0 -8
- package/dist/universal/nestedRoutes.js +0 -131
- package/dist/universal/remixRouter.d.ts +0 -1
- package/dist/universal/remixRouter.js +0 -17
- package/dist/universal/serialize.d.ts +0 -1
- package/dist/universal/serialize.js +0 -40
- package/dist/version.d.ts +0 -2
- package/dist/version.js +0 -92
- package/dist/wait.d.ts +0 -2
- package/dist/wait.js +0 -29
- package/dist/watch.d.ts +0 -8
- package/dist/watch.js +0 -90
package/dist/removeSlash.js
DELETED
@@ -1,33 +0,0 @@
|
|
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 removeSlash_exports = {};
|
19
|
-
__export(removeSlash_exports, {
|
20
|
-
removeLeadingSlash: () => removeLeadingSlash,
|
21
|
-
removeSlash: () => removeSlash,
|
22
|
-
removeTailSlash: () => removeTailSlash
|
23
|
-
});
|
24
|
-
module.exports = __toCommonJS(removeSlash_exports);
|
25
|
-
const removeLeadingSlash = (s) => s.replace(/^\/+/, "");
|
26
|
-
const removeTailSlash = (s) => s.replace(/\/+$/, "");
|
27
|
-
const removeSlash = (s) => removeLeadingSlash(removeTailSlash(s));
|
28
|
-
// Annotate the CommonJS export names for ESM import in node:
|
29
|
-
0 && (module.exports = {
|
30
|
-
removeLeadingSlash,
|
31
|
-
removeSlash,
|
32
|
-
removeTailSlash
|
33
|
-
});
|
package/dist/resolve.d.ts
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Try to resolve npm package entry file path.
|
3
|
-
* @param name - Package name.
|
4
|
-
* @param resolvePath - Path to resolve dependencies.
|
5
|
-
* @returns Resolved file path.
|
6
|
-
*/
|
7
|
-
export declare const tryResolve: (name: string, resolvePath: string) => string;
|
8
|
-
/**
|
9
|
-
* Try to resolve npm package, return true if package is installed.
|
10
|
-
*/
|
11
|
-
|
12
|
-
export declare const isPackageInstalled: (name: string, resolvePaths: string | string[]) => boolean;
|
13
|
-
export declare const getAntdMajorVersion: (appDirectory: string) => number | null;
|
package/dist/resolve.js
DELETED
@@ -1,63 +0,0 @@
|
|
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 resolve_exports = {};
|
19
|
-
__export(resolve_exports, {
|
20
|
-
getAntdMajorVersion: () => getAntdMajorVersion,
|
21
|
-
isPackageInstalled: () => isPackageInstalled,
|
22
|
-
tryResolve: () => tryResolve
|
23
|
-
});
|
24
|
-
module.exports = __toCommonJS(resolve_exports);
|
25
|
-
var import_ensureArray = require("./ensureArray");
|
26
|
-
const tryResolve = (name, resolvePath) => {
|
27
|
-
let filePath = "";
|
28
|
-
try {
|
29
|
-
filePath = require.resolve(name, { paths: [resolvePath] });
|
30
|
-
delete require.cache[filePath];
|
31
|
-
} catch (err) {
|
32
|
-
if (err.code === "MODULE_NOT_FOUND") {
|
33
|
-
throw new Error(`Can not find module ${name}.`);
|
34
|
-
}
|
35
|
-
throw err;
|
36
|
-
}
|
37
|
-
return filePath;
|
38
|
-
};
|
39
|
-
const isPackageInstalled = (name, resolvePaths) => {
|
40
|
-
try {
|
41
|
-
require.resolve(name, { paths: (0, import_ensureArray.ensureArray)(resolvePaths) });
|
42
|
-
return true;
|
43
|
-
} catch (err) {
|
44
|
-
return false;
|
45
|
-
}
|
46
|
-
};
|
47
|
-
const getAntdMajorVersion = (appDirectory) => {
|
48
|
-
try {
|
49
|
-
const pkgJsonPath = require.resolve("antd/package.json", {
|
50
|
-
paths: [appDirectory]
|
51
|
-
});
|
52
|
-
const { version } = require(pkgJsonPath);
|
53
|
-
return Number(version.split(".")[0]);
|
54
|
-
} catch (err) {
|
55
|
-
return null;
|
56
|
-
}
|
57
|
-
};
|
58
|
-
// Annotate the CommonJS export names for ESM import in node:
|
59
|
-
0 && (module.exports = {
|
60
|
-
getAntdMajorVersion,
|
61
|
-
isPackageInstalled,
|
62
|
-
tryResolve
|
63
|
-
});
|
package/dist/routes.d.ts
DELETED
package/dist/routes.js
DELETED
@@ -1,58 +0,0 @@
|
|
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 });
|
10
|
-
};
|
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
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
25
|
-
mod
|
26
|
-
));
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
var routes_exports = {};
|
29
|
-
__export(routes_exports, {
|
30
|
-
getPathWithoutExt: () => getPathWithoutExt,
|
31
|
-
getRouteId: () => getRouteId
|
32
|
-
});
|
33
|
-
module.exports = __toCommonJS(routes_exports);
|
34
|
-
var import_path = __toESM(require("path"));
|
35
|
-
var import_path2 = require("./path");
|
36
|
-
var import_constants = require("./constants");
|
37
|
-
const getPathWithoutExt = (filename) => {
|
38
|
-
const extname = import_path.default.extname(filename);
|
39
|
-
return filename.slice(0, -extname.length);
|
40
|
-
};
|
41
|
-
const getRouteId = (componentPath, routesDir, entryName) => {
|
42
|
-
const relativePath = (0, import_path2.normalizeToPosixPath)(
|
43
|
-
import_path.default.relative(routesDir, componentPath)
|
44
|
-
);
|
45
|
-
const pathWithoutExt = getPathWithoutExt(relativePath);
|
46
|
-
let id = ``;
|
47
|
-
if (entryName === import_constants.MAIN_ENTRY_NAME) {
|
48
|
-
id = pathWithoutExt;
|
49
|
-
} else {
|
50
|
-
id = `${entryName}_${pathWithoutExt}`;
|
51
|
-
}
|
52
|
-
return id;
|
53
|
-
};
|
54
|
-
// Annotate the CommonJS export names for ESM import in node:
|
55
|
-
0 && (module.exports = {
|
56
|
-
getPathWithoutExt,
|
57
|
-
getRouteId
|
58
|
-
});
|
package/dist/runtimeExports.d.ts
DELETED
package/dist/runtimeExports.js
DELETED
@@ -1,73 +0,0 @@
|
|
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 });
|
10
|
-
};
|
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
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
25
|
-
mod
|
26
|
-
));
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
var runtimeExports_exports = {};
|
29
|
-
__export(runtimeExports_exports, {
|
30
|
-
createRuntimeExportsUtils: () => createRuntimeExportsUtils
|
31
|
-
});
|
32
|
-
module.exports = __toCommonJS(runtimeExports_exports);
|
33
|
-
var import_path = __toESM(require("path"));
|
34
|
-
var import_compiled = require("./compiled");
|
35
|
-
var import_path2 = require("./path");
|
36
|
-
const memo = (fn) => {
|
37
|
-
const cache = /* @__PURE__ */ new Map();
|
38
|
-
return (...params) => {
|
39
|
-
const stringifiedParams = JSON.stringify(params);
|
40
|
-
const cachedResult = cache.get(stringifiedParams);
|
41
|
-
if (cachedResult) {
|
42
|
-
return cachedResult;
|
43
|
-
}
|
44
|
-
const res = fn(...params);
|
45
|
-
cache.set(stringifiedParams, res);
|
46
|
-
return res;
|
47
|
-
};
|
48
|
-
};
|
49
|
-
const createRuntimeExportsUtils = memo(
|
50
|
-
(pwd = "", namespace = "index") => {
|
51
|
-
const entryExportFile = import_path.default.join(pwd, `.runtime-exports/${namespace}.js`);
|
52
|
-
const addExport = (statement) => {
|
53
|
-
statement = (0, import_path2.normalizeOutputPath)(statement);
|
54
|
-
try {
|
55
|
-
import_compiled.fs.ensureFileSync(entryExportFile);
|
56
|
-
if (!import_compiled.fs.readFileSync(entryExportFile, "utf8").includes(statement)) {
|
57
|
-
import_compiled.fs.appendFileSync(entryExportFile, `${statement}
|
58
|
-
`);
|
59
|
-
}
|
60
|
-
} catch (e) {
|
61
|
-
}
|
62
|
-
};
|
63
|
-
const getPath = () => entryExportFile;
|
64
|
-
return {
|
65
|
-
addExport,
|
66
|
-
getPath
|
67
|
-
};
|
68
|
-
}
|
69
|
-
);
|
70
|
-
// Annotate the CommonJS export names for ESM import in node:
|
71
|
-
0 && (module.exports = {
|
72
|
-
createRuntimeExportsUtils
|
73
|
-
});
|
package/dist/ssr.d.ts
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
|
3
|
-
/**
|
4
|
-
* ssr helpers
|
5
|
-
*/
|
6
|
-
import type { IncomingHttpHeaders } from 'http';
|
7
|
-
declare const run: <O>(context: IncomingHttpHeaders, cb: () => O | Promise<O>) => Promise<O>, useHeaders: () => IncomingHttpHeaders;
|
8
|
-
export { run, useHeaders };
|
package/dist/ssr.js
DELETED
@@ -1,30 +0,0 @@
|
|
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 ssr_exports = {};
|
19
|
-
__export(ssr_exports, {
|
20
|
-
run: () => run,
|
21
|
-
useHeaders: () => useHeaders
|
22
|
-
});
|
23
|
-
module.exports = __toCommonJS(ssr_exports);
|
24
|
-
var import_storage = require("./storage");
|
25
|
-
const { run, useContext: useHeaders } = (0, import_storage.createStorage)();
|
26
|
-
// Annotate the CommonJS export names for ESM import in node:
|
27
|
-
0 && (module.exports = {
|
28
|
-
run,
|
29
|
-
useHeaders
|
30
|
-
});
|
package/dist/storage.d.ts
DELETED
package/dist/storage.js
DELETED
@@ -1,75 +0,0 @@
|
|
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 });
|
10
|
-
};
|
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
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
25
|
-
mod
|
26
|
-
));
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
var storage_exports = {};
|
29
|
-
__export(storage_exports, {
|
30
|
-
createStorage: () => createStorage
|
31
|
-
});
|
32
|
-
module.exports = __toCommonJS(storage_exports);
|
33
|
-
var ah = __toESM(require("async_hooks"));
|
34
|
-
const createStorage = () => {
|
35
|
-
let storage;
|
36
|
-
if (typeof ah.AsyncLocalStorage !== "undefined") {
|
37
|
-
storage = new ah.AsyncLocalStorage();
|
38
|
-
}
|
39
|
-
const run = (context, cb) => {
|
40
|
-
if (!storage) {
|
41
|
-
throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
42
|
-
`);
|
43
|
-
}
|
44
|
-
return new Promise((resolve, reject) => {
|
45
|
-
storage.run(context, () => {
|
46
|
-
try {
|
47
|
-
return resolve(cb());
|
48
|
-
} catch (error) {
|
49
|
-
return reject(error);
|
50
|
-
}
|
51
|
-
});
|
52
|
-
});
|
53
|
-
};
|
54
|
-
const useContext = () => {
|
55
|
-
if (!storage) {
|
56
|
-
throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
57
|
-
`);
|
58
|
-
}
|
59
|
-
const context = storage.getStore();
|
60
|
-
if (!context) {
|
61
|
-
throw new Error(
|
62
|
-
`Can't call useContext out of scope, make sure @modern-js/utils is a single version in node_modules`
|
63
|
-
);
|
64
|
-
}
|
65
|
-
return context;
|
66
|
-
};
|
67
|
-
return {
|
68
|
-
run,
|
69
|
-
useContext
|
70
|
-
};
|
71
|
-
};
|
72
|
-
// Annotate the CommonJS export names for ESM import in node:
|
73
|
-
0 && (module.exports = {
|
74
|
-
createStorage
|
75
|
-
});
|
package/dist/testUtils.d.ts
DELETED
package/dist/testUtils.js
DELETED
@@ -1,38 +0,0 @@
|
|
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 testUtils_exports = {};
|
19
|
-
__export(testUtils_exports, {
|
20
|
-
initSnapshotSerializer: () => initSnapshotSerializer
|
21
|
-
});
|
22
|
-
module.exports = __toCommonJS(testUtils_exports);
|
23
|
-
const initSnapshotSerializer = (root) => {
|
24
|
-
expect.addSnapshotSerializer({
|
25
|
-
test: (val) => typeof val === "string" && (val.includes("modern.js") || val.includes("node_modules") || val.includes(root)),
|
26
|
-
print: (val) => (
|
27
|
-
// eslint-disable-next-line no-nested-ternary
|
28
|
-
typeof val === "string" ? (
|
29
|
-
// eslint-disable-next-line no-nested-ternary
|
30
|
-
val.includes("node_modules") ? `"${val.replace(/.+node_modules/, ``).replace(/\\/g, "/")}"` : val.includes("modern.js") ? `"${val.replace(/.+modern\.js/, ``).replace(/\\/g, "/")}"` : `"${val.replace(root, "").replace(/\\/g, "/")}"`
|
31
|
-
) : val
|
32
|
-
)
|
33
|
-
});
|
34
|
-
};
|
35
|
-
// Annotate the CommonJS export names for ESM import in node:
|
36
|
-
0 && (module.exports = {
|
37
|
-
initSnapshotSerializer
|
38
|
-
});
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import type { ModernServerContext, ServerRoute } from '@modern-js/types';
|
2
|
-
export type ServerContext = Pick<ModernServerContext, 'logger' | 'req' | 'res' | 'params' | 'headers' | 'method' | 'url' | 'host' | 'protocol' | 'origin' | 'href' | 'path' | 'query'>;
|
3
|
-
export declare const matchEntry: (pathname: string, entries: ServerRoute[]) => ServerRoute | undefined;
|
package/dist/types.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export type Falsy = false | null | undefined | 0 | '';
|
package/dist/types.js
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
var __defProp = Object.defineProperty;
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
6
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
7
|
-
for (let key of __getOwnPropNames(from))
|
8
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
9
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
10
|
-
}
|
11
|
-
return to;
|
12
|
-
};
|
13
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
14
|
-
var types_exports = {};
|
15
|
-
module.exports = __toCommonJS(types_exports);
|
@@ -1,30 +0,0 @@
|
|
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 constants_exports = {};
|
19
|
-
__export(constants_exports, {
|
20
|
-
HMR_SOCK_PATH: () => HMR_SOCK_PATH,
|
21
|
-
ROUTE_MANIFEST: () => ROUTE_MANIFEST
|
22
|
-
});
|
23
|
-
module.exports = __toCommonJS(constants_exports);
|
24
|
-
const ROUTE_MANIFEST = `_MODERNJS_ROUTE_MANIFEST`;
|
25
|
-
const HMR_SOCK_PATH = "/webpack-hmr";
|
26
|
-
// Annotate the CommonJS export names for ESM import in node:
|
27
|
-
0 && (module.exports = {
|
28
|
-
HMR_SOCK_PATH,
|
29
|
-
ROUTE_MANIFEST
|
30
|
-
});
|
@@ -1,13 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2015-present, Facebook, Inc.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file at
|
6
|
-
* https://github.com/facebook/create-react-app/blob/master/LICENSE
|
7
|
-
*/
|
8
|
-
import type { StatsCompilation } from 'webpack';
|
9
|
-
declare function formatWebpackMessages(json?: Pick<StatsCompilation, 'errors' | 'warnings'>): {
|
10
|
-
errors: string[];
|
11
|
-
warnings: string[];
|
12
|
-
};
|
13
|
-
export { formatWebpackMessages };
|
@@ -1,100 +0,0 @@
|
|
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 formatWebpack_exports = {};
|
19
|
-
__export(formatWebpack_exports, {
|
20
|
-
formatWebpackMessages: () => formatWebpackMessages
|
21
|
-
});
|
22
|
-
module.exports = __toCommonJS(formatWebpack_exports);
|
23
|
-
const friendlySyntaxErrorLabel = "SyntaxError:";
|
24
|
-
function isLikelyASyntaxError(message) {
|
25
|
-
return message.includes(friendlySyntaxErrorLabel);
|
26
|
-
}
|
27
|
-
function formatMessage(stats) {
|
28
|
-
let lines = [];
|
29
|
-
let message;
|
30
|
-
if (typeof stats === "object") {
|
31
|
-
const fileName = stats.moduleName ? `File: ${stats.moduleName}
|
32
|
-
` : "";
|
33
|
-
const mainMessage = typeof stats.formatted === "string" ? stats.formatted : stats.message;
|
34
|
-
const details = stats.details ? `
|
35
|
-
Details: ${stats.details}
|
36
|
-
` : "";
|
37
|
-
const stack = stats.stack ? `
|
38
|
-
${stats.stack}` : "";
|
39
|
-
message = `${fileName}${mainMessage}${details}${stack}`;
|
40
|
-
} else {
|
41
|
-
message = stats;
|
42
|
-
}
|
43
|
-
lines = message.split("\n");
|
44
|
-
lines = lines.map((line) => {
|
45
|
-
const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(
|
46
|
-
line
|
47
|
-
);
|
48
|
-
if (!parsingError) {
|
49
|
-
return line;
|
50
|
-
}
|
51
|
-
const [, errorLine, errorColumn, errorMessage] = parsingError;
|
52
|
-
return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
|
53
|
-
});
|
54
|
-
message = lines.join("\n");
|
55
|
-
message = message.replace(
|
56
|
-
/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g,
|
57
|
-
`${friendlySyntaxErrorLabel} $3 ($1:$2)
|
58
|
-
`
|
59
|
-
);
|
60
|
-
lines = message.split("\n");
|
61
|
-
if (lines.length > 2 && lines[1].trim() === "") {
|
62
|
-
lines.splice(1, 1);
|
63
|
-
}
|
64
|
-
lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
|
65
|
-
if (lines[1] && lines[1].indexOf("Module not found:") !== -1) {
|
66
|
-
lines[1] = lines[1].replace("Error: ", "");
|
67
|
-
}
|
68
|
-
message = lines.join("\n");
|
69
|
-
message = message.replace(
|
70
|
-
/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
|
71
|
-
""
|
72
|
-
);
|
73
|
-
message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, "");
|
74
|
-
lines = message.split("\n");
|
75
|
-
lines = lines.filter(
|
76
|
-
(line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim()
|
77
|
-
);
|
78
|
-
message = lines.join("\n");
|
79
|
-
return message.trim();
|
80
|
-
}
|
81
|
-
function formatWebpackMessages(json) {
|
82
|
-
var _a, _b, _c;
|
83
|
-
const formattedErrors = (_a = json == null ? void 0 : json.errors) == null ? void 0 : _a.map(formatMessage);
|
84
|
-
const formattedWarnings = (_b = json == null ? void 0 : json.warnings) == null ? void 0 : _b.map(formatMessage);
|
85
|
-
const result = {
|
86
|
-
errors: formattedErrors || [],
|
87
|
-
warnings: formattedWarnings || []
|
88
|
-
};
|
89
|
-
if ((_c = result.errors) == null ? void 0 : _c.some(isLikelyASyntaxError)) {
|
90
|
-
result.errors = result.errors.filter(isLikelyASyntaxError);
|
91
|
-
}
|
92
|
-
if (result.errors.length > 1) {
|
93
|
-
result.errors.length = 1;
|
94
|
-
}
|
95
|
-
return result;
|
96
|
-
}
|
97
|
-
// Annotate the CommonJS export names for ESM import in node:
|
98
|
-
0 && (module.exports = {
|
99
|
-
formatWebpackMessages
|
100
|
-
});
|
@@ -1,8 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
import type { NestedRoute } from '@modern-js/types';
|
3
|
-
export declare const transformNestedRoutes: (routes: NestedRoute[]) => import("react-router-dom").RouteObject[];
|
4
|
-
export declare const renderNestedRoute: (nestedRoute: NestedRoute, options?: {
|
5
|
-
parent?: NestedRoute;
|
6
|
-
DeferredDataComponent?: () => JSX.Element | null;
|
7
|
-
props?: Record<string, any>;
|
8
|
-
}) => JSX.Element;
|