@modern-js/plugin-bff 1.3.8-canaray.0 → 1.4.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,42 @@
1
1
  # @modern-js/plugin-bff
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d2d1d6b2: feat: support server config
8
+
9
+ ### Patch Changes
10
+
11
+ - d2d1d6b2: feat: add prepare hook
12
+ - Updated dependencies [77ff9754]
13
+ - Updated dependencies [d2d1d6b2]
14
+ - Updated dependencies [07a4887e]
15
+ - Updated dependencies [ea2ae711]
16
+ - Updated dependencies [17d0cc46]
17
+ - Updated dependencies [d2d1d6b2]
18
+ - @modern-js/utils@1.4.0
19
+ - @modern-js/server-utils@1.2.2
20
+
21
+ ## 1.3.9
22
+
23
+ ### Patch Changes
24
+
25
+ - bebb39b6: chore: improve devDependencies and peerDependencies
26
+ - 132f7b53: feat: move config declarations to @modern-js/core
27
+ - Updated dependencies [bebb39b6]
28
+ - Updated dependencies [132f7b53]
29
+ - @modern-js/server-utils@1.2.2
30
+ - @modern-js/utils@1.3.7
31
+
32
+ ## 1.3.8
33
+
34
+ ### Patch Changes
35
+
36
+ - c1b8fa0a: feat: convert to new server plugin
37
+ - Updated dependencies [c2046f37]
38
+ - @modern-js/utils@1.3.6
39
+
3
40
  ## 1.3.6
4
41
 
5
42
  ### Patch Changes
@@ -1,8 +1,6 @@
1
- import "./types";
2
1
  import path from 'path';
3
- import fs from 'fs-extra';
4
2
  import { compiler } from '@modern-js/babel-compiler';
5
- import { PLUGIN_SCHEMAS, normalizeOutputPath, API_DIR } from '@modern-js/utils';
3
+ import { fs, API_DIR, PLUGIN_SCHEMAS, normalizeOutputPath } from '@modern-js/utils';
6
4
  import { resolveBabelConfig } from '@modern-js/server-utils';
7
5
  const DEFAULT_API_PREFIX = '/api';
8
6
  const TS_CONFIG_FILENAME = 'tsconfig.json';
@@ -1,2 +1 @@
1
- import "./types";
2
1
  export * from "./constants";
@@ -24,22 +24,25 @@ const createTransformAPI = storage => ({
24
24
  export default (() => ({
25
25
  name: '@modern-js/plugin-bff',
26
26
  setup: api => {
27
- const {
28
- appDirectory,
29
- distDirectory
30
- } = api.useAppContext();
31
- const root = isProd() ? distDirectory : appDirectory;
32
- const apiPath = path.resolve(root || process.cwd(), API_DIR);
33
- const apiAppPath = path.resolve(apiPath, API_APP_NAME);
34
27
  const storage = new Storage();
35
28
  const transformAPI = createTransformAPI(storage);
36
- const apiMod = requireExistModule(apiAppPath);
29
+ let apiAppPath = '';
30
+ return {
31
+ prepare() {
32
+ const {
33
+ appDirectory,
34
+ distDirectory
35
+ } = api.useAppContext();
36
+ const root = isProd() ? distDirectory : appDirectory;
37
+ const apiPath = path.resolve(root || process.cwd(), API_DIR);
38
+ apiAppPath = path.resolve(apiPath, API_APP_NAME);
39
+ const apiMod = requireExistModule(apiAppPath);
37
40
 
38
- if (apiMod && typeof apiMod === 'function') {
39
- apiMod(transformAPI);
40
- }
41
+ if (apiMod && typeof apiMod === 'function') {
42
+ apiMod(transformAPI);
43
+ }
44
+ },
41
45
 
42
- return {
43
46
  reset() {
44
47
  storage.reset();
45
48
  const newApiModule = requireExistModule(apiAppPath);
@@ -5,12 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- require("./types");
9
-
10
8
  var _path = _interopRequireDefault(require("path"));
11
9
 
12
- var _fsExtra = _interopRequireDefault(require("fs-extra"));
13
-
14
10
  var _babelCompiler = require("@modern-js/babel-compiler");
15
11
 
16
12
  var _utils = require("@modern-js/utils");
@@ -126,8 +122,8 @@ var _default = () => ({
126
122
  ignore: [`**/__tests__/**`, '**/typings/**', '*.d.ts', '*.test.ts']
127
123
  }, babelConfig);
128
124
 
129
- if (await _fsExtra.default.pathExists(rootDir)) {
130
- await _fsExtra.default.copy(rootDir, distDir, {
125
+ if (await _utils.fs.pathExists(rootDir)) {
126
+ await _utils.fs.copy(rootDir, distDir, {
131
127
  filter: src => !['.ts', '.js'].includes(_path.default.extname(src)) && src !== tsconfigPath
132
128
  });
133
129
  }
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- require("./types");
8
-
9
7
  var _constants = require("./constants");
10
8
 
11
9
  Object.keys(_constants).forEach(function (key) {
@@ -36,25 +36,27 @@ const createTransformAPI = storage => ({
36
36
  var _default = () => ({
37
37
  name: '@modern-js/plugin-bff',
38
38
  setup: api => {
39
- const {
40
- appDirectory,
41
- distDirectory
42
- } = api.useAppContext();
43
- const root = (0, _utils.isProd)() ? distDirectory : appDirectory;
44
-
45
- const apiPath = _path.default.resolve(root || process.cwd(), _utils.API_DIR);
46
-
47
- const apiAppPath = _path.default.resolve(apiPath, _constants.API_APP_NAME);
48
-
49
39
  const storage = new Storage();
50
40
  const transformAPI = createTransformAPI(storage);
51
- const apiMod = (0, _utils.requireExistModule)(apiAppPath);
41
+ let apiAppPath = '';
42
+ return {
43
+ prepare() {
44
+ const {
45
+ appDirectory,
46
+ distDirectory
47
+ } = api.useAppContext();
48
+ const root = (0, _utils.isProd)() ? distDirectory : appDirectory;
52
49
 
53
- if (apiMod && typeof apiMod === 'function') {
54
- apiMod(transformAPI);
55
- }
50
+ const apiPath = _path.default.resolve(root || process.cwd(), _utils.API_DIR);
51
+
52
+ apiAppPath = _path.default.resolve(apiPath, _constants.API_APP_NAME);
53
+ const apiMod = (0, _utils.requireExistModule)(apiAppPath);
54
+
55
+ if (apiMod && typeof apiMod === 'function') {
56
+ apiMod(transformAPI);
57
+ }
58
+ },
56
59
 
57
- return {
58
60
  reset() {
59
61
  storage.reset();
60
62
  const newApiModule = (0, _utils.requireExistModule)(apiAppPath);
@@ -1,4 +1,3 @@
1
- import './types';
2
1
  import type { CliPlugin } from '@modern-js/core';
3
2
 
4
3
  declare const _default: () => CliPlugin;
@@ -1,2 +1 @@
1
- import './types';
2
1
  export * from './constants';
package/jest.config.js CHANGED
@@ -2,7 +2,6 @@ const sharedConfig = require('@scripts/jest-config');
2
2
 
3
3
  /** @type {import('@jest/types').Config.InitialOptions} */
4
4
  module.exports = {
5
- // eslint-disable-next-line node/no-unsupported-features/es-syntax
6
5
  ...sharedConfig,
7
6
  rootDir: __dirname,
8
7
  };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.3.8-canaray.0",
14
+ "version": "1.4.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -56,38 +56,35 @@
56
56
  "@babel/core": "7.16.7",
57
57
  "@babel/runtime": "^7",
58
58
  "@modern-js/babel-compiler": "^1.2.2",
59
+ "@modern-js/bff-utils": "^1.2.2",
59
60
  "@modern-js/create-request": "^1.2.2",
60
- "@modern-js/server-utils": "^1.2.1",
61
- "@modern-js/utils": "^1.3.4",
62
- "fs-extra": "^10.0.0",
63
- "loader-utils": "^2.0.0",
64
- "@modern-js/bff-utils": "^1.2.2"
61
+ "@modern-js/server-utils": "^1.2.2",
62
+ "@modern-js/utils": "^1.4.0",
63
+ "loader-utils": "^2.0.0"
65
64
  },
66
65
  "devDependencies": {
66
+ "@modern-js/core": "1.7.0",
67
+ "@modern-js/plugin-analyze": "^1.3.6",
68
+ "@modern-js/runtime": "^1.2.5",
69
+ "@modern-js/server-core": "1.3.0",
70
+ "@modern-js/types": "^1.4.0",
67
71
  "@scripts/build": "0.0.0",
68
- "@modern-js/plugin-analyze": "^1.3.3",
69
- "@modern-js/runtime": "^1.2.2",
70
- "@modern-js/types": "^1.3.4",
72
+ "@scripts/jest-config": "0.0.0",
71
73
  "@types/babel__core": "^7.1.15",
72
- "@types/fs-extra": "^9.0.13",
73
74
  "@types/jest": "^26",
74
75
  "@types/loader-utils": "^2.0.3",
75
76
  "@types/node": "^14",
77
+ "jest": "^27",
76
78
  "memfs": "^3.3.0",
77
79
  "ts-jest": "^27.0.5",
78
80
  "typescript": "^4",
79
- "webpack": "^5.54.0",
80
- "webpack-chain": "^6.5.1",
81
- "jest": "^27",
82
- "@scripts/jest-config": "0.0.0",
83
- "@modern-js/server-core": "^1.2.3",
84
- "@modern-js/core": "^1.4.6"
81
+ "webpack": "^5.71.0",
82
+ "webpack-chain": "^6.5.1"
85
83
  },
86
84
  "sideEffects": false,
87
85
  "publishConfig": {
88
86
  "registry": "https://registry.npmjs.org/",
89
- "access": "public",
90
- "types": "./dist/types/index.d.ts"
87
+ "access": "public"
91
88
  },
92
89
  "scripts": {
93
90
  "new": "modern new",
package/tests/compiler.ts CHANGED
@@ -12,7 +12,6 @@ global.setImmediate = setTimeout;
12
12
  global.clearImmediate = clearTimeout;
13
13
 
14
14
  export const compiler = (fixture: string, options: APILoaderOptions) => {
15
- // eslint-disable-next-line @typescript-eslint/no-shadow
16
15
  const compiler = webpack({
17
16
  context: __dirname,
18
17
  entry: fixture,
package/types.d.ts CHANGED
@@ -4,7 +4,6 @@ declare module '@modern-js/core' {
4
4
  prefix: string;
5
5
  requestCreator: string;
6
6
  fetcher: string;
7
- proxy: Record<string, any>;
8
7
  }>;
9
8
  }
10
9
  }
@@ -1 +0,0 @@
1
- import '@modern-js/core';
@@ -1,3 +0,0 @@
1
- "use strict";
2
-
3
- require("@modern-js/core");
@@ -1,11 +0,0 @@
1
- import '@modern-js/core';
2
- declare module '@modern-js/core' {
3
- interface UserConfig {
4
- bff?: {
5
- prefix?: string;
6
- requestCreator?: string;
7
- fetcher?: string;
8
- proxy: Record<string, any>;
9
- };
10
- }
11
- }