@modern-js/plugin-express 2.16.0 → 2.17.1

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,25 @@
1
1
  # @modern-js/plugin-express
2
2
 
3
+ ## 2.17.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @modern-js/bff-core@2.17.1
8
+ - @modern-js/bff-runtime@2.17.1
9
+ - @modern-js/types@2.17.1
10
+ - @modern-js/utils@2.17.1
11
+
12
+ ## 2.17.0
13
+
14
+ ### Patch Changes
15
+
16
+ - 3810930: fix: optimize alias for plugin-express & export useBlocker
17
+ fix: 优化 plugin-express 的 alias 的实现 & 导出 useBlocker
18
+ - @modern-js/bff-core@2.17.0
19
+ - @modern-js/bff-runtime@2.17.0
20
+ - @modern-js/types@2.17.0
21
+ - @modern-js/utils@2.17.0
22
+
3
23
  ## 2.16.0
4
24
 
5
25
  ### Patch Changes
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "default", {
8
8
  });
9
9
  const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
10
10
  const _utils = require("@modern-js/utils");
11
- const _bffcore = require("@modern-js/bff-core");
12
11
  function _getRequireWildcardCache(nodeInterop) {
13
12
  if (typeof WeakMap !== "function")
14
13
  return null;
@@ -58,29 +57,16 @@ const _default = () => ({
58
57
  return {
59
58
  config() {
60
59
  const appContext = useAppContext();
61
- const { appDirectory } = appContext;
62
60
  bffExportsUtils = (0, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, "server");
63
- const serverRuntimePath = bffExportsUtils.getPath();
64
- const relativeRuntimePath = (0, _bffcore.getRelativeRuntimePath)(appDirectory, serverRuntimePath);
65
- if (process.env.NODE_ENV === "production") {
66
- return {
67
- source: {
68
- alias: {
69
- "@modern-js/runtime/server": relativeRuntimePath,
70
- "@modern-js/runtime/express": relativeRuntimePath
71
- }
72
- }
73
- };
74
- } else {
75
- return {
76
- source: {
77
- alias: {
78
- "@modern-js/runtime/server": serverRuntimePath,
79
- "@modern-js/runtime/express": serverRuntimePath
80
- }
61
+ const runtimePath = process.env.NODE_ENV === "development" ? require.resolve("@modern-js/plugin-express/runtime") : "@modern-js/plugin-express/runtime";
62
+ return {
63
+ source: {
64
+ alias: {
65
+ "@modern-js/runtime/server": runtimePath,
66
+ "@modern-js/runtime/express": runtimePath
81
67
  }
82
- };
83
- }
68
+ }
69
+ };
84
70
  },
85
71
  collectServerPlugins({ plugins }) {
86
72
  plugins.push({
@@ -1,6 +1,5 @@
1
1
  import * as path from "path";
2
2
  import { createRuntimeExportsUtils } from "@modern-js/utils";
3
- import { getRelativeRuntimePath } from "@modern-js/bff-core";
4
3
  export default function() {
5
4
  return {
6
5
  name: "@modern-js/plugin-express",
@@ -11,29 +10,16 @@ export default function() {
11
10
  return {
12
11
  config: function config() {
13
12
  var appContext = useAppContext();
14
- var appDirectory = appContext.appDirectory;
15
13
  bffExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, "server");
16
- var serverRuntimePath = bffExportsUtils.getPath();
17
- var relativeRuntimePath = getRelativeRuntimePath(appDirectory, serverRuntimePath);
18
- if (process.env.NODE_ENV === "production") {
19
- return {
20
- source: {
21
- alias: {
22
- "@modern-js/runtime/server": relativeRuntimePath,
23
- "@modern-js/runtime/express": relativeRuntimePath
24
- }
25
- }
26
- };
27
- } else {
28
- return {
29
- source: {
30
- alias: {
31
- "@modern-js/runtime/server": serverRuntimePath,
32
- "@modern-js/runtime/express": serverRuntimePath
33
- }
14
+ var runtimePath = process.env.NODE_ENV === "development" ? require.resolve("@modern-js/plugin-express/runtime") : "@modern-js/plugin-express/runtime";
15
+ return {
16
+ source: {
17
+ alias: {
18
+ "@modern-js/runtime/server": runtimePath,
19
+ "@modern-js/runtime/express": runtimePath
34
20
  }
35
- };
36
- }
21
+ }
22
+ };
37
23
  },
38
24
  collectServerPlugins: function collectServerPlugins(param) {
39
25
  var plugins = param.plugins;
@@ -1,6 +1,5 @@
1
1
  import * as path from "path";
2
2
  import { createRuntimeExportsUtils } from "@modern-js/utils";
3
- import { getRelativeRuntimePath } from "@modern-js/bff-core";
4
3
  export default () => ({
5
4
  name: "@modern-js/plugin-express",
6
5
  setup: (api) => {
@@ -10,29 +9,16 @@ export default () => ({
10
9
  return {
11
10
  config() {
12
11
  const appContext = useAppContext();
13
- const { appDirectory } = appContext;
14
12
  bffExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, "server");
15
- const serverRuntimePath = bffExportsUtils.getPath();
16
- const relativeRuntimePath = getRelativeRuntimePath(appDirectory, serverRuntimePath);
17
- if (process.env.NODE_ENV === "production") {
18
- return {
19
- source: {
20
- alias: {
21
- "@modern-js/runtime/server": relativeRuntimePath,
22
- "@modern-js/runtime/express": relativeRuntimePath
23
- }
24
- }
25
- };
26
- } else {
27
- return {
28
- source: {
29
- alias: {
30
- "@modern-js/runtime/server": serverRuntimePath,
31
- "@modern-js/runtime/express": serverRuntimePath
32
- }
13
+ const runtimePath = process.env.NODE_ENV === "development" ? require.resolve("@modern-js/plugin-express/runtime") : "@modern-js/plugin-express/runtime";
14
+ return {
15
+ source: {
16
+ alias: {
17
+ "@modern-js/runtime/server": runtimePath,
18
+ "@modern-js/runtime/express": runtimePath
33
19
  }
34
- };
35
- }
20
+ }
21
+ };
36
22
  },
37
23
  collectServerPlugins({ plugins }) {
38
24
  plugins.push({
@@ -6,6 +6,6 @@ type MaybeAsync<T> = T | Promise<T>;
6
6
  type PipeFunction<T> = (value: T, end: EndFunction) => MaybeAsync<void> | MaybeAsync<T>;
7
7
  export declare const Pipe: <T>(func: PipeFunction<T>) => Operator;
8
8
  export type Pipe = typeof Pipe;
9
- export declare const Middleware: (middleware: (req: Request, res: Response, next: NextFunction) => void) => Operator;
9
+ export declare const Middleware: (middleware: (req: Request, res: Response, next: NextFunction) => void) => Operator<void>;
10
10
  export type Middleware = typeof Middleware;
11
11
  export {};
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.16.0",
18
+ "version": "2.17.1",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/cli/index.d.ts",
21
21
  "main": "./dist/cjs/cli/index.js",
@@ -37,6 +37,9 @@
37
37
  "require": "./dist/cjs/index.js"
38
38
  },
39
39
  "default": "./dist/esm/index.js"
40
+ },
41
+ "./runtime": {
42
+ "default": "./dist/cjs/runtime/index.js"
40
43
  }
41
44
  },
42
45
  "dependencies": {
@@ -46,10 +49,10 @@
46
49
  "formidable": "^1.2.2",
47
50
  "reflect-metadata": "^0.1.13",
48
51
  "type-is": "^1.6.18",
49
- "@modern-js/bff-core": "2.16.0",
50
- "@modern-js/bff-runtime": "2.16.0",
51
- "@modern-js/types": "2.16.0",
52
- "@modern-js/utils": "2.16.0"
52
+ "@modern-js/bff-core": "2.17.1",
53
+ "@modern-js/bff-runtime": "2.17.1",
54
+ "@modern-js/types": "2.17.1",
55
+ "@modern-js/utils": "2.17.1"
53
56
  },
54
57
  "devDependencies": {
55
58
  "@types/cookie-parser": "^1.4.2",
@@ -65,11 +68,11 @@
65
68
  "supertest": "^6.1.6",
66
69
  "typescript": "^4",
67
70
  "zod": "^3.17.3",
68
- "@modern-js/core": "2.16.0",
69
- "@modern-js/app-tools": "2.16.0",
70
- "@modern-js/server-core": "2.16.0",
71
- "@scripts/build": "2.16.0",
72
- "@scripts/jest-config": "2.16.0"
71
+ "@modern-js/core": "2.17.1",
72
+ "@modern-js/app-tools": "2.17.1",
73
+ "@modern-js/server-core": "2.17.1",
74
+ "@scripts/build": "2.17.1",
75
+ "@scripts/jest-config": "2.17.1"
73
76
  },
74
77
  "peerDependencies": {
75
78
  "express": "^4.17.1"