@modern-js/plugin-testing 0.0.0-next-20240618081858 → 0.0.0-next-20240618094033

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.
@@ -43,11 +43,10 @@ let server;
43
43
  const createApp = async (pwd, config, plugins, routes) => {
44
44
  if (!server) {
45
45
  config.output.path = "./";
46
- const pluginInstances = (0, import_prod_server.loadServerPlugins)(plugins, pwd);
47
46
  server = await (0, import_prod_server.createProdServer)({
48
47
  pwd,
49
48
  config,
50
- plugins: pluginInstances,
49
+ internalPlugins: plugins,
51
50
  routes,
52
51
  appContext: {
53
52
  apiDirectory: import_node_path.default.join(pwd, "api"),
@@ -138,7 +138,8 @@ const testingBffPlugin = () => ({
138
138
  pwd,
139
139
  userConfig,
140
140
  routes: appContext.serverRoutes,
141
- plugins: appContext.serverPlugins,
141
+ // Todo need use collect server internalPlugins
142
+ plugins: appContext.serverInternalPlugins,
142
143
  utils,
143
144
  appContext
144
145
  });
@@ -35,17 +35,9 @@ var import_path = __toESM(require("path"));
35
35
  var import_babel_compiler = require("@modern-js/babel-compiler");
36
36
  var import_base = require("../base");
37
37
  const test = async (api) => {
38
- var _runner__internalServerPlugins, _userConfig_tools, _userConfig_tools1;
38
+ var _userConfig_tools, _userConfig_tools1;
39
39
  const userConfig = api.useResolvedConfigContext();
40
40
  const appContext = api.useAppContext();
41
- const runner = api.useHookRunners();
42
- const { plugins = [] } = await ((_runner__internalServerPlugins = runner._internalServerPlugins) === null || _runner__internalServerPlugins === void 0 ? void 0 : _runner__internalServerPlugins.call(runner, {
43
- plugins: []
44
- })) || {};
45
- api.setAppContext({
46
- ...api.useAppContext(),
47
- serverPlugins: plugins
48
- });
49
41
  userConfig.testing = userConfig.testing || {};
50
42
  const jest = userConfig.testing.jest || (userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_tools = userConfig.tools) === null || _userConfig_tools === void 0 ? void 0 : _userConfig_tools.jest);
51
43
  if (Array.isArray(jest)) {
@@ -2,7 +2,7 @@ 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 { AsyncLocalStorage } from "async_hooks";
4
4
  import path from "node:path";
5
- import { createProdServer, loadServerPlugins } from "@modern-js/prod-server";
5
+ import { createProdServer } from "@modern-js/prod-server";
6
6
  var store = new AsyncLocalStorage();
7
7
  var isInHandler = function() {
8
8
  return Boolean(store.getStore());
@@ -10,7 +10,7 @@ var isInHandler = function() {
10
10
  var server;
11
11
  var createApp = function() {
12
12
  var _ref = _async_to_generator(function(pwd, config, plugins, routes) {
13
- var pluginInstances, app;
13
+ var app;
14
14
  return _ts_generator(this, function(_state) {
15
15
  switch (_state.label) {
16
16
  case 0:
@@ -20,13 +20,12 @@ var createApp = function() {
20
20
  2
21
21
  ];
22
22
  config.output.path = "./";
23
- pluginInstances = loadServerPlugins(plugins, pwd);
24
23
  return [
25
24
  4,
26
25
  createProdServer({
27
26
  pwd,
28
27
  config,
29
- plugins: pluginInstances,
28
+ internalPlugins: plugins,
30
29
  routes,
31
30
  appContext: {
32
31
  apiDirectory: path.join(pwd, "api"),
@@ -129,7 +129,8 @@ var testingBffPlugin = function() {
129
129
  pwd,
130
130
  userConfig,
131
131
  routes: appContext.serverRoutes,
132
- plugins: appContext.serverPlugins,
132
+ // Todo need use collect server internalPlugins
133
+ plugins: appContext.serverInternalPlugins,
133
134
  utils,
134
135
  appContext
135
136
  })
@@ -1,30 +1,16 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
- import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
3
  import path from "path";
6
4
  import { compiler } from "@modern-js/babel-compiler";
7
5
  import { runTest } from "../base";
8
6
  var test = function() {
9
7
  var _ref = _async_to_generator(function(api) {
10
- var _runner__internalServerPlugins, _userConfig_tools, _userConfig_tools1, userConfig, appContext, runner, _ref2, _ref_plugins, plugins, jest, runtimeExportsPath;
8
+ var _userConfig_tools, _userConfig_tools1, userConfig, appContext, jest, runtimeExportsPath;
11
9
  return _ts_generator(this, function(_state) {
12
10
  switch (_state.label) {
13
11
  case 0:
14
12
  userConfig = api.useResolvedConfigContext();
15
13
  appContext = api.useAppContext();
16
- runner = api.useHookRunners();
17
- return [
18
- 4,
19
- (_runner__internalServerPlugins = runner._internalServerPlugins) === null || _runner__internalServerPlugins === void 0 ? void 0 : _runner__internalServerPlugins.call(runner, {
20
- plugins: []
21
- })
22
- ];
23
- case 1:
24
- _ref2 = _state.sent() || {}, _ref_plugins = _ref2.plugins, plugins = _ref_plugins === void 0 ? [] : _ref_plugins;
25
- api.setAppContext(_object_spread_props(_object_spread({}, api.useAppContext()), {
26
- serverPlugins: plugins
27
- }));
28
14
  userConfig.testing = userConfig.testing || {};
29
15
  jest = userConfig.testing.jest || (userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_tools = userConfig.tools) === null || _userConfig_tools === void 0 ? void 0 : _userConfig_tools.jest);
30
16
  if (Array.isArray(jest)) {
@@ -50,13 +36,13 @@ var test = function() {
50
36
  ]
51
37
  })
52
38
  ];
53
- case 2:
39
+ case 1:
54
40
  _state.sent();
55
41
  return [
56
42
  4,
57
43
  runTest(api, userConfig.testing)
58
44
  ];
59
- case 3:
45
+ case 2:
60
46
  _state.sent();
61
47
  return [
62
48
  2
@@ -1,17 +1,16 @@
1
1
  import { AsyncLocalStorage } from "async_hooks";
2
2
  import path from "node:path";
3
- import { createProdServer, loadServerPlugins } from "@modern-js/prod-server";
3
+ import { createProdServer } from "@modern-js/prod-server";
4
4
  const store = new AsyncLocalStorage();
5
5
  const isInHandler = () => Boolean(store.getStore());
6
6
  let server;
7
7
  const createApp = async (pwd, config, plugins, routes) => {
8
8
  if (!server) {
9
9
  config.output.path = "./";
10
- const pluginInstances = loadServerPlugins(plugins, pwd);
11
10
  server = await createProdServer({
12
11
  pwd,
13
12
  config,
14
- plugins: pluginInstances,
13
+ internalPlugins: plugins,
15
14
  routes,
16
15
  appContext: {
17
16
  apiDirectory: path.join(pwd, "api"),
@@ -104,7 +104,8 @@ const testingBffPlugin = () => ({
104
104
  pwd,
105
105
  userConfig,
106
106
  routes: appContext.serverRoutes,
107
- plugins: appContext.serverPlugins,
107
+ // Todo need use collect server internalPlugins
108
+ plugins: appContext.serverInternalPlugins,
108
109
  utils,
109
110
  appContext
110
111
  });
@@ -2,17 +2,9 @@ import path from "path";
2
2
  import { compiler } from "@modern-js/babel-compiler";
3
3
  import { runTest } from "../base";
4
4
  const test = async (api) => {
5
- var _runner__internalServerPlugins, _userConfig_tools, _userConfig_tools1;
5
+ var _userConfig_tools, _userConfig_tools1;
6
6
  const userConfig = api.useResolvedConfigContext();
7
7
  const appContext = api.useAppContext();
8
- const runner = api.useHookRunners();
9
- const { plugins = [] } = await ((_runner__internalServerPlugins = runner._internalServerPlugins) === null || _runner__internalServerPlugins === void 0 ? void 0 : _runner__internalServerPlugins.call(runner, {
10
- plugins: []
11
- })) || {};
12
- api.setAppContext({
13
- ...api.useAppContext(),
14
- serverPlugins: plugins
15
- });
16
8
  userConfig.testing = userConfig.testing || {};
17
9
  const jest = userConfig.testing.jest || (userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_tools = userConfig.tools) === null || _userConfig_tools === void 0 ? void 0 : _userConfig_tools.jest);
18
10
  if (Array.isArray(jest)) {
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
- import { ServerPlugin } from '@modern-js/types';
2
+ import { InternalPlugins } from '@modern-js/types';
3
3
  export declare const isInHandler: () => boolean;
4
- declare const createApp: (pwd: string, config: any, plugins: ServerPlugin[], routes: any[]) => Promise<(req: import("http").IncomingMessage, res: import("http").ServerResponse) => Promise<void>>;
4
+ declare const createApp: (pwd: string, config: any, plugins: InternalPlugins, routes: any[]) => Promise<(req: import("http").IncomingMessage, res: import("http").ServerResponse) => Promise<void>>;
5
5
  declare const getApp: () => (req: import("http").IncomingMessage, res: import("http").ServerResponse) => Promise<void>;
6
6
  declare const closeServer: () => Promise<void>;
7
7
  export { createApp, getApp, closeServer };
@@ -1,12 +1,12 @@
1
1
  import type { CliPlugin, IAppContext } from '@modern-js/core';
2
- import { ServerPlugin } from '@modern-js/prod-server';
2
+ import { InternalPlugins } from '@modern-js/types';
3
3
  import { UserConfig } from '../../base/config';
4
4
  import { TestConfigOperator } from '../../base';
5
5
  import type { Hooks } from '../../base/hook';
6
6
  export declare const setJestConfigForBFF: ({ pwd, userConfig, plugins, routes, utils, appContext, }: {
7
7
  pwd: string;
8
8
  userConfig: any;
9
- plugins: ServerPlugin[];
9
+ plugins: InternalPlugins;
10
10
  routes: any[];
11
11
  utils: TestConfigOperator;
12
12
  appContext: IAppContext;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "0.0.0-next-20240618081858",
18
+ "version": "0.0.0-next-20240618094033",
19
19
  "jsnext:source": "./src/cli/index.ts",
20
20
  "types": "./dist/types/cli/index.d.ts",
21
21
  "main": "./dist/cjs/cli/index.js",
@@ -131,17 +131,17 @@
131
131
  "ts-jest": "^29.1.0",
132
132
  "yargs": "^17.0.1",
133
133
  "@swc/helpers": "0.5.3",
134
- "@modern-js/babel-compiler": "0.0.0-next-20240618081858",
135
- "@modern-js/plugin": "0.0.0-next-20240618081858",
136
- "@modern-js/utils": "0.0.0-next-20240618081858",
137
- "@modern-js/bff-core": "0.0.0-next-20240618081858",
138
- "@modern-js/types": "0.0.0-next-20240618081858",
139
- "@modern-js/prod-server": "0.0.0-next-20240618081858"
134
+ "@modern-js/babel-compiler": "0.0.0-next-20240618094033",
135
+ "@modern-js/utils": "0.0.0-next-20240618094033",
136
+ "@modern-js/prod-server": "0.0.0-next-20240618094033",
137
+ "@modern-js/plugin": "0.0.0-next-20240618094033",
138
+ "@modern-js/types": "0.0.0-next-20240618094033",
139
+ "@modern-js/bff-core": "0.0.0-next-20240618094033"
140
140
  },
141
141
  "peerDependencies": {
142
142
  "react": ">=17",
143
143
  "react-dom": ">=17",
144
- "@modern-js/runtime": "0.0.0-next-20240618081858"
144
+ "@modern-js/runtime": "0.0.0-next-20240618094033"
145
145
  },
146
146
  "peerDependenciesMeta": {
147
147
  "@modern-js/runtime": {
@@ -156,10 +156,10 @@
156
156
  "@types/node": "^14",
157
157
  "@types/yargs": "^17.0.2",
158
158
  "typescript": "^5",
159
- "@modern-js/core": "0.0.0-next-20240618081858",
160
- "@modern-js/runtime": "0.0.0-next-20240618081858",
161
- "@scripts/build": "0.0.0-next-20240618081858",
162
- "@scripts/jest-config": "0.0.0-next-20240618081858"
159
+ "@modern-js/core": "0.0.0-next-20240618094033",
160
+ "@modern-js/runtime": "0.0.0-next-20240618094033",
161
+ "@scripts/build": "0.0.0-next-20240618094033",
162
+ "@scripts/jest-config": "0.0.0-next-20240618094033"
163
163
  },
164
164
  "sideEffects": false,
165
165
  "publishConfig": {