@modern-js/plugin-testing 0.0.0-next-20221208182407 → 0.0.0-next-20221209041021

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.
Files changed (105) hide show
  1. package/CHANGELOG.md +7 -78
  2. package/dist/js/modern/base/config/index.js +29 -9
  3. package/dist/js/modern/base/config/patches/assetsModule.js +7 -7
  4. package/dist/js/modern/base/config/patches/filemock.js +4 -1
  5. package/dist/js/modern/base/config/patches/index.js +30 -7
  6. package/dist/js/modern/base/config/patches/transformer.js +13 -18
  7. package/dist/js/modern/base/config/resolver.js +11 -6
  8. package/dist/js/modern/base/config/testConfigOperator.js +29 -25
  9. package/dist/js/modern/base/config/transformer/babelTransformer.js +16 -8
  10. package/dist/js/modern/base/hook.js +10 -5
  11. package/dist/js/modern/base/index.js +14 -6
  12. package/dist/js/modern/base/runJest.js +73 -62
  13. package/dist/js/modern/base/utils.js +40 -25
  14. package/dist/js/modern/cli/bff/app.js +37 -12
  15. package/dist/js/modern/cli/bff/constant.js +4 -1
  16. package/dist/js/modern/cli/bff/index.js +95 -54
  17. package/dist/js/modern/cli/bff/mockAPI.js +79 -66
  18. package/dist/js/modern/cli/bff/setup.js +71 -34
  19. package/dist/js/modern/cli/bff/utils/index.js +31 -17
  20. package/dist/js/modern/cli/index.js +65 -30
  21. package/dist/js/modern/cli/test.js +53 -18
  22. package/dist/js/modern/constant.js +4 -1
  23. package/dist/js/modern/index.js +3 -3
  24. package/dist/js/modern/modern-app.env.d.js +0 -0
  25. package/dist/js/modern/runtime-testing/app.js +25 -16
  26. package/dist/js/modern/runtime-testing/base.js +7 -3
  27. package/dist/js/modern/runtime-testing/customRender.js +24 -12
  28. package/dist/js/modern/runtime-testing/index.js +1 -1
  29. package/dist/js/modern/runtime-testing/reduck.js +41 -21
  30. package/dist/js/modern/runtime-testing/request.js +4 -4
  31. package/dist/js/modern/runtime-testing/resolvePlugins.js +24 -10
  32. package/dist/js/node/base/config/index.js +56 -18
  33. package/dist/js/node/base/config/patches/assetsModule.js +30 -12
  34. package/dist/js/node/base/config/patches/filemock.js +22 -7
  35. package/dist/js/node/base/config/patches/index.js +50 -15
  36. package/dist/js/node/base/config/patches/transformer.js +38 -25
  37. package/dist/js/node/base/config/resolver.js +37 -10
  38. package/dist/js/node/base/config/testConfigOperator.js +49 -32
  39. package/dist/js/node/base/config/transformer/babelTransformer.js +40 -15
  40. package/dist/js/node/base/hook.js +28 -13
  41. package/dist/js/node/base/index.js +31 -63
  42. package/dist/js/node/base/runJest.js +99 -71
  43. package/dist/js/node/base/utils.js +66 -36
  44. package/dist/js/node/cli/bff/app.js +57 -22
  45. package/dist/js/node/cli/bff/constant.js +22 -7
  46. package/dist/js/node/cli/bff/index.js +121 -67
  47. package/dist/js/node/cli/bff/mockAPI.js +103 -73
  48. package/dist/js/node/cli/bff/setup.js +100 -38
  49. package/dist/js/node/cli/bff/utils/index.js +55 -24
  50. package/dist/js/node/cli/index.js +88 -46
  51. package/dist/js/node/cli/test.js +79 -27
  52. package/dist/js/node/constant.js +22 -7
  53. package/dist/js/node/index.js +19 -18
  54. package/dist/js/node/modern-app.env.d.js +0 -0
  55. package/dist/js/node/runtime-testing/app.js +53 -27
  56. package/dist/js/node/runtime-testing/base.js +30 -33
  57. package/dist/js/node/runtime-testing/customRender.js +49 -20
  58. package/dist/js/node/runtime-testing/index.js +18 -27
  59. package/dist/js/node/runtime-testing/reduck.js +67 -33
  60. package/dist/js/node/runtime-testing/request.js +32 -13
  61. package/dist/js/node/runtime-testing/resolvePlugins.js +41 -14
  62. package/dist/js/treeshaking/base/config/index.js +150 -31
  63. package/dist/js/treeshaking/base/config/patches/assetsModule.js +9 -11
  64. package/dist/js/treeshaking/base/config/patches/filemock.js +2 -1
  65. package/dist/js/treeshaking/base/config/patches/index.js +221 -64
  66. package/dist/js/treeshaking/base/config/patches/transformer.js +34 -37
  67. package/dist/js/treeshaking/base/config/resolver.js +24 -11
  68. package/dist/js/treeshaking/base/config/testConfigOperator.js +120 -69
  69. package/dist/js/treeshaking/base/config/transformer/babelTransformer.js +16 -10
  70. package/dist/js/treeshaking/base/hook.js +8 -7
  71. package/dist/js/treeshaking/base/index.js +7 -6
  72. package/dist/js/treeshaking/base/runJest.js +281 -164
  73. package/dist/js/treeshaking/base/utils.js +72 -48
  74. package/dist/js/treeshaking/cli/bff/app.js +192 -68
  75. package/dist/js/treeshaking/cli/bff/constant.js +2 -1
  76. package/dist/js/treeshaking/cli/bff/index.js +291 -130
  77. package/dist/js/treeshaking/cli/bff/mockAPI.js +181 -91
  78. package/dist/js/treeshaking/cli/bff/setup.js +185 -59
  79. package/dist/js/treeshaking/cli/bff/utils/index.js +47 -21
  80. package/dist/js/treeshaking/cli/index.js +249 -108
  81. package/dist/js/treeshaking/cli/test.js +177 -44
  82. package/dist/js/treeshaking/constant.js +2 -1
  83. package/dist/js/treeshaking/index.js +3 -3
  84. package/dist/js/treeshaking/modern-app.env.d.js +0 -0
  85. package/dist/js/treeshaking/runtime-testing/app.js +85 -39
  86. package/dist/js/treeshaking/runtime-testing/base.js +4 -3
  87. package/dist/js/treeshaking/runtime-testing/customRender.js +38 -10
  88. package/dist/js/treeshaking/runtime-testing/index.js +1 -1
  89. package/dist/js/treeshaking/runtime-testing/reduck.js +85 -33
  90. package/dist/js/treeshaking/runtime-testing/request.js +49 -19
  91. package/dist/js/treeshaking/runtime-testing/resolvePlugins.js +45 -14
  92. package/dist/types/base/config/index.d.ts +1 -0
  93. package/dist/types/base/config/patches/assetsModule.d.ts +1 -0
  94. package/dist/types/base/config/patches/filemock.d.ts +1 -0
  95. package/dist/types/base/config/patches/transformer.d.ts +1 -0
  96. package/dist/types/base/config/resolver.d.ts +2 -1
  97. package/dist/types/base/config/testConfigOperator.d.ts +2 -0
  98. package/dist/types/base/runJest.d.ts +2 -0
  99. package/dist/types/base/utils.d.ts +1 -0
  100. package/dist/types/cli/bff/index.d.ts +2 -0
  101. package/dist/types/cli/bff/mockAPI.d.ts +1 -0
  102. package/dist/types/cli/index.d.ts +2 -0
  103. package/dist/types/runtime-testing/app.d.ts +3 -0
  104. package/dist/types/runtime-testing/customRender.d.ts +2 -0
  105. package/package.json +13 -13
@@ -1,23 +1,37 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
- import path from 'path';
7
- import { chalk } from '@modern-js/utils';
8
- export const isBFFProject = pwd => {
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import path from "path";
18
+ import { chalk } from "@modern-js/utils";
19
+ const isBFFProject = (pwd) => {
9
20
  try {
10
- const packageJson = require(path.join(pwd, './package.json'));
11
- const {
12
- dependencies,
13
- devDependencies
14
- } = packageJson;
15
- const isBFF = Object.keys(_objectSpread(_objectSpread({}, dependencies), devDependencies)).some(dependency => dependency.includes('plugin-bff'));
16
- const isMWA = Object.keys(devDependencies).some(devDependency => devDependency.includes('app-tools'));
21
+ const packageJson = require(path.join(pwd, "./package.json"));
22
+ const { dependencies, devDependencies } = packageJson;
23
+ const isBFF = Object.keys(__spreadValues(__spreadValues({}, dependencies), devDependencies)).some(
24
+ (dependency) => dependency.includes("plugin-bff")
25
+ );
26
+ const isMWA = Object.keys(devDependencies).some(
27
+ (devDependency) => devDependency.includes("app-tools")
28
+ );
17
29
  return isMWA && isBFF;
18
30
  } catch (error) {
19
- // eslint-disable-next-line no-console
20
31
  console.log(chalk.red(error));
21
32
  return false;
22
33
  }
23
- };
34
+ };
35
+ export {
36
+ isBFFProject
37
+ };
@@ -1,80 +1,115 @@
1
- import path from 'path';
2
- import { isApiOnly, mergeAlias, PLUGIN_SCHEMAS, createRuntimeExportsUtils } from '@modern-js/utils';
3
- import { testingHooks, getModuleNameMapper, DEFAULT_RESOLVER_PATH } from "../base";
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ import path from "path";
22
+ import {
23
+ isApiOnly,
24
+ mergeAlias,
25
+ PLUGIN_SCHEMAS,
26
+ createRuntimeExportsUtils
27
+ } from "@modern-js/utils";
28
+ import {
29
+ testingHooks,
30
+ getModuleNameMapper,
31
+ DEFAULT_RESOLVER_PATH
32
+ } from "../base";
4
33
  import { MODERNJS_CONFIG_KEY } from "../constant";
5
34
  import TestingBffPlugin from "./bff";
6
35
  import test from "./test";
7
- export const mergeUserJestConfig = testUtils => {
36
+ const mergeUserJestConfig = (testUtils) => {
8
37
  const resolveJestConfig = testUtils.testConfig.jest;
9
-
10
- // resolveJestConfig 如果是函数类型,在所有测试插件 jestConfig 都执行后,再执行生成最终配置
11
- if (resolveJestConfig && typeof resolveJestConfig !== 'function') {
38
+ if (resolveJestConfig && typeof resolveJestConfig !== "function") {
12
39
  testUtils.mergeJestConfig(resolveJestConfig);
13
40
  }
14
41
  };
15
- export default (() => {
42
+ var cli_default = () => {
16
43
  const BffPlugin = TestingBffPlugin();
17
44
  return {
18
- name: '@modern-js/plugin-testing',
45
+ name: "@modern-js/plugin-testing",
19
46
  usePlugins: [BffPlugin],
20
47
  post: [BffPlugin.name],
21
48
  registerHook: testingHooks,
22
- setup: api => {
49
+ setup: (api) => {
23
50
  let testingExportsUtils;
24
51
  return {
25
- commands: ({
26
- program
27
- }) => {
28
- program.command('test').allowUnknownOption().usage('<regexForTestFiles> --[options]').action(async () => {
29
- await test(api);
30
- });
52
+ commands: ({ program }) => {
53
+ program.command("test").allowUnknownOption().usage("<regexForTestFiles> --[options]").action(() => __async(void 0, null, function* () {
54
+ yield test(api);
55
+ }));
31
56
  },
32
57
  validateSchema() {
33
- return PLUGIN_SCHEMAS['@modern-js/plugin-testing'];
58
+ return PLUGIN_SCHEMAS["@modern-js/plugin-testing"];
34
59
  },
35
60
  config() {
36
61
  const appContext = api.useAppContext();
37
- testingExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, 'testing');
62
+ testingExportsUtils = createRuntimeExportsUtils(
63
+ appContext.internalDirectory,
64
+ "testing"
65
+ );
38
66
  return {
39
67
  source: {
40
68
  alias: {
41
- '@modern-js/runtime/testing': testingExportsUtils.getPath()
69
+ "@modern-js/runtime/testing": testingExportsUtils.getPath()
42
70
  }
43
71
  }
44
72
  };
45
73
  },
46
74
  addRuntimeExports() {
47
- const testingPath = path.resolve(__dirname, '../');
75
+ const testingPath = path.resolve(__dirname, "../");
48
76
  testingExportsUtils.addExport(`export * from '${testingPath}'`);
49
77
  },
50
- jestConfig: async (utils, next) => {
78
+ jestConfig: (utils, next) => __async(void 0, null, function* () {
51
79
  const appContext = api.useAppContext();
52
80
  const userConfig = api.useResolvedConfigContext();
53
- const apiOnly = await isApiOnly(appContext.appDirectory);
81
+ const apiOnly = yield isApiOnly(appContext.appDirectory);
54
82
  if (apiOnly) {
55
83
  return next(utils);
56
84
  }
57
85
  const alias = mergeAlias(userConfig.source.alias);
58
86
  if (testingExportsUtils) {
59
- alias['@modern-js/runtime/testing'] = [testingExportsUtils.getPath()];
87
+ alias["@modern-js/runtime/testing"] = [
88
+ testingExportsUtils.getPath()
89
+ ];
60
90
  }
61
91
  utils.mergeJestConfig({
62
92
  globals: {
63
93
  [MODERNJS_CONFIG_KEY]: userConfig
64
94
  },
65
95
  moduleNameMapper: getModuleNameMapper(alias),
66
- testEnvironment: 'jsdom',
96
+ testEnvironment: "jsdom",
67
97
  resolver: DEFAULT_RESOLVER_PATH,
68
98
  rootDir: appContext.appDirectory || process.cwd(),
69
- // todo: diffrernt test root for diffrent solutions
70
- // testMatch: [`<rootDir>/(src|tests|electron)/**/*.test.[jt]s?(x)`],
71
- // testMatch bug on windows, issue: https://github.com/facebook/jest/issues/7914
72
- testMatch: [`<rootDir>/src/**/*.test.[jt]s?(x)`, `<rootDir>/tests/**/*.test.[jt]s?(x)`, `<rootDir>/electron/**/*.test.[jt]s?(x)`]
99
+ testMatch: [
100
+ `<rootDir>/src/**/*.test.[jt]s?(x)`,
101
+ `<rootDir>/tests/**/*.test.[jt]s?(x)`,
102
+ `<rootDir>/electron/**/*.test.[jt]s?(x)`
103
+ ]
73
104
  });
74
105
  mergeUserJestConfig(utils);
75
106
  return next(utils);
76
- }
107
+ })
77
108
  };
78
109
  }
79
110
  };
80
- });
111
+ };
112
+ export {
113
+ cli_default as default,
114
+ mergeUserJestConfig
115
+ };
@@ -1,26 +1,61 @@
1
- import path from 'path';
2
- import { compiler } from '@modern-js/babel-compiler';
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ import path from "path";
22
+ import { compiler } from "@modern-js/babel-compiler";
3
23
  import { runTest } from "../base";
4
- const test = async api => {
24
+ const test = (api) => __async(void 0, null, function* () {
25
+ var _a, _b;
5
26
  const userConfig = api.useResolvedConfigContext();
6
27
  const appContext = api.useAppContext();
7
28
  userConfig.testing = userConfig.testing || {};
8
- const jest = userConfig.testing.jest || userConfig.tools.jest;
29
+ const jest = userConfig.testing.jest || ((_a = userConfig == null ? void 0 : userConfig.tools) == null ? void 0 : _a.jest);
9
30
  if (Array.isArray(jest)) {
10
31
  userConfig.testing.jest = jest[0];
11
32
  }
12
- userConfig.testing.jest = userConfig.testing.jest || userConfig.tools.jest;
13
- const runtimeExportsPath = path.join(appContext.internalDirectory, '.runtime-exports');
14
- await compiler({
15
- sourceDir: runtimeExportsPath,
16
- rootDir: runtimeExportsPath,
17
- distDir: runtimeExportsPath,
18
- quiet: true
19
- }, {
20
- presets: [[require.resolve('@babel/preset-env'), {
21
- modules: 'cjs'
22
- }]]
23
- });
24
- await runTest(api, userConfig.testing);
33
+ userConfig.testing.jest = userConfig.testing.jest || ((_b = userConfig == null ? void 0 : userConfig.tools) == null ? void 0 : _b.jest);
34
+ const runtimeExportsPath = path.join(
35
+ appContext.internalDirectory,
36
+ ".runtime-exports"
37
+ );
38
+ yield compiler(
39
+ {
40
+ sourceDir: runtimeExportsPath,
41
+ rootDir: runtimeExportsPath,
42
+ distDir: runtimeExportsPath,
43
+ quiet: true
44
+ },
45
+ {
46
+ presets: [
47
+ [
48
+ require.resolve("@babel/preset-env"),
49
+ {
50
+ modules: "cjs"
51
+ }
52
+ ]
53
+ ]
54
+ }
55
+ );
56
+ yield runTest(api, userConfig.testing);
57
+ });
58
+ var test_default = test;
59
+ export {
60
+ test_default as default
25
61
  };
26
- export default test;
@@ -1 +1,4 @@
1
- export const MODERNJS_CONFIG_KEY = '__modernjs_config__';
1
+ const MODERNJS_CONFIG_KEY = "__modernjs_config__";
2
+ export {
3
+ MODERNJS_CONFIG_KEY
4
+ };
@@ -1,3 +1,3 @@
1
- import '@testing-library/jest-dom/extend-expect';
2
- import '@testing-library/jest-dom';
3
- export * from "./runtime-testing";
1
+ import "@testing-library/jest-dom/extend-expect";
2
+ import "@testing-library/jest-dom";
3
+ export * from "./runtime-testing";
File without changes
@@ -1,29 +1,35 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
- import { createApp } from '@modern-js/runtime';
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import { createApp } from "@modern-js/runtime";
7
18
  import { MODERNJS_CONFIG_KEY } from "../constant";
8
19
  import resolvePlugins from "./resolvePlugins";
9
20
  class ModernRuntime {
10
21
  constructor(options) {
11
- _defineProperty(this, "options", void 0);
12
22
  this.options = options;
13
23
  }
14
24
  init(options) {
15
25
  this.options = options;
16
26
  }
17
27
  createApp(props) {
18
- var _this$options;
19
- const {
20
- entry,
21
- children
22
- } = props || {};
23
- let runtimeFeatures = (_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.runtime;
28
+ var _a, _b;
29
+ const { entry, children } = props || {};
30
+ let runtimeFeatures = (_a = this.options) == null ? void 0 : _a.runtime;
24
31
  if (entry) {
25
- var _this$options$runtime;
26
- runtimeFeatures = _objectSpread(_objectSpread({}, runtimeFeatures || {}), (_this$options$runtime = this.options.runtimeByEntries) === null || _this$options$runtime === void 0 ? void 0 : _this$options$runtime[entry]);
32
+ runtimeFeatures = __spreadValues(__spreadValues({}, runtimeFeatures || {}), (_b = this.options.runtimeByEntries) == null ? void 0 : _b[entry]);
27
33
  }
28
34
  const Component = () => {
29
35
  if (!children) {
@@ -36,4 +42,7 @@ class ModernRuntime {
36
42
  })(Component);
37
43
  }
38
44
  }
39
- export default new ModernRuntime(global[MODERNJS_CONFIG_KEY] || {});
45
+ var app_default = new ModernRuntime(global[MODERNJS_CONFIG_KEY] || {});
46
+ export {
47
+ app_default as default
48
+ };
@@ -1,3 +1,7 @@
1
- export { default as renderApp } from "./customRender";
2
- export * from '@testing-library/react';
3
- export { request as testBff } from "./request";
1
+ import { default as default2 } from "./customRender";
2
+ export * from "@testing-library/react";
3
+ import { request } from "./request";
4
+ export {
5
+ default2 as renderApp,
6
+ request as testBff
7
+ };
@@ -1,13 +1,25 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
- import React from 'react';
7
- import { render } from '@testing-library/react';
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import React from "react";
18
+ import { render } from "@testing-library/react";
8
19
  import app from "./app";
9
- const WrapModernProviders = props => /*#__PURE__*/React.createElement(app.createApp(props));
10
- const customRender = (ui, options) => render(ui, _objectSpread({
11
- wrapper: WrapModernProviders
12
- }, options));
13
- export default customRender;
20
+ const WrapModernProviders = (props) => React.createElement(app.createApp(props));
21
+ const customRender = (ui, options) => render(ui, __spreadValues({ wrapper: WrapModernProviders }, options));
22
+ var customRender_default = customRender;
23
+ export {
24
+ customRender_default as default
25
+ };
@@ -1,2 +1,2 @@
1
1
  export * from "./base";
2
- export * from "./reduck";
2
+ export * from "./reduck";
@@ -1,35 +1,55 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
- import { createStore as originCreateStore } from '@modern-js-reduck/store';
7
- import effectsPlugin from '@modern-js-reduck/plugin-effects';
8
- import autoActionsPlugin from '@modern-js-reduck/plugin-auto-actions';
9
- import immerPlugin from '@modern-js-reduck/plugin-immutable';
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { createStore as originCreateStore } from "@modern-js-reduck/store";
21
+ import effectsPlugin from "@modern-js-reduck/plugin-effects";
22
+ import autoActionsPlugin from "@modern-js-reduck/plugin-auto-actions";
23
+ import immerPlugin from "@modern-js-reduck/plugin-immutable";
10
24
  import { MODERNJS_CONFIG_KEY } from "../constant";
11
- export const effects = () => effectsPlugin;
12
- export const immer = () => immerPlugin;
13
- export const autoActions = () => autoActionsPlugin;
14
- export const createStore = props => {
25
+ const effects = () => effectsPlugin;
26
+ const immer = () => immerPlugin;
27
+ const autoActions = () => autoActionsPlugin;
28
+ const createStore = (props) => {
15
29
  const createStatePlugins = () => {
16
- var _modernConfig$runtime;
30
+ var _a;
17
31
  const modernConfig = global[MODERNJS_CONFIG_KEY];
18
- const stateConfig = modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig$runtime = modernConfig.runtime) === null || _modernConfig$runtime === void 0 ? void 0 : _modernConfig$runtime.state;
32
+ const stateConfig = (_a = modernConfig == null ? void 0 : modernConfig.runtime) == null ? void 0 : _a.state;
19
33
  const plugins = [];
20
- if ((stateConfig === null || stateConfig === void 0 ? void 0 : stateConfig.effects) !== false) {
34
+ if ((stateConfig == null ? void 0 : stateConfig.effects) !== false) {
21
35
  plugins.push(effects());
22
36
  }
23
- if ((stateConfig === null || stateConfig === void 0 ? void 0 : stateConfig.autoActions) !== false) {
37
+ if ((stateConfig == null ? void 0 : stateConfig.autoActions) !== false) {
24
38
  plugins.push(autoActions());
25
39
  }
26
- if ((stateConfig === null || stateConfig === void 0 ? void 0 : stateConfig.immer) !== false) {
40
+ if ((stateConfig == null ? void 0 : stateConfig.immer) !== false) {
27
41
  plugins.push(immer());
28
42
  }
29
- return ((props === null || props === void 0 ? void 0 : props.plugins) || []).concat(plugins);
43
+ return ((props == null ? void 0 : props.plugins) || []).concat(plugins);
30
44
  };
31
- const config = _objectSpread(_objectSpread({}, props || {}), {}, {
45
+ const config = __spreadProps(__spreadValues({}, props || {}), {
32
46
  plugins: createStatePlugins()
33
47
  });
34
48
  return originCreateStore(config);
35
- };
49
+ };
50
+ export {
51
+ autoActions,
52
+ createStore,
53
+ effects,
54
+ immer
55
+ };
@@ -1,6 +1,4 @@
1
- /* eslint-disable eslint-comments/disable-enable-pair */
2
-
3
- import supertest from 'supertest';
1
+ import supertest from "supertest";
4
2
  import { getApp } from "../cli/bff/app";
5
3
  function request(...args) {
6
4
  const [fn, ...extraArgs] = args;
@@ -13,4 +11,6 @@ function request(...args) {
13
11
  fn.returnHttp = false;
14
12
  return res;
15
13
  }
16
- export { request };
14
+ export {
15
+ request
16
+ };
@@ -1,19 +1,33 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
- const allowedFeatures = ['router', 'state'];
7
- export default function resolvePlugins(features) {
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ const allowedFeatures = ["router", "state"];
18
+ function resolvePlugins(features) {
8
19
  const plugins = [];
9
20
  if (!features) {
10
21
  return plugins;
11
22
  }
12
- Object.keys(features).forEach(feature => {
23
+ Object.keys(features).forEach((feature) => {
13
24
  if (allowedFeatures.includes(feature)) {
14
- const curPluginRes = require(`@modern-js/runtime/plugins`)[feature](_objectSpread({}, features[feature]));
25
+ const curPluginRes = require(`@modern-js/runtime/plugins`)[feature](__spreadValues({}, features[feature]));
15
26
  plugins.push(curPluginRes);
16
27
  }
17
28
  });
18
29
  return plugins;
19
- }
30
+ }
31
+ export {
32
+ resolvePlugins as default
33
+ };