@modern-js/plugin-data-loader 2.22.1 → 2.23.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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # @modern-js/plugin-data-loader
2
2
 
3
+ ## 2.23.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 7e6fb5f: chore: publishConfig add provenance config
8
+
9
+ chore: publishConfig 增加 provenance 配置
10
+
11
+ - a7a7ad7: chore: move some public code to the utils package
12
+ chore: 移动一些公共的代码到 utils 包
13
+ - 6dec7c2: test(utils): reuse the snapshot serializer of vitest config
14
+
15
+ test(utils): 复用 vitest 的 snapshot serializer
16
+
17
+ - e5259fb: fix: absoluteEntryDir should support directory entry
18
+ fix: absoluteEntryDir 应该支持配置目录 entry,这里 document 会使用
19
+ - Updated dependencies [7e6fb5f]
20
+ - Updated dependencies [a7a7ad7]
21
+ - Updated dependencies [6dec7c2]
22
+ - Updated dependencies [c3216b5]
23
+ - @modern-js/utils@2.23.0
24
+
3
25
  ## 2.22.1
4
26
 
5
27
  ### Patch Changes
@@ -18,7 +18,7 @@ _export(exports, {
18
18
  }
19
19
  });
20
20
  const _pathtoregexp = require("path-to-regexp");
21
- const _reactrouterdom = require("react-router-dom");
21
+ const _router = require("@modern-js/utils/runtime/router");
22
22
  const _constants = require("../common/constants");
23
23
  const _data = require("./data");
24
24
  const getRequestUrl = ({ params, request, routeId }) => {
@@ -36,7 +36,7 @@ const handleRedirectResponse = (res) => {
36
36
  const { headers } = res;
37
37
  const location = headers.get("X-Modernjs-Redirect");
38
38
  if (location) {
39
- throw (0, _reactrouterdom.redirect)(location);
39
+ throw (0, _router.redirect)(location);
40
40
  }
41
41
  return res;
42
42
  };
@@ -24,8 +24,8 @@ const _node = require("@remix-run/node");
24
24
  const _remixrouter = require("@modern-js/utils/runtime/remix-router");
25
25
  const _nestedroutes = require("@modern-js/utils/runtime/nested-routes");
26
26
  const _lodash = require("@modern-js/utils/lodash");
27
+ const _runtimenode = require("@modern-js/utils/runtime-node");
27
28
  const _constants = require("../common/constants");
28
- const _utils = require("../common/utils");
29
29
  const _response = require("./response");
30
30
  (0, _node.installGlobals)();
31
31
  const redirectStatusCodes = /* @__PURE__ */ new Set([
@@ -95,7 +95,7 @@ const sendLoaderResponse = async (res, nodeResponse) => {
95
95
  const handleRequest = async ({ context, serverRoutes, routes: routesConfig }) => {
96
96
  const { method, query } = context;
97
97
  const routeId = query[_constants.LOADER_ID_PARAM];
98
- const entry = (0, _utils.matchEntry)(context.path, serverRoutes);
98
+ const entry = (0, _runtimenode.matchEntry)(context.path, serverRoutes);
99
99
  if (!routeId || !entry) {
100
100
  return;
101
101
  }
@@ -13,13 +13,13 @@ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildc
13
13
  const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
14
14
  const _fs = /* @__PURE__ */ _interop_require_default._(require("fs"));
15
15
  const _utils = require("@modern-js/utils");
16
- const _utils1 = require("../common/utils");
16
+ const _runtimenode = require("@modern-js/utils/runtime-node");
17
17
  const _default = () => ({
18
18
  name: "@modern-js/plugin-data-loader",
19
19
  setup: () => ({
20
20
  prepareLoaderHandler({ serverRoutes, distDir }) {
21
21
  return async (context) => {
22
- const entry = (0, _utils1.matchEntry)(context.path, serverRoutes);
22
+ const entry = (0, _runtimenode.matchEntry)(context.path, serverRoutes);
23
23
  if (!entry) {
24
24
  return;
25
25
  }
@@ -1,7 +1,7 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import { compile } from "path-to-regexp";
4
- import { redirect } from "react-router-dom";
4
+ import { redirect } from "@modern-js/utils/runtime/router";
5
5
  import { LOADER_ID_PARAM, DIRECT_PARAM, CONTENT_TYPE_DEFERRED } from "../common/constants";
6
6
  import { parseDeferredReadableStream } from "./data";
7
7
  export var getRequestUrl = function(param) {
@@ -6,8 +6,8 @@ import { installGlobals, writeReadableStreamToWritable, Response as NodeResponse
6
6
  import { createStaticHandler, ErrorResponse, UNSAFE_DEFERRED_SYMBOL as DEFERRED_SYMBOL } from "@modern-js/utils/runtime/remix-router";
7
7
  import { transformNestedRoutes } from "@modern-js/utils/runtime/nested-routes";
8
8
  import { isPlainObject } from "@modern-js/utils/lodash";
9
+ import { matchEntry } from "@modern-js/utils/runtime-node";
9
10
  import { CONTENT_TYPE_DEFERRED, LOADER_ID_PARAM } from "../common/constants";
10
- import { matchEntry } from "../common/utils";
11
11
  import { createDeferredReadableStream } from "./response";
12
12
  installGlobals();
13
13
  var redirectStatusCodes = /* @__PURE__ */ new Set([
@@ -3,7 +3,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import path from "path";
4
4
  import fs from "fs";
5
5
  import { MAIN_ENTRY_NAME, SERVER_BUNDLE_DIRECTORY } from "@modern-js/utils";
6
- import { matchEntry } from "../common/utils";
6
+ import { matchEntry } from "@modern-js/utils/runtime-node";
7
7
  export default function() {
8
8
  return {
9
9
  name: "@modern-js/plugin-data-loader",
@@ -1,5 +1,5 @@
1
1
  import { compile } from "path-to-regexp";
2
- import { redirect } from "react-router-dom";
2
+ import { redirect } from "@modern-js/utils/runtime/router";
3
3
  import { LOADER_ID_PARAM, DIRECT_PARAM, CONTENT_TYPE_DEFERRED } from "../common/constants";
4
4
  import { parseDeferredReadableStream } from "./data";
5
5
  export const getRequestUrl = ({ params, request, routeId }) => {
@@ -2,8 +2,8 @@ import { installGlobals, writeReadableStreamToWritable, Response as NodeResponse
2
2
  import { createStaticHandler, ErrorResponse, UNSAFE_DEFERRED_SYMBOL as DEFERRED_SYMBOL } from "@modern-js/utils/runtime/remix-router";
3
3
  import { transformNestedRoutes } from "@modern-js/utils/runtime/nested-routes";
4
4
  import { isPlainObject } from "@modern-js/utils/lodash";
5
+ import { matchEntry } from "@modern-js/utils/runtime-node";
5
6
  import { CONTENT_TYPE_DEFERRED, LOADER_ID_PARAM } from "../common/constants";
6
- import { matchEntry } from "../common/utils";
7
7
  import { createDeferredReadableStream } from "./response";
8
8
  installGlobals();
9
9
  const redirectStatusCodes = /* @__PURE__ */ new Set([
@@ -1,7 +1,7 @@
1
1
  import path from "path";
2
2
  import fs from "fs";
3
3
  import { MAIN_ENTRY_NAME, SERVER_BUNDLE_DIRECTORY } from "@modern-js/utils";
4
- import { matchEntry } from "../common/utils";
4
+ import { matchEntry } from "@modern-js/utils/runtime-node";
5
5
  export default () => ({
6
6
  name: "@modern-js/plugin-data-loader",
7
7
  setup: () => ({
@@ -1,6 +1,6 @@
1
1
  import type { NestedRoute, ServerRoute } from '@modern-js/types';
2
2
  import { Response as NodeResponse } from '@remix-run/node';
3
- import { ServerContext } from '../common/utils';
3
+ import { ServerContext } from '@modern-js/utils/runtime-node';
4
4
  export declare function isRedirectResponse(status: number): boolean;
5
5
  export declare function isResponse(value: any): value is NodeResponse;
6
6
  export declare const handleRequest: ({
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.22.1",
18
+ "version": "2.23.0",
19
19
  "engines": {
20
20
  "node": ">=14.17.6"
21
21
  },
@@ -57,9 +57,8 @@
57
57
  "@babel/core": "^7.21.8",
58
58
  "@remix-run/node": "^1.12.0",
59
59
  "path-to-regexp": "^6.2.0",
60
- "react-router-dom": "^6.8.1",
61
60
  "@swc/helpers": "0.5.1",
62
- "@modern-js/utils": "2.22.1"
61
+ "@modern-js/utils": "2.23.0"
63
62
  },
64
63
  "devDependencies": {
65
64
  "@types/babel__core": "^7.20.0",
@@ -76,21 +75,20 @@
76
75
  "webpack-chain": "^6.5.1",
77
76
  "react": "^18",
78
77
  "react-dom": "^18",
79
- "react-router-dom": "^6.8.1",
80
- "@modern-js/server-core": "2.22.1",
81
- "@modern-js/core": "2.22.1",
82
- "@modern-js/types": "2.22.1",
83
- "@scripts/build": "2.22.1",
84
- "@scripts/jest-config": "2.22.1"
78
+ "@modern-js/types": "2.23.0",
79
+ "@modern-js/server-core": "2.23.0",
80
+ "@modern-js/core": "2.23.0",
81
+ "@scripts/build": "2.23.0",
82
+ "@scripts/jest-config": "2.23.0"
85
83
  },
86
84
  "peerDependencies": {
87
- "react": ">=17.0.0",
88
- "react-router-dom": "^6.8.1"
85
+ "react": ">=17.0.0"
89
86
  },
90
87
  "sideEffects": false,
91
88
  "publishConfig": {
92
89
  "registry": "https://registry.npmjs.org/",
93
- "access": "public"
90
+ "access": "public",
91
+ "provenance": true
94
92
  },
95
93
  "scripts": {
96
94
  "new": "modern-lib new",
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "matchEntry", {
6
- enumerable: true,
7
- get: function() {
8
- return matchEntry;
9
- }
10
- });
11
- function sortByUrlPath(entries) {
12
- entries.sort(function(a, b) {
13
- const length1 = a.urlPath.length;
14
- const length2 = b.urlPath.length;
15
- if (length1 < length2) {
16
- return 1;
17
- }
18
- if (length1 > length2) {
19
- return -1;
20
- }
21
- return 0;
22
- });
23
- return entries;
24
- }
25
- const matchEntry = (pathname, entries) => {
26
- sortByUrlPath(entries);
27
- return entries.find((entry) => pathname.startsWith(entry.urlPath));
28
- };
@@ -1,20 +0,0 @@
1
- function sortByUrlPath(entries) {
2
- entries.sort(function(a, b) {
3
- var length1 = a.urlPath.length;
4
- var length2 = b.urlPath.length;
5
- if (length1 < length2) {
6
- return 1;
7
- }
8
- if (length1 > length2) {
9
- return -1;
10
- }
11
- return 0;
12
- });
13
- return entries;
14
- }
15
- export var matchEntry = function(pathname, entries) {
16
- sortByUrlPath(entries);
17
- return entries.find(function(entry) {
18
- return pathname.startsWith(entry.urlPath);
19
- });
20
- };
@@ -1,18 +0,0 @@
1
- function sortByUrlPath(entries) {
2
- entries.sort(function(a, b) {
3
- const length1 = a.urlPath.length;
4
- const length2 = b.urlPath.length;
5
- if (length1 < length2) {
6
- return 1;
7
- }
8
- if (length1 > length2) {
9
- return -1;
10
- }
11
- return 0;
12
- });
13
- return entries;
14
- }
15
- export const matchEntry = (pathname, entries) => {
16
- sortByUrlPath(entries);
17
- return entries.find((entry) => pathname.startsWith(entry.urlPath));
18
- };
@@ -1,3 +0,0 @@
1
- import { 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;