@modern-js/plugin-express 1.3.1 → 1.4.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # @modern-js/plugin-express
2
2
 
3
+ ## 1.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - ef7b0a54: feat: convert to new plugin
8
+ - Updated dependencies [5bf5868d]
9
+ - Updated dependencies [d95f28c3]
10
+ - Updated dependencies [2e8dec93]
11
+ - Updated dependencies [2008fdbd]
12
+ - Updated dependencies [2e8dec93]
13
+ - @modern-js/utils@1.3.5
14
+ - @modern-js/server-core@1.2.3
15
+
16
+ ## 1.4.1
17
+
18
+ ### Patch Changes
19
+
20
+ - 3eee457b: fix: move some peerDependencies to dependecies
21
+ - Updated dependencies [cc5e8001]
22
+ - Updated dependencies [2520ea86]
23
+ - Updated dependencies [db43dce6]
24
+ - Updated dependencies [e81fd9b7]
25
+ - Updated dependencies [1c411e71]
26
+ - @modern-js/core@1.4.6
27
+ - @modern-js/utils@1.3.4
28
+
29
+ ## 1.4.0
30
+
31
+ ### Minor Changes
32
+
33
+ - ec4dbffb: feat: support as a pure api service
34
+
35
+ ### Patch Changes
36
+
37
+ - 272cab15: refactor server plugin manager
38
+ - Updated dependencies [d9cc5ea9]
39
+ - Updated dependencies [bd819a8d]
40
+ - Updated dependencies [ec4dbffb]
41
+ - Updated dependencies [d099e5c5]
42
+ - Updated dependencies [bada2879]
43
+ - Updated dependencies [24f616ca]
44
+ - Updated dependencies [bd819a8d]
45
+ - Updated dependencies [272cab15]
46
+ - @modern-js/core@1.4.0
47
+ - @modern-js/utils@1.3.0
48
+ - @modern-js/server-core@1.2.2
49
+
3
50
  ## 1.3.1
4
51
 
5
52
  ### Patch Changes
@@ -1,50 +1,54 @@
1
1
  import * as path from 'path';
2
- import { useAppContext, createPlugin } from '@modern-js/core';
3
2
  import { createRuntimeExportsUtils } from '@modern-js/utils';
4
- export default createPlugin(() => {
5
- let bffExportsUtils;
6
- const runtimeModulePath = path.resolve(__dirname, '../runtime');
7
- return {
8
- config() {
9
- // eslint-disable-next-line react-hooks/rules-of-hooks
10
- const appContext = useAppContext();
11
- const {
12
- appDirectory
13
- } = appContext;
14
- bffExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, 'server');
15
- const serverRuntimePath = bffExportsUtils.getPath(); // Look up one level, because the artifacts after build have dist directories
3
+ export default (() => ({
4
+ name: '@modern-js/plugin-express',
5
+ setup: api => {
6
+ let bffExportsUtils;
7
+ const {
8
+ useAppContext
9
+ } = api;
10
+ const runtimeModulePath = path.resolve(__dirname, '../runtime');
11
+ return {
12
+ config() {
13
+ // eslint-disable-next-line react-hooks/rules-of-hooks
14
+ const appContext = useAppContext();
15
+ const {
16
+ appDirectory
17
+ } = appContext;
18
+ bffExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, 'server');
19
+ const serverRuntimePath = bffExportsUtils.getPath(); // Look up one level, because the artifacts after build have dist directories
16
20
 
17
- let relativeRuntimePath = path.join('../', path.relative(appDirectory, serverRuntimePath));
21
+ let relativeRuntimePath = path.join('../', path.relative(appDirectory, serverRuntimePath));
18
22
 
19
- if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
20
- relativeRuntimePath = `./${path.relative(appDirectory, serverRuntimePath)}`;
21
- }
23
+ if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
24
+ relativeRuntimePath = `./${path.relative(appDirectory, serverRuntimePath)}`;
25
+ }
22
26
 
23
- return {
24
- source: {
25
- alias: {
26
- '@modern-js/runtime/server': relativeRuntimePath
27
+ return {
28
+ source: {
29
+ alias: {
30
+ '@modern-js/runtime/server': relativeRuntimePath
31
+ }
27
32
  }
28
- }
29
- };
30
- },
33
+ };
34
+ },
31
35
 
32
- modifyEntryImports(input) {
33
- // eslint-disable-next-line react-hooks/rules-of-hooks
34
- const {
35
- appDirectory
36
- } = useAppContext();
36
+ addRuntimeExports(input) {
37
+ // eslint-disable-next-line react-hooks/rules-of-hooks
38
+ const {
39
+ appDirectory
40
+ } = useAppContext();
37
41
 
38
- const runtimePath = require.resolve(`@modern-js/runtime`, {
39
- paths: [appDirectory]
40
- });
42
+ const runtimePath = require.resolve(`@modern-js/runtime`, {
43
+ paths: [appDirectory]
44
+ });
41
45
 
42
- const currentFile = bffExportsUtils.getPath();
43
- const runtimeDir = path.dirname(runtimePath);
44
- const relativeBffPath = path.relative(path.dirname(currentFile), path.join(runtimeDir, './exports/server'));
45
- const relativeRuntimeModulePath = path.relative(path.dirname(currentFile), runtimeModulePath);
46
- const relativeFramePath = path.relative(path.dirname(currentFile), require.resolve('express'));
47
- bffExportsUtils.addExport(`const bffRuntime = require('${relativeBffPath}');
46
+ const currentFile = bffExportsUtils.getPath();
47
+ const runtimeDir = path.dirname(runtimePath);
48
+ const relativeBffPath = path.relative(path.dirname(currentFile), path.join(runtimeDir, './exports/server'));
49
+ const relativeRuntimeModulePath = path.relative(path.dirname(currentFile), runtimeModulePath);
50
+ const relativeFramePath = path.relative(path.dirname(currentFile), require.resolve('express'));
51
+ bffExportsUtils.addExport(`const bffRuntime = require('${relativeBffPath}');
48
52
  const pluginRuntime = require('${relativeRuntimeModulePath}');
49
53
  const express = require('${relativeFramePath}')
50
54
  module.exports = {
@@ -53,10 +57,9 @@ export default createPlugin(() => {
53
57
  ...pluginRuntime
54
58
  }
55
59
  `);
56
- return input;
57
- }
60
+ return input;
61
+ }
58
62
 
59
- };
60
- }, {
61
- name: '@modern-js/plugin-express'
62
- });
63
+ };
64
+ }
65
+ }));
@@ -1,7 +1,7 @@
1
1
  import * as path from 'path';
2
2
  import express from 'express';
3
3
  import cookieParser from 'cookie-parser';
4
- import { createPlugin } from '@modern-js/server-plugin';
4
+ import { createPlugin } from '@modern-js/server-core';
5
5
  import { requireModule } from '@modern-js/bff-utils';
6
6
  import { fs, createDebugger } from '@modern-js/utils';
7
7
  import finalhandler from 'finalhandler';
@@ -7,58 +7,61 @@ exports.default = void 0;
7
7
 
8
8
  var path = _interopRequireWildcard(require("path"));
9
9
 
10
- var _core = require("@modern-js/core");
11
-
12
10
  var _utils = require("@modern-js/utils");
13
11
 
14
12
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
13
 
16
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
15
 
18
- var _default = (0, _core.createPlugin)(() => {
19
- let bffExportsUtils;
20
- const runtimeModulePath = path.resolve(__dirname, '../runtime');
21
- return {
22
- config() {
23
- // eslint-disable-next-line react-hooks/rules-of-hooks
24
- const appContext = (0, _core.useAppContext)();
25
- const {
26
- appDirectory
27
- } = appContext;
28
- bffExportsUtils = (0, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, 'server');
29
- const serverRuntimePath = bffExportsUtils.getPath(); // Look up one level, because the artifacts after build have dist directories
16
+ var _default = () => ({
17
+ name: '@modern-js/plugin-express',
18
+ setup: api => {
19
+ let bffExportsUtils;
20
+ const {
21
+ useAppContext
22
+ } = api;
23
+ const runtimeModulePath = path.resolve(__dirname, '../runtime');
24
+ return {
25
+ config() {
26
+ // eslint-disable-next-line react-hooks/rules-of-hooks
27
+ const appContext = useAppContext();
28
+ const {
29
+ appDirectory
30
+ } = appContext;
31
+ bffExportsUtils = (0, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, 'server');
32
+ const serverRuntimePath = bffExportsUtils.getPath(); // Look up one level, because the artifacts after build have dist directories
30
33
 
31
- let relativeRuntimePath = path.join('../', path.relative(appDirectory, serverRuntimePath));
34
+ let relativeRuntimePath = path.join('../', path.relative(appDirectory, serverRuntimePath));
32
35
 
33
- if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
34
- relativeRuntimePath = `./${path.relative(appDirectory, serverRuntimePath)}`;
35
- }
36
+ if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
37
+ relativeRuntimePath = `./${path.relative(appDirectory, serverRuntimePath)}`;
38
+ }
36
39
 
37
- return {
38
- source: {
39
- alias: {
40
- '@modern-js/runtime/server': relativeRuntimePath
40
+ return {
41
+ source: {
42
+ alias: {
43
+ '@modern-js/runtime/server': relativeRuntimePath
44
+ }
41
45
  }
42
- }
43
- };
44
- },
46
+ };
47
+ },
45
48
 
46
- modifyEntryImports(input) {
47
- // eslint-disable-next-line react-hooks/rules-of-hooks
48
- const {
49
- appDirectory
50
- } = (0, _core.useAppContext)();
49
+ addRuntimeExports(input) {
50
+ // eslint-disable-next-line react-hooks/rules-of-hooks
51
+ const {
52
+ appDirectory
53
+ } = useAppContext();
51
54
 
52
- const runtimePath = require.resolve(`@modern-js/runtime`, {
53
- paths: [appDirectory]
54
- });
55
+ const runtimePath = require.resolve(`@modern-js/runtime`, {
56
+ paths: [appDirectory]
57
+ });
55
58
 
56
- const currentFile = bffExportsUtils.getPath();
57
- const runtimeDir = path.dirname(runtimePath);
58
- const relativeBffPath = path.relative(path.dirname(currentFile), path.join(runtimeDir, './exports/server'));
59
- const relativeRuntimeModulePath = path.relative(path.dirname(currentFile), runtimeModulePath);
60
- const relativeFramePath = path.relative(path.dirname(currentFile), require.resolve('express'));
61
- bffExportsUtils.addExport(`const bffRuntime = require('${relativeBffPath}');
59
+ const currentFile = bffExportsUtils.getPath();
60
+ const runtimeDir = path.dirname(runtimePath);
61
+ const relativeBffPath = path.relative(path.dirname(currentFile), path.join(runtimeDir, './exports/server'));
62
+ const relativeRuntimeModulePath = path.relative(path.dirname(currentFile), runtimeModulePath);
63
+ const relativeFramePath = path.relative(path.dirname(currentFile), require.resolve('express'));
64
+ bffExportsUtils.addExport(`const bffRuntime = require('${relativeBffPath}');
62
65
  const pluginRuntime = require('${relativeRuntimeModulePath}');
63
66
  const express = require('${relativeFramePath}')
64
67
  module.exports = {
@@ -67,12 +70,11 @@ var _default = (0, _core.createPlugin)(() => {
67
70
  ...pluginRuntime
68
71
  }
69
72
  `);
70
- return input;
71
- }
73
+ return input;
74
+ }
72
75
 
73
- };
74
- }, {
75
- name: '@modern-js/plugin-express'
76
+ };
77
+ }
76
78
  });
77
79
 
78
80
  exports.default = _default;
@@ -11,7 +11,7 @@ var _express = _interopRequireDefault(require("express"));
11
11
 
12
12
  var _cookieParser = _interopRequireDefault(require("cookie-parser"));
13
13
 
14
- var _serverPlugin = require("@modern-js/server-plugin");
14
+ var _serverCore = require("@modern-js/server-core");
15
15
 
16
16
  var _bffUtils = require("@modern-js/bff-utils");
17
17
 
@@ -70,7 +70,7 @@ const initApp = app => {
70
70
  return app;
71
71
  };
72
72
 
73
- var _default = (0, _serverPlugin.createPlugin)(() => ({
73
+ var _default = (0, _serverCore.createPlugin)(() => ({
74
74
  // eslint-disable-next-line max-statements
75
75
  async prepareApiServer({
76
76
  pwd,
@@ -1,18 +1,5 @@
1
- declare const _default: import("@modern-js/core").AsyncPlugin<Partial<import("@modern-js/core").Progresses2Threads<{
2
- config: import("@modern-js/core").ParallelWorkflow<void, unknown>;
3
- resolvedConfig: import("@modern-js/core").AsyncWaterfall<{
4
- resolved: import("@modern-js/core").NormalizedConfig;
5
- }>;
6
- validateSchema: import("@modern-js/core").ParallelWorkflow<void, unknown>;
7
- prepare: import("@modern-js/core").AsyncWorkflow<void, void>;
8
- commands: import("@modern-js/core").AsyncWorkflow<{
9
- program: import("commander").Command;
10
- }, void>;
11
- watchFiles: import("@modern-js/core").ParallelWorkflow<void, unknown>;
12
- fileChange: import("@modern-js/core").AsyncWorkflow<{
13
- filename: string;
14
- }, void>;
15
- beforeExit: import("@modern-js/core").AsyncWorkflow<void, void>;
16
- } & import("@modern-js/core").ClearDraftProgress<import("@modern-js/core").Hooks>>>>;
1
+ import type { CliPlugin } from '@modern-js/core';
2
+
3
+ declare const _default: () => CliPlugin;
17
4
 
18
5
  export default _default;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.3.1",
14
+ "version": "1.4.2",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -35,16 +35,18 @@
35
35
  "dependencies": {
36
36
  "@babel/runtime": "^7.15.3",
37
37
  "@modern-js/adapter-helpers": "^1.2.1",
38
- "@modern-js/utils": "^1.2.2",
38
+ "@modern-js/utils": "^1.3.5",
39
39
  "cookie-parser": "^1.4.5",
40
40
  "finalhandler": "^1.1.2",
41
41
  "formidable": "^1.2.2",
42
- "type-is": "^1.6.18"
42
+ "type-is": "^1.6.18",
43
+ "@modern-js/bff-utils": "^1.2.2",
44
+ "@modern-js/server-core": "^1.2.3",
45
+ "@modern-js/bff-runtime": "^1.2.1"
43
46
  },
44
47
  "devDependencies": {
45
48
  "express": "^4.17.1",
46
49
  "@modern-js/server-utils": "^1.2.1",
47
- "@modern-js/bff-runtime": "^1.2.1",
48
50
  "@types/cookie-parser": "^1.4.2",
49
51
  "@types/express": "^4.17.13",
50
52
  "@types/finalhandler": "^1.1.1",
@@ -55,9 +57,7 @@
55
57
  "@types/type-is": "^1.6.3",
56
58
  "supertest": "^6.1.6",
57
59
  "typescript": "^4",
58
- "@modern-js/bff-utils": "^1.2.2",
59
- "@modern-js/core": "^1.3.2",
60
- "@modern-js/server-plugin": "^1.2.1",
60
+ "@modern-js/core": "^1.5.0",
61
61
  "@scripts/build": "0.0.0",
62
62
  "jest": "^27",
63
63
  "@scripts/jest-config": "0.0.0"
@@ -68,16 +68,11 @@
68
68
  }
69
69
  },
70
70
  "peerDependencies": {
71
- "@modern-js/bff-utils": "^1.2.2",
72
- "@modern-js/core": "^1.3.2",
73
- "@modern-js/server-plugin": "^1.2.1",
74
- "@modern-js/bff-runtime": "^1.2.1",
75
71
  "express": "^4.17.1"
76
72
  },
77
73
  "publishConfig": {
78
74
  "registry": "https://registry.npmjs.org/",
79
- "access": "public",
80
- "types": "./dist/types/index.d.ts"
75
+ "access": "public"
81
76
  },
82
77
  "scripts": {
83
78
  "new": "modern new",
@@ -1,6 +1,6 @@
1
1
  import * as path from 'path';
2
2
  import request from 'supertest';
3
- import { serverManager } from '@modern-js/server-plugin';
3
+ import { serverManager } from '@modern-js/server-core';
4
4
  import { INTROSPECTION_ROUTE_PATH } from '@modern-js/bff-utils';
5
5
  import plugin from '../src/plugin';
6
6
  import { APIPlugin } from './helpers';
package/tests/helpers.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import path from 'path';
2
- import { createPlugin } from '@modern-js/server-plugin';
2
+ import { createPlugin } from '@modern-js/server-core';
3
3
  import { injectAPIHandlerInfos, API_DIR } from '@modern-js/bff-utils';
4
4
 
5
5
  export const APIPlugin = createPlugin(() => ({
@@ -1,7 +1,7 @@
1
1
  import path from 'path';
2
2
  import express from 'express';
3
3
  import request from 'supertest';
4
- import { serverManager } from '@modern-js/server-plugin';
4
+ import { serverManager } from '@modern-js/server-core';
5
5
  import { INTROSPECTION_ROUTE_PATH } from '@modern-js/bff-utils';
6
6
  import plugin from '../src/plugin';
7
7
  import { APIPlugin } from './helpers';
@@ -2,7 +2,7 @@ import * as path from 'path';
2
2
  import { Buffer } from 'buffer';
3
3
  import { Request, Response } from 'express';
4
4
  import request from 'supertest';
5
- import { serverManager } from '@modern-js/server-plugin';
5
+ import { serverManager } from '@modern-js/server-core';
6
6
  import plugin from '../src/plugin';
7
7
  import './common';
8
8