@modern-js/utils 2.22.0 → 2.22.1-alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/FileSizeReporter.d.ts +16 -0
- package/dist/FileSizeReporter.js +162 -0
- package/dist/alias.d.ts +25 -0
- package/dist/alias.js +108 -0
- package/dist/analyzeProject.d.ts +2 -0
- package/dist/analyzeProject.js +71 -0
- package/dist/applyOptionsChain.d.ts +3 -0
- package/dist/applyOptionsChain.js +58 -0
- package/dist/babel.d.ts +3 -0
- package/dist/babel.js +136 -0
- package/dist/chainId.d.ts +244 -0
- package/dist/chainId.js +196 -0
- package/dist/cjs/cli/constants/index.js +4 -0
- package/dist/cjs/runtime-node/walk.js +1 -0
- package/dist/cjs/universal/constants.js +4 -0
- package/dist/clearConsole.d.ts +1 -0
- package/dist/clearConsole.js +31 -0
- package/dist/commands.d.ts +4 -0
- package/dist/commands.js +48 -0
- package/dist/compatRequire.d.ts +13 -0
- package/dist/compatRequire.js +82 -0
- package/dist/compiled.d.ts +43 -0
- package/dist/compiled.js +142 -0
- package/dist/constants.d.ts +244 -0
- package/dist/constants.js +320 -0
- package/dist/debug.d.ts +6 -0
- package/dist/debug.js +28 -0
- package/dist/emptyDir.d.ts +1 -0
- package/dist/emptyDir.js +52 -0
- package/dist/ensureAbsolutePath.d.ts +7 -0
- package/dist/ensureAbsolutePath.js +38 -0
- package/dist/ensureArray.d.ts +1 -0
- package/dist/ensureArray.js +32 -0
- package/dist/esm/cli/constants/index.js +1 -0
- package/dist/esm/runtime-node/walk.js +0 -0
- package/dist/esm/universal/constants.js +1 -0
- package/dist/findExists.d.ts +6 -0
- package/dist/findExists.js +45 -0
- package/dist/generateMetaTags.d.ts +16 -0
- package/dist/generateMetaTags.js +61 -0
- package/dist/getBrowserslist.d.ts +2 -0
- package/dist/getBrowserslist.js +31 -0
- package/dist/getCoreJsVersion.d.ts +1 -0
- package/dist/getCoreJsVersion.js +46 -0
- package/dist/getEntryOptions.d.ts +1 -0
- package/dist/getEntryOptions.js +54 -0
- package/dist/getPackageManager.d.ts +1 -0
- package/dist/getPackageManager.js +87 -0
- package/dist/getPort.d.ts +14 -0
- package/dist/getPort.js +112 -0
- package/dist/getServerConfig.d.ts +1 -0
- package/dist/getServerConfig.js +67 -0
- package/dist/getTargetDir.d.ts +1 -0
- package/dist/getTargetDir.js +41 -0
- package/dist/import.d.ts +5 -0
- package/dist/import.js +33 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +60 -0
- package/dist/is/index.d.ts +58 -0
- package/dist/is/index.js +114 -0
- package/dist/is/nodeEnv.d.ts +8 -0
- package/dist/is/nodeEnv.js +39 -0
- package/dist/is/platform.d.ts +2 -0
- package/dist/is/platform.js +30 -0
- package/dist/is/type.d.ts +8 -0
- package/dist/is/type.js +64 -0
- package/dist/logger.d.ts +65 -0
- package/dist/logger.js +145 -0
- package/dist/monorepo.d.ts +11 -0
- package/dist/monorepo.js +137 -0
- package/dist/nodeEnv.d.ts +3 -0
- package/dist/nodeEnv.js +81 -0
- package/dist/path.d.ts +18 -0
- package/dist/path.js +92 -0
- package/dist/pathSerializer.d.ts +16 -0
- package/dist/pathSerializer.js +76 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +46 -0
- package/dist/prettyInstructions.d.ts +9 -0
- package/dist/prettyInstructions.js +112 -0
- package/dist/printBuildError.d.ts +8 -0
- package/dist/printBuildError.js +57 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +64 -0
- package/dist/readTsConfig.d.ts +2 -0
- package/dist/readTsConfig.js +47 -0
- package/dist/removeSlash.d.ts +3 -0
- package/dist/removeSlash.js +33 -0
- package/dist/resolve.d.ts +13 -0
- package/dist/resolve.js +63 -0
- package/dist/routes.d.ts +2 -0
- package/dist/routes.js +58 -0
- package/dist/runtimeExports.d.ts +4 -0
- package/dist/runtimeExports.js +73 -0
- package/dist/ssr.d.ts +8 -0
- package/dist/ssr.js +30 -0
- package/dist/storage.d.ts +5 -0
- package/dist/storage.js +75 -0
- package/dist/testUtils.d.ts +5 -0
- package/dist/testUtils.js +38 -0
- package/dist/types/cli/constants/index.d.ts +4 -0
- package/dist/types/runtime-node/walk.d.ts +0 -0
- package/dist/types/universal/constants.d.ts +5 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.js +15 -0
- package/dist/universal/constants.d.ts +9 -0
- package/dist/universal/constants.js +30 -0
- package/dist/universal/formatWebpack.d.ts +13 -0
- package/dist/universal/formatWebpack.js +100 -0
- package/dist/universal/nestedRoutes.d.ts +8 -0
- package/dist/universal/nestedRoutes.js +131 -0
- package/dist/universal/remixRouter.d.ts +1 -0
- package/dist/universal/remixRouter.js +17 -0
- package/dist/universal/serialize.d.ts +1 -0
- package/dist/universal/serialize.js +40 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +92 -0
- package/dist/wait.d.ts +2 -0
- package/dist/wait.js +29 -0
- package/dist/watch.d.ts +8 -0
- package/dist/watch.js +90 -0
- package/package.json +12 -3
@@ -0,0 +1,131 @@
|
|
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, lazyImport } = nestedRoute;
|
54
|
+
const Component = component;
|
55
|
+
const { parent, DeferredDataComponent, props = {} } = 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) && lazyImport) {
|
76
|
+
const Loading = parent.loading;
|
77
|
+
if (isLoadableComponent(Component)) {
|
78
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {}) });
|
79
|
+
} else {
|
80
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {}), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}) });
|
81
|
+
}
|
82
|
+
} else if (isLoadableComponent(Component) && lazyImport) {
|
83
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
|
84
|
+
} else if (isRoot) {
|
85
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
86
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, __spreadValues({}, props)),
|
87
|
+
typeof document === "undefined" && DeferredDataComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DeferredDataComponent, {})
|
88
|
+
] });
|
89
|
+
} else if (lazyImport) {
|
90
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}) });
|
91
|
+
} else {
|
92
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
|
93
|
+
}
|
94
|
+
} else {
|
95
|
+
nestedRoute.loading = parent == null ? void 0 : parent.loading;
|
96
|
+
}
|
97
|
+
if (element) {
|
98
|
+
routeProps.element = element;
|
99
|
+
}
|
100
|
+
const childElements = children == null ? void 0 : children.map((childRoute) => {
|
101
|
+
return renderNestedRoute(childRoute, { parent: nestedRoute });
|
102
|
+
});
|
103
|
+
const routeElement = index ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Route, __spreadProps(__spreadValues({}, routeProps), { index: true }), id) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Route, __spreadProps(__spreadValues({}, routeProps), { index: false, children: childElements }), id);
|
104
|
+
return routeElement;
|
105
|
+
};
|
106
|
+
function createLoader(route) {
|
107
|
+
const { loader } = route;
|
108
|
+
if (loader) {
|
109
|
+
return (args) => {
|
110
|
+
if (typeof route.lazyImport === "function") {
|
111
|
+
route.lazyImport();
|
112
|
+
}
|
113
|
+
return loader(args);
|
114
|
+
};
|
115
|
+
} else {
|
116
|
+
return () => {
|
117
|
+
if (typeof route.lazyImport === "function") {
|
118
|
+
route.lazyImport();
|
119
|
+
}
|
120
|
+
return null;
|
121
|
+
};
|
122
|
+
}
|
123
|
+
}
|
124
|
+
function isLoadableComponent(component) {
|
125
|
+
return component && component.displayName === "Loadable" && component.preload && typeof component.preload === "function";
|
126
|
+
}
|
127
|
+
// Annotate the CommonJS export names for ESM import in node:
|
128
|
+
0 && (module.exports = {
|
129
|
+
renderNestedRoute,
|
130
|
+
transformNestedRoutes
|
131
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from '@remix-run/router';
|
@@ -0,0 +1,17 @@
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
15
|
+
var remixRouter_exports = {};
|
16
|
+
module.exports = __toCommonJS(remixRouter_exports);
|
17
|
+
__reExport(remixRouter_exports, require("@remix-run/router"), module.exports);
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const serializeJson: (data: any) => string;
|
@@ -0,0 +1,40 @@
|
|
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 serialize_exports = {};
|
29
|
+
__export(serialize_exports, {
|
30
|
+
serializeJson: () => serializeJson
|
31
|
+
});
|
32
|
+
module.exports = __toCommonJS(serialize_exports);
|
33
|
+
var import_serialize_javascript = __toESM(require("serialize-javascript"));
|
34
|
+
const serializeJson = (data) => {
|
35
|
+
return (0, import_serialize_javascript.default)(data, { isJSON: true });
|
36
|
+
};
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
38
|
+
0 && (module.exports = {
|
39
|
+
serializeJson
|
40
|
+
});
|
package/dist/version.js
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
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 __export = (target, all) => {
|
22
|
+
for (var name in all)
|
23
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
24
|
+
};
|
25
|
+
var __copyProps = (to, from, except, desc) => {
|
26
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
27
|
+
for (let key of __getOwnPropNames(from))
|
28
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
29
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
30
|
+
}
|
31
|
+
return to;
|
32
|
+
};
|
33
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
34
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
35
|
+
// file that has been converted to a CommonJS file using a Babel-
|
36
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
37
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
38
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
39
|
+
mod
|
40
|
+
));
|
41
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
42
|
+
var __async = (__this, __arguments, generator) => {
|
43
|
+
return new Promise((resolve, reject) => {
|
44
|
+
var fulfilled = (value) => {
|
45
|
+
try {
|
46
|
+
step(generator.next(value));
|
47
|
+
} catch (e) {
|
48
|
+
reject(e);
|
49
|
+
}
|
50
|
+
};
|
51
|
+
var rejected = (value) => {
|
52
|
+
try {
|
53
|
+
step(generator.throw(value));
|
54
|
+
} catch (e) {
|
55
|
+
reject(e);
|
56
|
+
}
|
57
|
+
};
|
58
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
59
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
60
|
+
});
|
61
|
+
};
|
62
|
+
var version_exports = {};
|
63
|
+
__export(version_exports, {
|
64
|
+
getPnpmVersion: () => getPnpmVersion,
|
65
|
+
isReact18: () => isReact18
|
66
|
+
});
|
67
|
+
module.exports = __toCommonJS(version_exports);
|
68
|
+
var import_path = __toESM(require("path"));
|
69
|
+
var import_compiled = require("./compiled");
|
70
|
+
function getPnpmVersion() {
|
71
|
+
return __async(this, null, function* () {
|
72
|
+
const { stdout } = yield (0, import_compiled.execa)("pnpm", ["--version"]);
|
73
|
+
return stdout;
|
74
|
+
});
|
75
|
+
}
|
76
|
+
const isReact18 = (cwd) => {
|
77
|
+
const pkgPath = import_path.default.join(cwd, "package.json");
|
78
|
+
if (!import_compiled.fs.existsSync(pkgPath)) {
|
79
|
+
return false;
|
80
|
+
}
|
81
|
+
const pkgInfo = JSON.parse(import_compiled.fs.readFileSync(pkgPath, "utf8"));
|
82
|
+
const deps = __spreadValues(__spreadValues({}, pkgInfo.devDependencies), pkgInfo.dependencies);
|
83
|
+
if (typeof deps.react !== "string") {
|
84
|
+
return false;
|
85
|
+
}
|
86
|
+
return import_compiled.semver.satisfies(import_compiled.semver.minVersion(deps.react), ">=18.0.0");
|
87
|
+
};
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
89
|
+
0 && (module.exports = {
|
90
|
+
getPnpmVersion,
|
91
|
+
isReact18
|
92
|
+
});
|
package/dist/wait.d.ts
ADDED
package/dist/wait.js
ADDED
@@ -0,0 +1,29 @@
|
|
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 wait_exports = {};
|
19
|
+
__export(wait_exports, {
|
20
|
+
wait: () => wait
|
21
|
+
});
|
22
|
+
module.exports = __toCommonJS(wait_exports);
|
23
|
+
const wait = (time = 0) => new Promise((resolve) => {
|
24
|
+
setTimeout(resolve, time);
|
25
|
+
});
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
27
|
+
0 && (module.exports = {
|
28
|
+
wait
|
29
|
+
});
|
package/dist/watch.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
export type WatchChangeTypeValueT = 'add' | 'unlink' | 'change';
|
2
|
+
export declare const WatchChangeType: Record<'ADD' | 'UNLINK' | 'CHANGE', WatchChangeTypeValueT>;
|
3
|
+
type RunTaskType = (option: {
|
4
|
+
changedFilePath: string;
|
5
|
+
changeType: WatchChangeTypeValueT;
|
6
|
+
}) => void | Promise<void>;
|
7
|
+
export declare const watch: (watchDir: string | string[], runTask: RunTaskType, ignored?: string[]) => import("./compiled").FSWatcher;
|
8
|
+
export {};
|
package/dist/watch.js
ADDED
@@ -0,0 +1,90 @@
|
|
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 __async = (__this, __arguments, generator) => {
|
29
|
+
return new Promise((resolve, reject) => {
|
30
|
+
var fulfilled = (value) => {
|
31
|
+
try {
|
32
|
+
step(generator.next(value));
|
33
|
+
} catch (e) {
|
34
|
+
reject(e);
|
35
|
+
}
|
36
|
+
};
|
37
|
+
var rejected = (value) => {
|
38
|
+
try {
|
39
|
+
step(generator.throw(value));
|
40
|
+
} catch (e) {
|
41
|
+
reject(e);
|
42
|
+
}
|
43
|
+
};
|
44
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
46
|
+
});
|
47
|
+
};
|
48
|
+
var watch_exports = {};
|
49
|
+
__export(watch_exports, {
|
50
|
+
WatchChangeType: () => WatchChangeType,
|
51
|
+
watch: () => watch
|
52
|
+
});
|
53
|
+
module.exports = __toCommonJS(watch_exports);
|
54
|
+
var path = __toESM(require("path"));
|
55
|
+
var import_compiled = require("./compiled");
|
56
|
+
const WatchChangeType = {
|
57
|
+
ADD: "add",
|
58
|
+
UNLINK: "unlink",
|
59
|
+
CHANGE: "change"
|
60
|
+
};
|
61
|
+
const watch = (watchDir, runTask, ignored = []) => {
|
62
|
+
let ready = false;
|
63
|
+
const watcher = import_compiled.chokidar.watch(watchDir, {
|
64
|
+
ignored
|
65
|
+
});
|
66
|
+
watcher.on("ready", () => ready = true);
|
67
|
+
watcher.on("change", (filePath) => __async(void 0, null, function* () {
|
68
|
+
const changedFilePath = path.resolve(filePath);
|
69
|
+
yield runTask({ changedFilePath, changeType: WatchChangeType.CHANGE });
|
70
|
+
}));
|
71
|
+
watcher.on("add", (filePath) => __async(void 0, null, function* () {
|
72
|
+
const changedFilePath = path.resolve(filePath);
|
73
|
+
if (ready) {
|
74
|
+
yield runTask({ changedFilePath, changeType: WatchChangeType.ADD });
|
75
|
+
}
|
76
|
+
}));
|
77
|
+
watcher.on("unlink", (filePath) => __async(void 0, null, function* () {
|
78
|
+
const changedFilePath = path.resolve(filePath);
|
79
|
+
yield runTask({ changedFilePath, changeType: WatchChangeType.UNLINK });
|
80
|
+
}));
|
81
|
+
watcher.on("error", (err) => {
|
82
|
+
throw err;
|
83
|
+
});
|
84
|
+
return watcher;
|
85
|
+
};
|
86
|
+
// Annotate the CommonJS export names for ESM import in node:
|
87
|
+
0 && (module.exports = {
|
88
|
+
WatchChangeType,
|
89
|
+
watch
|
90
|
+
});
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.22.
|
18
|
+
"version": "2.22.1-alpha.1",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -36,41 +36,50 @@
|
|
36
36
|
},
|
37
37
|
"./runtime/router": {
|
38
38
|
"types": "./dist/types/runtime/router.d.ts",
|
39
|
+
"require": "./dist/cjs/runtime/router.js",
|
39
40
|
"default": "./dist/esm/runtime/router.js"
|
40
41
|
},
|
41
42
|
"./runtime/remix-router": {
|
42
43
|
"types": "./dist/types/runtime/remixRouter.d.ts",
|
44
|
+
"require": "./dist/cjs/runtime/remixRouter.js",
|
43
45
|
"default": "./dist/esm/runtime/remixRouter.js"
|
44
46
|
},
|
45
47
|
"./runtime/nested-routes": {
|
46
48
|
"types": "./dist/types/runtime/nestedRoutes.d.ts",
|
49
|
+
"require": "./dist/cjs/runtime/nestedRoutes.js",
|
47
50
|
"default": "./dist/esm/runtime/nestedRoutes.js"
|
48
51
|
},
|
49
52
|
"./runtime-browser": {
|
50
53
|
"jsnext:source": "./src/runtime-browser/index.d.ts",
|
54
|
+
"require": "./dist/cjs/runtime-browser/index.js",
|
51
55
|
"default": "./dist/esm/runtime-browser/index.js"
|
52
56
|
},
|
53
57
|
"./runtime-node": {
|
54
58
|
"types": "./dist/types/runtime-node/index.d.ts",
|
59
|
+
"require": "./dist/cjs/runtime-node/index.js",
|
55
60
|
"default": "./dist/esm/runtime-node/index.js"
|
56
61
|
},
|
57
62
|
"./runtime-node/router": {
|
58
63
|
"types": "./dist/types/runtime-node/router.d.ts",
|
64
|
+
"require": "./dist/cjs/runtime-node/router.js",
|
59
65
|
"default": "./dist/esm/runtime-node/router.js"
|
60
66
|
},
|
61
67
|
"./universal/constants": {
|
62
68
|
"types": "./dist/types/universal/constants.d.ts",
|
63
69
|
"import": "./dist/esm/universal/constants.js",
|
70
|
+
"require": "./dist/cjs/universal/constants.js",
|
64
71
|
"default": "./dist/cjs/universal/constants.js"
|
65
72
|
},
|
66
73
|
"./universal/format-webpack": {
|
67
74
|
"types": "./dist/types/universal/format-webpack.d.ts",
|
68
75
|
"import": "./dist/esm/universal/formatWebpack.js",
|
76
|
+
"require": "./dist/cjs/universal/formatWebpack.js",
|
69
77
|
"default": "./dist/cjs/universal/formatWebpack.js"
|
70
78
|
},
|
71
79
|
"./universal/plugin-dag-sort": {
|
72
80
|
"types": "./dist/types/universal/pluginDagSort.d.ts",
|
73
81
|
"import": "./dist/esm/universal/pluginDagSort.js",
|
82
|
+
"require": "./dist/cjs/universal/pluginDagSort.js",
|
74
83
|
"default": "./dist/cjs/universal/pluginDagSort.js"
|
75
84
|
},
|
76
85
|
"./ajv": "./dist/compiled/ajv/index.js",
|
@@ -232,8 +241,8 @@
|
|
232
241
|
"webpack": "^5.82.1",
|
233
242
|
"@types/serialize-javascript": "^5.0.1",
|
234
243
|
"@modern-js/types": "2.22.0",
|
235
|
-
"@scripts/
|
236
|
-
"@scripts/
|
244
|
+
"@scripts/build": "2.22.0",
|
245
|
+
"@scripts/jest-config": "2.22.0"
|
237
246
|
},
|
238
247
|
"sideEffects": false,
|
239
248
|
"scripts": {
|