@modern-js/plugin-data-loader 3.0.0-alpha.0 → 3.0.0-alpha.2

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.
@@ -27,7 +27,7 @@ __webpack_require__.d(__webpack_exports__, {
27
27
  default: ()=>loader
28
28
  });
29
29
  const external_util_namespaceObject = require("util");
30
- const logger_namespaceObject = require("@modern-js/utils/logger");
30
+ const utils_namespaceObject = require("@modern-js/utils");
31
31
  const external_generateClient_js_namespaceObject = require("./generateClient.js");
32
32
  async function loader(source) {
33
33
  this.cacheable();
@@ -49,7 +49,7 @@ async function loader(source) {
49
49
  const clientDataContent = await readFile(clientDataPath);
50
50
  return clientDataContent;
51
51
  } catch (error) {
52
- if ('development' === process.env.NODE_ENV) logger_namespaceObject.logger.error(`Failed to read the clientData file ${options.clientData}`);
52
+ if ('development' === process.env.NODE_ENV) utils_namespaceObject.logger.error(`Failed to read the clientData file ${options.clientData}`);
53
53
  }
54
54
  }
55
55
  const code = (0, external_generateClient_js_namespaceObject.generateClient)({
@@ -1,7 +1,7 @@
1
1
  import { redirect } from "@modern-js/runtime-utils/router";
2
2
  import { compile } from "path-to-regexp";
3
- import { CONTENT_TYPE_DEFERRED, DIRECT_PARAM, LOADER_ID_PARAM } from "../common/constants";
4
- import { parseDeferredReadableStream } from "./data";
3
+ import { CONTENT_TYPE_DEFERRED, DIRECT_PARAM, LOADER_ID_PARAM } from "../common/constants.mjs";
4
+ import { parseDeferredReadableStream } from "./data.mjs";
5
5
  const getRequestUrl = ({ params, request, routeId })=>{
6
6
  const url = new URL(request.url);
7
7
  const toPath = compile(url.pathname, {
@@ -1,6 +1,6 @@
1
1
  import { promisify } from "util";
2
- import { logger } from "@modern-js/utils/logger";
3
- import { generateClient } from "./generateClient";
2
+ import { logger } from "@modern-js/utils";
3
+ import { generateClient } from "./generateClient.mjs";
4
4
  async function loader(source) {
5
5
  this.cacheable();
6
6
  const target = this._compiler?.options.target;
@@ -6,9 +6,9 @@ import { time } from "@modern-js/runtime-utils/time";
6
6
  import { parseHeaders } from "@modern-js/runtime-utils/universal/request";
7
7
  import { isPlainObject } from "@modern-js/utils/lodash";
8
8
  import { LOADER_REPORTER_NAME } from "@modern-js/utils/universal/constants";
9
- import { CONTENT_TYPE_DEFERRED, LOADER_ID_PARAM } from "../common/constants";
10
- import { errorResponseToJson, serializeError } from "./errors";
11
- import { createDeferredReadableStream } from "./response";
9
+ import { CONTENT_TYPE_DEFERRED, LOADER_ID_PARAM } from "../common/constants.mjs";
10
+ import { errorResponseToJson, serializeError } from "./errors.mjs";
11
+ import { createDeferredReadableStream } from "./response.mjs";
12
12
  const redirectStatusCodes = new Set([
13
13
  301,
14
14
  302,
@@ -1,3 +1,5 @@
1
+ import "node:module";
2
+ /*#__PURE__*/ import.meta.url;
1
3
  import { redirect } from "@modern-js/runtime-utils/router";
2
4
  import { compile } from "path-to-regexp";
3
5
  import { CONTENT_TYPE_DEFERRED, DIRECT_PARAM, LOADER_ID_PARAM } from "../common/constants.mjs";
@@ -1,3 +1,5 @@
1
+ import "node:module";
2
+ /*#__PURE__*/ import.meta.url;
1
3
  import { AbortedDeferredError, DeferredData } from "@modern-js/runtime-utils/browser";
2
4
  const DEFERRED_VALUE_PLACEHOLDER_PREFIX = '__deferred_promise:';
3
5
  async function parseDeferredReadableStream(stream) {
@@ -1,7 +1,12 @@
1
+ import "node:module";
2
+ /*#__PURE__*/ import.meta.url;
3
+ import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
4
+ import { dirname as __rspack_dirname } from "node:path";
1
5
  import path from "path";
6
+ var generateClient_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
2
7
  const generateClient = ({ inline, action, routeId })=>{
3
8
  let requestCode = "";
4
- const requestCreatorPath = path.join(__dirname, './createRequest').replace('/cjs/cli/', '/esm/cli/').replace(/\\/g, '/');
9
+ const requestCreatorPath = path.join(generateClient_dirname, './createRequest').replace('/cjs/cli/', '/esm/cli/').replace(/\\/g, '/');
5
10
  const importCode = `
6
11
  import { createRequest, createActionRequest } from '${requestCreatorPath}';
7
12
  `;
@@ -1,5 +1,7 @@
1
+ import "node:module";
2
+ /*#__PURE__*/ import.meta.url;
1
3
  import { promisify } from "util";
2
- import { logger } from "@modern-js/utils/logger";
4
+ import { logger } from "@modern-js/utils";
3
5
  import { generateClient } from "./generateClient.mjs";
4
6
  async function loader(source) {
5
7
  this.cacheable();
@@ -1,3 +1,5 @@
1
+ import "node:module";
2
+ /*#__PURE__*/ import.meta.url;
1
3
  const LOADER_ID_PARAM = '__loader';
2
4
  const DIRECT_PARAM = '__ssrDirect';
3
5
  const CONTENT_TYPE_DEFERRED = 'text/modernjs-deferred';
@@ -1,3 +1,5 @@
1
+ import "node:module";
2
+ /*#__PURE__*/ import.meta.url;
1
3
  import { isRouteErrorResponse } from "@modern-js/runtime-utils/router";
2
4
  function sanitizeError(error) {
3
5
  if (error instanceof Error && 'development' !== process.env.NODE_ENV && 'test' !== process.env.NODE_ENV) {
@@ -1,3 +1,5 @@
1
+ import "node:module";
2
+ /*#__PURE__*/ import.meta.url;
1
3
  import { transformNestedRoutes } from "@modern-js/runtime-utils/browser";
2
4
  import { createRequestContext, reporterCtx, storage } from "@modern-js/runtime-utils/node";
3
5
  import { DEFERRED_SYMBOL, createStaticHandler, isRouteErrorResponse } from "@modern-js/runtime-utils/router";
@@ -1,3 +1,5 @@
1
+ import "node:module";
2
+ /*#__PURE__*/ import.meta.url;
1
3
  import { TextEncoder } from "util";
2
4
  import { serializeJson } from "@modern-js/runtime-utils/node";
3
5
  function isTrackedPromise(value) {
package/package.json CHANGED
@@ -15,23 +15,19 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "3.0.0-alpha.0",
18
+ "version": "3.0.0-alpha.2",
19
19
  "engines": {
20
20
  "node": ">=20"
21
21
  },
22
- "jsnext:source": "./src/runtime/index.ts",
23
22
  "types": "./dist/types/runtime/index.d.ts",
24
23
  "main": "./dist/cjs/runtime/index.js",
25
- "module": "./dist/esm/runtime/index.mjs",
26
24
  "exports": {
27
25
  "./loader": {
28
26
  "types": "./dist/types/cli/loader.d.ts",
29
- "jsnext:source": "./src/cli/loader.ts",
30
27
  "default": "./dist/cjs/cli/loader.js"
31
28
  },
32
29
  "./runtime": {
33
30
  "types": "./dist/types/runtime/index.d.ts",
34
- "jsnext:source": "./src/runtime/index.ts",
35
31
  "default": "./dist/esm/runtime/index.mjs"
36
32
  }
37
33
  },
@@ -46,28 +42,25 @@
46
42
  }
47
43
  },
48
44
  "dependencies": {
49
- "@babel/core": "^7.28.5",
50
45
  "@swc/helpers": "^0.5.17",
51
46
  "path-to-regexp": "^6.3.0",
52
- "@modern-js/runtime-utils": "3.0.0-alpha.0",
53
- "@modern-js/utils": "3.0.0-alpha.0"
47
+ "@modern-js/runtime-utils": "3.0.0-alpha.2",
48
+ "@modern-js/utils": "3.0.0-alpha.2"
54
49
  },
55
50
  "devDependencies": {
56
- "@rslib/core": "0.18.5",
57
- "@types/babel__core": "^7.20.5",
51
+ "@rsbuild/core": "2.0.0-beta.0",
52
+ "@rslib/core": "0.19.3",
58
53
  "@types/node": "^20",
59
54
  "@types/supertest": "^2.0.16",
60
- "isomorphic-fetch": "^3.0.0",
61
55
  "memfs": "^3.5.3",
62
56
  "react": "^19.2.3",
63
57
  "react-dom": "^19.2.3",
64
58
  "supertest": "^6.3.4",
65
59
  "typescript": "^5",
66
- "@rsbuild/core": "1.6.15",
67
- "@modern-js/types": "3.0.0-alpha.0",
68
- "@scripts/rstest-config": "2.66.0",
60
+ "@modern-js/server-core": "3.0.0-alpha.2",
69
61
  "@modern-js/rslib": "2.68.10",
70
- "@modern-js/server-core": "3.0.0-alpha.0"
62
+ "@scripts/rstest-config": "2.66.0",
63
+ "@modern-js/types": "3.0.0-alpha.2"
71
64
  },
72
65
  "peerDependencies": {
73
66
  "react": ">=17.0.2"