@modern-js/plugin-testing 1.21.3 → 2.0.0-beta.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,16 +1,47 @@
1
1
  # @modern-js/plugin-testing
2
2
 
3
- ## 1.21.3
3
+ ## 2.0.0-beta.0
4
+
5
+ ### Major Changes
6
+
7
+ - dda38c9: chore: v2
4
8
 
5
9
  ### Patch Changes
6
10
 
7
- - @modern-js/babel-preset-app@1.21.3
8
- - @modern-js/webpack@1.21.3
9
- - @modern-js/runtime@1.21.3
10
- - @modern-js/prod-server@1.21.3
11
- - @modern-js/babel-compiler@1.21.3
12
- - @modern-js/plugin@1.21.3
13
- - @modern-js/utils@1.21.3
11
+ - cc971eabf: refactor: move server plugin load logic in `@modern-js/core`
12
+ refactor:移除在 `@modern-js/core` 中的 server 插件加载逻辑
13
+ - 14b712d: fix: use consistent alias type and default value across packages
14
+
15
+ fix: 在各个包中使用一致的 alias 类型定义和默认值
16
+
17
+ - Updated dependencies [b18fa8f]
18
+ - Updated dependencies [c9e800d39]
19
+ - Updated dependencies [15bf09d9c]
20
+ - Updated dependencies [a2509bf]
21
+ - Updated dependencies [decfcd989]
22
+ - Updated dependencies [4369648ae]
23
+ - Updated dependencies [edd1cfb1a]
24
+ - Updated dependencies [cc971eabf]
25
+ - Updated dependencies [5b9049f]
26
+ - Updated dependencies [6bda14ed7]
27
+ - Updated dependencies [b8bbe036c]
28
+ - Updated dependencies [60d5378]
29
+ - Updated dependencies [d5a31df78]
30
+ - Updated dependencies [dda38c9]
31
+ - Updated dependencies [102d32e4b]
32
+ - Updated dependencies [8b8e1bb57]
33
+ - Updated dependencies [3bbea92b2]
34
+ - Updated dependencies [73cd29dd9]
35
+ - Updated dependencies [fcace5b5b]
36
+ - Updated dependencies [abf3421]
37
+ - Updated dependencies [543be95]
38
+ - Updated dependencies [14b712d]
39
+ - @modern-js/runtime@2.0.0-beta.0
40
+ - @modern-js/prod-server@2.0.0-beta.0
41
+ - @modern-js/babel-preset-app@2.0.0-beta.0
42
+ - @modern-js/utils@2.0.0-beta.0
43
+ - @modern-js/plugin@2.0.0-beta.0
44
+ - @modern-js/babel-compiler@2.0.0-beta.0
14
45
 
15
46
  ## 1.21.2
16
47
 
@@ -11,7 +11,7 @@ const createApp = async (pwd, config, plugins, routes) => {
11
11
  apiOnly: true,
12
12
  pwd,
13
13
  config,
14
- plugins,
14
+ internalPlugins: plugins,
15
15
  routes
16
16
  });
17
17
  await server.init();
@@ -102,12 +102,11 @@ export default (() => ({
102
102
  }
103
103
 
104
104
  const userConfig = api.useResolvedConfigContext();
105
- const plugins = appContext.plugins.map(p => p.server).filter(Boolean);
106
105
  await setJestConfigForBFF({
107
106
  pwd,
108
107
  userConfig,
109
- plugins,
110
108
  routes: appContext.serverRoutes,
109
+ plugins: appContext.serverInternalPlugins,
111
110
  utils
112
111
  });
113
112
  return next(utils);
@@ -1,6 +1,5 @@
1
1
  import path from 'path';
2
- import { PLUGIN_SCHEMAS, createRuntimeExportsUtils, isApiOnly } from '@modern-js/utils';
3
- import { getWebpackConfig, WebpackConfigTarget } from '@modern-js/webpack';
2
+ import { isApiOnly, mergeAlias, PLUGIN_SCHEMAS, createRuntimeExportsUtils } from '@modern-js/utils';
4
3
  import { testingHooks, getModuleNameMapper, DEFAULT_RESOLVER_PATH } from "../base";
5
4
  import { MODERNJS_CONFIG_KEY } from "../constant";
6
5
  import TestingBffPlugin from "./bff";
@@ -60,12 +59,12 @@ export default (() => {
60
59
  return next(utils);
61
60
  }
62
61
 
63
- const webpackConfig = getWebpackConfig(WebpackConfigTarget.CLIENT, appContext, userConfig);
64
- const {
65
- resolve: {
66
- alias = {}
67
- }
68
- } = webpackConfig;
62
+ const alias = mergeAlias(userConfig.source.alias);
63
+
64
+ if (testingExportsUtils) {
65
+ alias['@modern-js/runtime/testing'] = [testingExportsUtils.getPath()];
66
+ }
67
+
69
68
  utils.mergeJestConfig({
70
69
  globals: {
71
70
  [MODERNJS_CONFIG_KEY]: userConfig
@@ -23,7 +23,7 @@ const createApp = async (pwd, config, plugins, routes) => {
23
23
  apiOnly: true,
24
24
  pwd,
25
25
  config,
26
- plugins,
26
+ internalPlugins: plugins,
27
27
  routes
28
28
  });
29
29
  await server.init();
@@ -119,12 +119,11 @@ var _default = () => ({
119
119
  }
120
120
 
121
121
  const userConfig = api.useResolvedConfigContext();
122
- const plugins = appContext.plugins.map(p => p.server).filter(Boolean);
123
122
  await setJestConfigForBFF({
124
123
  pwd,
125
124
  userConfig,
126
- plugins,
127
125
  routes: appContext.serverRoutes,
126
+ plugins: appContext.serverInternalPlugins,
128
127
  utils
129
128
  });
130
129
  return next(utils);
@@ -9,8 +9,6 @@ var _path = _interopRequireDefault(require("path"));
9
9
 
10
10
  var _utils = require("@modern-js/utils");
11
11
 
12
- var _webpack = require("@modern-js/webpack");
13
-
14
12
  var _base = require("../base");
15
13
 
16
14
  var _constant = require("../constant");
@@ -80,12 +78,12 @@ var _default = () => {
80
78
  return next(utils);
81
79
  }
82
80
 
83
- const webpackConfig = (0, _webpack.getWebpackConfig)(_webpack.WebpackConfigTarget.CLIENT, appContext, userConfig);
84
- const {
85
- resolve: {
86
- alias = {}
87
- }
88
- } = webpackConfig;
81
+ const alias = (0, _utils.mergeAlias)(userConfig.source.alias);
82
+
83
+ if (testingExportsUtils) {
84
+ alias['@modern-js/runtime/testing'] = [testingExportsUtils.getPath()];
85
+ }
86
+
89
87
  utils.mergeJestConfig({
90
88
  globals: {
91
89
  [_constant.MODERNJS_CONFIG_KEY]: userConfig
@@ -25,7 +25,7 @@ var createApp = /*#__PURE__*/function () {
25
25
  apiOnly: true,
26
26
  pwd: pwd,
27
27
  config: config,
28
- plugins: plugins,
28
+ internalPlugins: plugins,
29
29
  routes: routes
30
30
  });
31
31
  _context.next = 5;
@@ -103,7 +103,7 @@ export default (function () {
103
103
  return {
104
104
  jestConfig: function () {
105
105
  var _jestConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(utils, next) {
106
- var appContext, pwd, userConfig, plugins;
106
+ var appContext, pwd, userConfig;
107
107
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
108
108
  while (1) {
109
109
  switch (_context2.prev = _context2.next) {
@@ -120,22 +120,19 @@ export default (function () {
120
120
 
121
121
  case 4:
122
122
  userConfig = api.useResolvedConfigContext();
123
- plugins = appContext.plugins.map(function (p) {
124
- return p.server;
125
- }).filter(Boolean);
126
- _context2.next = 8;
123
+ _context2.next = 7;
127
124
  return setJestConfigForBFF({
128
125
  pwd: pwd,
129
126
  userConfig: userConfig,
130
- plugins: plugins,
131
127
  routes: appContext.serverRoutes,
128
+ plugins: appContext.serverInternalPlugins,
132
129
  utils: utils
133
130
  });
134
131
 
135
- case 8:
132
+ case 7:
136
133
  return _context2.abrupt("return", next(utils));
137
134
 
138
- case 9:
135
+ case 8:
139
136
  case "end":
140
137
  return _context2.stop();
141
138
  }
@@ -2,8 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
3
3
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
4
  import path from 'path';
5
- import { PLUGIN_SCHEMAS, createRuntimeExportsUtils, isApiOnly } from '@modern-js/utils';
6
- import { getWebpackConfig, WebpackConfigTarget } from '@modern-js/webpack';
5
+ import { isApiOnly, mergeAlias, PLUGIN_SCHEMAS, createRuntimeExportsUtils } from '@modern-js/utils';
7
6
  import { testingHooks, getModuleNameMapper, DEFAULT_RESOLVER_PATH } from "../base";
8
7
  import { MODERNJS_CONFIG_KEY } from "../constant";
9
8
  import TestingBffPlugin from "./bff";
@@ -63,8 +62,7 @@ export default (function () {
63
62
  },
64
63
  jestConfig: function () {
65
64
  var _jestConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(utils, next) {
66
- var appContext, userConfig, apiOnly, webpackConfig, _webpackConfig$resolv, alias;
67
-
65
+ var appContext, userConfig, apiOnly, alias;
68
66
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
69
67
  while (1) {
70
68
  switch (_context2.prev = _context2.next) {
@@ -85,8 +83,12 @@ export default (function () {
85
83
  return _context2.abrupt("return", next(utils));
86
84
 
87
85
  case 7:
88
- webpackConfig = getWebpackConfig(WebpackConfigTarget.CLIENT, appContext, userConfig);
89
- _webpackConfig$resolv = webpackConfig.resolve.alias, alias = _webpackConfig$resolv === void 0 ? {} : _webpackConfig$resolv;
86
+ alias = mergeAlias(userConfig.source.alias);
87
+
88
+ if (testingExportsUtils) {
89
+ alias['@modern-js/runtime/testing'] = [testingExportsUtils.getPath()];
90
+ }
91
+
90
92
  utils.mergeJestConfig({
91
93
  globals: _defineProperty({}, MODERNJS_CONFIG_KEY, userConfig),
92
94
  moduleNameMapper: getModuleNameMapper(alias),
@@ -1,8 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node/http" />
3
3
  /// <reference types="@modern-js/prod-server/src/type" />
4
+ import { InternalPlugins } from '@modern-js/types';
4
5
  export declare const isInHandler: () => boolean;
5
- declare const createApp: (pwd: string, config: any, plugins: any[], routes: any[]) => Promise<(req: import("http").IncomingMessage, res: import("http").ServerResponse, next?: (() => void) | undefined) => void>;
6
+ declare const createApp: (pwd: string, config: any, plugins: InternalPlugins, routes: any[]) => Promise<(req: import("http").IncomingMessage, res: import("http").ServerResponse, next?: (() => void) | undefined) => void>;
6
7
  declare const getApp: () => (req: import("http").IncomingMessage, res: import("http").ServerResponse, next?: (() => void) | undefined) => void;
7
8
  declare const closeServer: () => Promise<void>;
8
9
  export { createApp, getApp, closeServer };
@@ -1,4 +1,5 @@
1
1
  import type { CliPlugin } from '@modern-js/core';
2
+ import { InternalPlugins } from '@modern-js/types';
2
3
  import { TestConfigOperator } from '../../base';
3
4
  export declare const setJestConfigForBFF: ({
4
5
  pwd,
@@ -9,7 +10,7 @@ export declare const setJestConfigForBFF: ({
9
10
  }: {
10
11
  pwd: string;
11
12
  userConfig: any;
12
- plugins: any[];
13
+ plugins: InternalPlugins;
13
14
  routes: any[];
14
15
  utils: TestConfigOperator;
15
16
  }) => Promise<void>;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.21.3",
14
+ "version": "2.0.0-beta.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -99,14 +99,13 @@
99
99
  "@modern-js-reduck/plugin-effects": "^1.0.2",
100
100
  "@modern-js-reduck/plugin-immutable": "^1.0.1",
101
101
  "@modern-js-reduck/store": "^1.0.3",
102
- "@modern-js/babel-compiler": "1.21.3",
103
- "@modern-js/utils": "1.21.3",
104
- "@modern-js/webpack": "1.21.3",
105
- "@modern-js/babel-preset-app": "1.21.3",
106
- "@modern-js/plugin": "1.21.3",
107
- "@modern-js/prod-server": "1.21.3",
102
+ "@modern-js/babel-compiler": "2.0.0-beta.0",
103
+ "@modern-js/utils": "2.0.0-beta.0",
104
+ "@modern-js/babel-preset-app": "2.0.0-beta.0",
105
+ "@modern-js/plugin": "2.0.0-beta.0",
106
+ "@modern-js/prod-server": "2.0.0-beta.0",
108
107
  "@testing-library/jest-dom": "^5.14.1",
109
- "@testing-library/react": "^12.0.0",
108
+ "@testing-library/react": "^13.4.0",
110
109
  "@types/testing-library__jest-dom": "^5.14.3",
111
110
  "jest-environment-node": "^27.2.2",
112
111
  "path-to-regexp": "^6.2.0",
@@ -121,7 +120,7 @@
121
120
  "peerDependencies": {
122
121
  "react": ">=17",
123
122
  "react-dom": ">=17",
124
- "@modern-js/runtime": "^1.21.3"
123
+ "@modern-js/runtime": "^2.0.0-beta.0"
125
124
  },
126
125
  "peerDependenciesMeta": {
127
126
  "@modern-js/runtime": {
@@ -129,13 +128,14 @@
129
128
  }
130
129
  },
131
130
  "devDependencies": {
132
- "react": "^17",
133
- "react-dom": "^17",
134
- "@modern-js/core": "1.21.3",
135
- "@modern-js/runtime": "1.21.3",
136
- "@modern-js/bff-core": "1.21.3",
137
- "@scripts/build": "1.21.3",
138
- "@scripts/jest-config": "1.21.3",
131
+ "react": "^18",
132
+ "react-dom": "^18",
133
+ "@modern-js/core": "2.0.0-beta.0",
134
+ "@modern-js/types": "2.0.0-beta.0",
135
+ "@modern-js/runtime": "2.0.0-beta.0",
136
+ "@modern-js/bff-core": "2.0.0-beta.0",
137
+ "@scripts/build": "2.0.0-beta.0",
138
+ "@scripts/jest-config": "2.0.0-beta.0",
139
139
  "@types/jest": "^27",
140
140
  "@types/supertest": "^2.0.11",
141
141
  "@types/node": "^14",
@@ -150,33 +150,10 @@
150
150
  "registry": "https://registry.npmjs.org/",
151
151
  "access": "public"
152
152
  },
153
- "wireit": {
154
- "build": {
155
- "command": "modern build",
156
- "files": [
157
- "src/**/*",
158
- "tsconfig.json",
159
- "package.json"
160
- ],
161
- "output": [
162
- "dist/**/*"
163
- ]
164
- },
165
- "test": {
166
- "command": "jest",
167
- "files": [
168
- "src/**/*",
169
- "tsconfig.json",
170
- "package.json",
171
- "tests/**/*"
172
- ],
173
- "output": []
174
- }
175
- },
176
153
  "scripts": {
177
154
  "new": "modern new",
178
155
  "dev": "modern build --watch",
179
- "build": "wireit",
180
- "test": "wireit"
156
+ "build": "modern build",
157
+ "test": "jest"
181
158
  }
182
159
  }