@tramvai/test-child-app 2.70.1 → 2.72.3

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/lib/index.es.js CHANGED
@@ -1,75 +1 @@
1
- import { CHILD_APP_RESOLVE_BASE_URL_TOKEN, CHILD_APP_RESOLUTION_CONFIGS_TOKEN, CHILD_APP_LOADER_TOKEN, CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN, CHILD_APP_RESOLVE_CONFIG_TOKEN, CHILD_APP_DI_MANAGER_TOKEN, CHILD_APP_INTERNAL_RENDER_TOKEN } from '@tramvai/child-app-core';
2
- import { provide } from '@tramvai/core';
3
- import { ChildAppModule } from '@tramvai/module-child-app';
4
- import { createTestApp, testApp } from '@tramvai/test-unit';
5
-
6
- // mock module federation internal stuff
7
- // @ts-ignore
8
- global.__webpack_init_sharing__ = async () => { };
9
- // @ts-ignore
10
- global.__webpack_share_scopes__ = { default: { react: {}, 'react-dom': {} } };
11
- // @ts-ignore
12
- global.setImmediate = (fn) => fn();
13
- const testChildApp = async (childApp, options = {}) => {
14
- var _a, _b;
15
- const testAppInstance = await createTestApp({
16
- ...options,
17
- modules: [...((_a = options.modules) !== null && _a !== void 0 ? _a : []), ChildAppModule],
18
- providers: [
19
- ...((_b = options.providers) !== null && _b !== void 0 ? _b : []),
20
- provide({
21
- provide: CHILD_APP_RESOLVE_BASE_URL_TOKEN,
22
- useValue: 'http://test',
23
- }),
24
- provide({
25
- provide: CHILD_APP_RESOLUTION_CONFIGS_TOKEN,
26
- multi: true,
27
- useValue: [
28
- {
29
- name: childApp.name,
30
- byTag: {
31
- latest: {
32
- version: 'test',
33
- },
34
- },
35
- },
36
- ],
37
- }),
38
- provide({
39
- // replace loader for child-app as we do not need any logic for loading child-app
40
- provide: CHILD_APP_LOADER_TOKEN,
41
- useValue: {
42
- get(config) {
43
- if (config.name !== childApp.name) {
44
- throw new Error(`Cannot resolve child-app with name "${config.name}",
45
- This test wrapper supports only child-app with name "${childApp.name}"`);
46
- }
47
- return childApp;
48
- },
49
- async init(_) { },
50
- async load(_) { },
51
- },
52
- }),
53
- ],
54
- });
55
- const testAppWrapper = await testApp(testAppInstance.app);
56
- const appDi = testAppWrapper.app.di;
57
- await appDi.get(CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN).init();
58
- const resolveExternalConfig = appDi.get(CHILD_APP_RESOLVE_CONFIG_TOKEN);
59
- const diManager = appDi.get(CHILD_APP_DI_MANAGER_TOKEN);
60
- const config = resolveExternalConfig({ name: childApp.name });
61
- const di = config && diManager.getChildDi(config);
62
- if (!di) {
63
- throw new Error('Cannot resolve child-app di');
64
- }
65
- const Component = di.get(CHILD_APP_INTERNAL_RENDER_TOKEN);
66
- return {
67
- ...testAppWrapper,
68
- childApp: {
69
- di,
70
- Component,
71
- },
72
- };
73
- };
74
-
75
- export { testChildApp };
1
+ export { testChildApp } from './testChildApp.es.js';
package/lib/index.js CHANGED
@@ -2,78 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var childAppCore = require('@tramvai/child-app-core');
6
- var core = require('@tramvai/core');
7
- var moduleChildApp = require('@tramvai/module-child-app');
8
- var testUnit = require('@tramvai/test-unit');
5
+ var testChildApp = require('./testChildApp.js');
9
6
 
10
- // mock module federation internal stuff
11
- // @ts-ignore
12
- global.__webpack_init_sharing__ = async () => { };
13
- // @ts-ignore
14
- global.__webpack_share_scopes__ = { default: { react: {}, 'react-dom': {} } };
15
- // @ts-ignore
16
- global.setImmediate = (fn) => fn();
17
- const testChildApp = async (childApp, options = {}) => {
18
- var _a, _b;
19
- const testAppInstance = await testUnit.createTestApp({
20
- ...options,
21
- modules: [...((_a = options.modules) !== null && _a !== void 0 ? _a : []), moduleChildApp.ChildAppModule],
22
- providers: [
23
- ...((_b = options.providers) !== null && _b !== void 0 ? _b : []),
24
- core.provide({
25
- provide: childAppCore.CHILD_APP_RESOLVE_BASE_URL_TOKEN,
26
- useValue: 'http://test',
27
- }),
28
- core.provide({
29
- provide: childAppCore.CHILD_APP_RESOLUTION_CONFIGS_TOKEN,
30
- multi: true,
31
- useValue: [
32
- {
33
- name: childApp.name,
34
- byTag: {
35
- latest: {
36
- version: 'test',
37
- },
38
- },
39
- },
40
- ],
41
- }),
42
- core.provide({
43
- // replace loader for child-app as we do not need any logic for loading child-app
44
- provide: childAppCore.CHILD_APP_LOADER_TOKEN,
45
- useValue: {
46
- get(config) {
47
- if (config.name !== childApp.name) {
48
- throw new Error(`Cannot resolve child-app with name "${config.name}",
49
- This test wrapper supports only child-app with name "${childApp.name}"`);
50
- }
51
- return childApp;
52
- },
53
- async init(_) { },
54
- async load(_) { },
55
- },
56
- }),
57
- ],
58
- });
59
- const testAppWrapper = await testUnit.testApp(testAppInstance.app);
60
- const appDi = testAppWrapper.app.di;
61
- await appDi.get(childAppCore.CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN).init();
62
- const resolveExternalConfig = appDi.get(childAppCore.CHILD_APP_RESOLVE_CONFIG_TOKEN);
63
- const diManager = appDi.get(childAppCore.CHILD_APP_DI_MANAGER_TOKEN);
64
- const config = resolveExternalConfig({ name: childApp.name });
65
- const di = config && diManager.getChildDi(config);
66
- if (!di) {
67
- throw new Error('Cannot resolve child-app di');
68
- }
69
- const Component = di.get(childAppCore.CHILD_APP_INTERNAL_RENDER_TOKEN);
70
- return {
71
- ...testAppWrapper,
72
- childApp: {
73
- di,
74
- Component,
75
- },
76
- };
77
- };
78
7
 
79
- exports.testChildApp = testChildApp;
8
+
9
+ exports.testChildApp = testChildApp.testChildApp;
@@ -0,0 +1,75 @@
1
+ import { CHILD_APP_RESOLVE_BASE_URL_TOKEN, CHILD_APP_RESOLUTION_CONFIGS_TOKEN, CHILD_APP_LOADER_TOKEN, CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN, CHILD_APP_RESOLVE_CONFIG_TOKEN, CHILD_APP_DI_MANAGER_TOKEN, CHILD_APP_INTERNAL_RENDER_TOKEN } from '@tramvai/child-app-core';
2
+ import { provide } from '@tramvai/core';
3
+ import { ChildAppModule } from '@tramvai/module-child-app';
4
+ import { createTestApp, testApp } from '@tramvai/test-unit';
5
+
6
+ // mock module federation internal stuff
7
+ // @ts-ignore
8
+ global.__webpack_init_sharing__ = async () => { };
9
+ // @ts-ignore
10
+ global.__webpack_share_scopes__ = { default: { react: {}, 'react-dom': {} } };
11
+ // @ts-ignore
12
+ global.setImmediate = (fn) => fn();
13
+ const testChildApp = async (childApp, options = {}) => {
14
+ var _a, _b;
15
+ const testAppInstance = await createTestApp({
16
+ ...options,
17
+ modules: [...((_a = options.modules) !== null && _a !== void 0 ? _a : []), ChildAppModule],
18
+ providers: [
19
+ ...((_b = options.providers) !== null && _b !== void 0 ? _b : []),
20
+ provide({
21
+ provide: CHILD_APP_RESOLVE_BASE_URL_TOKEN,
22
+ useValue: 'http://test',
23
+ }),
24
+ provide({
25
+ provide: CHILD_APP_RESOLUTION_CONFIGS_TOKEN,
26
+ multi: true,
27
+ useValue: [
28
+ {
29
+ name: childApp.name,
30
+ byTag: {
31
+ latest: {
32
+ version: 'test',
33
+ },
34
+ },
35
+ },
36
+ ],
37
+ }),
38
+ provide({
39
+ // replace loader for child-app as we do not need any logic for loading child-app
40
+ provide: CHILD_APP_LOADER_TOKEN,
41
+ useValue: {
42
+ get(config) {
43
+ if (config.name !== childApp.name) {
44
+ throw new Error(`Cannot resolve child-app with name "${config.name}",
45
+ This test wrapper supports only child-app with name "${childApp.name}"`);
46
+ }
47
+ return childApp;
48
+ },
49
+ async init(_) { },
50
+ async load(_) { },
51
+ },
52
+ }),
53
+ ],
54
+ });
55
+ const testAppWrapper = await testApp(testAppInstance.app);
56
+ const appDi = testAppWrapper.app.di;
57
+ await appDi.get(CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN).init();
58
+ const resolveExternalConfig = appDi.get(CHILD_APP_RESOLVE_CONFIG_TOKEN);
59
+ const diManager = appDi.get(CHILD_APP_DI_MANAGER_TOKEN);
60
+ const config = resolveExternalConfig({ name: childApp.name });
61
+ const di = config && diManager.getChildDi(config);
62
+ if (!di) {
63
+ throw new Error('Cannot resolve child-app di');
64
+ }
65
+ const Component = di.get(CHILD_APP_INTERNAL_RENDER_TOKEN);
66
+ return {
67
+ ...testAppWrapper,
68
+ childApp: {
69
+ di,
70
+ Component,
71
+ },
72
+ };
73
+ };
74
+
75
+ export { testChildApp };
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var childAppCore = require('@tramvai/child-app-core');
6
+ var core = require('@tramvai/core');
7
+ var moduleChildApp = require('@tramvai/module-child-app');
8
+ var testUnit = require('@tramvai/test-unit');
9
+
10
+ // mock module federation internal stuff
11
+ // @ts-ignore
12
+ global.__webpack_init_sharing__ = async () => { };
13
+ // @ts-ignore
14
+ global.__webpack_share_scopes__ = { default: { react: {}, 'react-dom': {} } };
15
+ // @ts-ignore
16
+ global.setImmediate = (fn) => fn();
17
+ const testChildApp = async (childApp, options = {}) => {
18
+ var _a, _b;
19
+ const testAppInstance = await testUnit.createTestApp({
20
+ ...options,
21
+ modules: [...((_a = options.modules) !== null && _a !== void 0 ? _a : []), moduleChildApp.ChildAppModule],
22
+ providers: [
23
+ ...((_b = options.providers) !== null && _b !== void 0 ? _b : []),
24
+ core.provide({
25
+ provide: childAppCore.CHILD_APP_RESOLVE_BASE_URL_TOKEN,
26
+ useValue: 'http://test',
27
+ }),
28
+ core.provide({
29
+ provide: childAppCore.CHILD_APP_RESOLUTION_CONFIGS_TOKEN,
30
+ multi: true,
31
+ useValue: [
32
+ {
33
+ name: childApp.name,
34
+ byTag: {
35
+ latest: {
36
+ version: 'test',
37
+ },
38
+ },
39
+ },
40
+ ],
41
+ }),
42
+ core.provide({
43
+ // replace loader for child-app as we do not need any logic for loading child-app
44
+ provide: childAppCore.CHILD_APP_LOADER_TOKEN,
45
+ useValue: {
46
+ get(config) {
47
+ if (config.name !== childApp.name) {
48
+ throw new Error(`Cannot resolve child-app with name "${config.name}",
49
+ This test wrapper supports only child-app with name "${childApp.name}"`);
50
+ }
51
+ return childApp;
52
+ },
53
+ async init(_) { },
54
+ async load(_) { },
55
+ },
56
+ }),
57
+ ],
58
+ });
59
+ const testAppWrapper = await testUnit.testApp(testAppInstance.app);
60
+ const appDi = testAppWrapper.app.di;
61
+ await appDi.get(childAppCore.CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN).init();
62
+ const resolveExternalConfig = appDi.get(childAppCore.CHILD_APP_RESOLVE_CONFIG_TOKEN);
63
+ const diManager = appDi.get(childAppCore.CHILD_APP_DI_MANAGER_TOKEN);
64
+ const config = resolveExternalConfig({ name: childApp.name });
65
+ const di = config && diManager.getChildDi(config);
66
+ if (!di) {
67
+ throw new Error('Cannot resolve child-app di');
68
+ }
69
+ const Component = di.get(childAppCore.CHILD_APP_INTERNAL_RENDER_TOKEN);
70
+ return {
71
+ ...testAppWrapper,
72
+ childApp: {
73
+ di,
74
+ Component,
75
+ },
76
+ };
77
+ };
78
+
79
+ exports.testChildApp = testChildApp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/test-child-app",
3
- "version": "2.70.1",
3
+ "version": "2.72.3",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -13,22 +13,21 @@
13
13
  "url": "git@github.com:Tinkoff/tramvai.git"
14
14
  },
15
15
  "scripts": {
16
- "build": "tramvai-build --for-publish",
17
- "watch": "tsc -w",
18
- "build-for-publish": "true"
16
+ "build": "tramvai-build --forPublish --preserveModules",
17
+ "watch": "tsc -w"
19
18
  },
20
19
  "dependencies": {
21
- "@tramvai/child-app-core": "2.70.1",
22
- "@tramvai/core": "2.70.1",
23
- "@tramvai/test-unit": "2.70.1",
20
+ "@tramvai/child-app-core": "2.72.3",
21
+ "@tramvai/core": "2.72.3",
22
+ "@tramvai/test-unit": "2.72.3",
24
23
  "tslib": "^2.4.0"
25
24
  },
26
25
  "devDependencies": {
27
- "@tramvai/react": "2.70.1",
26
+ "@tramvai/react": "2.72.3",
28
27
  "react": "18.2.0"
29
28
  },
30
29
  "peerDependencies": {
31
- "@tramvai/module-child-app": "2.70.1"
30
+ "@tramvai/module-child-app": "2.72.3"
32
31
  },
33
32
  "license": "Apache-2.0",
34
33
  "module": "lib/index.es.js"