@module-federation/data-prefetch 0.0.0-next-20241010084324 → 0.0.0-next-20241011070539

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 (87) hide show
  1. package/.swcrc +29 -0
  2. package/CHANGELOG.md +12 -4
  3. package/LICENSE +1 -1
  4. package/dist/LICENSE +21 -0
  5. package/dist/babel.cjs.d.ts +2 -0
  6. package/dist/babel.cjs.js +50 -0
  7. package/dist/babel.esm.d.ts +2 -0
  8. package/dist/babel.esm.js +48 -0
  9. package/dist/cli.cjs.d.ts +1 -0
  10. package/dist/cli.cjs.js +155 -0
  11. package/dist/cli.esm.d.ts +1 -0
  12. package/dist/cli.esm.js +152 -0
  13. package/dist/index.cjs.d.ts +1 -0
  14. package/dist/index.cjs.js +13 -0
  15. package/dist/index.cjs2.js +7 -0
  16. package/dist/index.esm.d.ts +1 -0
  17. package/dist/index.esm.js +6 -0
  18. package/dist/index.esm2.js +5 -0
  19. package/dist/package.json +100 -0
  20. package/dist/plugin.cjs.d.ts +2 -0
  21. package/dist/plugin.cjs.js +159 -0
  22. package/dist/plugin.esm.d.ts +2 -0
  23. package/dist/plugin.esm.js +154 -0
  24. package/dist/polyfills.cjs.js +14 -0
  25. package/dist/polyfills.esm.js +12 -0
  26. package/dist/prefetch.cjs.js +142 -0
  27. package/dist/prefetch.esm.js +140 -0
  28. package/dist/react.cjs.d.ts +1 -0
  29. package/dist/react.cjs.js +77 -0
  30. package/dist/react.esm.d.ts +1 -0
  31. package/dist/react.esm.js +75 -0
  32. package/dist/runtime-utils.cjs.js +27 -0
  33. package/dist/runtime-utils.esm.js +22 -0
  34. package/dist/shared.cjs.d.ts +2 -0
  35. package/dist/shared.cjs.js +24 -0
  36. package/dist/shared.esm.d.ts +2 -0
  37. package/dist/shared.esm.js +22 -0
  38. package/dist/{cli → src/cli}/babel.d.ts +2 -4
  39. package/dist/{cli → src/cli}/index.d.ts +5 -8
  40. package/dist/src/common/constant.d.ts +1 -0
  41. package/dist/src/common/index.d.ts +1 -0
  42. package/dist/src/common/node-utils.d.ts +2 -0
  43. package/dist/src/common/runtime-utils.d.ts +5 -0
  44. package/dist/src/index.d.ts +2 -0
  45. package/dist/src/logger/index.d.ts +3 -0
  46. package/dist/src/plugin.d.ts +3 -0
  47. package/dist/{prefetch-c08be471.d.ts → src/prefetch.d.ts} +4 -6
  48. package/dist/src/react/hooks.d.ts +11 -0
  49. package/dist/src/react/index.d.ts +1 -0
  50. package/dist/src/react/utils.d.ts +1 -0
  51. package/dist/src/shared/index.d.ts +3 -0
  52. package/dist/src/universal/index.d.ts +2 -0
  53. package/dist/universal.cjs.d.ts +1 -0
  54. package/dist/universal.cjs.js +29 -0
  55. package/dist/universal.esm.d.ts +1 -0
  56. package/dist/universal.esm.js +27 -0
  57. package/package.json +33 -30
  58. package/project.json +48 -6
  59. package/rollup.config.js +46 -0
  60. package/src/cli/index.ts +2 -2
  61. package/tsconfig.json +1 -1
  62. package/tsconfig.lib.json +10 -0
  63. package/dist/cli/babel.js +0 -84
  64. package/dist/cli/index.js +0 -207
  65. package/dist/esm/chunk-AJPO2B2T.js +0 -30
  66. package/dist/esm/chunk-BGNOVRH5.js +0 -166
  67. package/dist/esm/chunk-EZUCZHGV.js +0 -11
  68. package/dist/esm/chunk-ISF7VMBW.js +0 -156
  69. package/dist/esm/chunk-OCDMSRMZ.js +0 -32
  70. package/dist/esm/chunk-TTJJJ2WZ.js +0 -7
  71. package/dist/esm/cli/babel.js +0 -57
  72. package/dist/esm/cli/index.js +0 -180
  73. package/dist/esm/index.js +0 -13
  74. package/dist/esm/plugin.js +0 -12
  75. package/dist/esm/react/index.js +0 -94
  76. package/dist/esm/shared/index.js +0 -27
  77. package/dist/esm/universal/index.js +0 -9
  78. package/dist/index.d.ts +0 -5
  79. package/dist/index.js +0 -351
  80. package/dist/plugin.d.ts +0 -5
  81. package/dist/plugin.js +0 -347
  82. package/dist/react/index.d.ts +0 -16
  83. package/dist/react/index.js +0 -287
  84. package/dist/shared/index.d.ts +0 -5
  85. package/dist/shared/index.js +0 -48
  86. package/dist/universal/index.d.ts +0 -8
  87. package/dist/universal/index.js +0 -205
@@ -0,0 +1,77 @@
1
+ 'use strict';
2
+
3
+ var polyfills = require('./polyfills.cjs.js');
4
+ var react = require('react');
5
+ var index = require('./index.cjs2.js');
6
+ var prefetch = require('./prefetch.cjs.js');
7
+ var universal = require('./universal.cjs.js');
8
+ var runtimeUtils = require('./runtime-utils.cjs.js');
9
+ require('@module-federation/sdk');
10
+ require('@module-federation/runtime');
11
+
12
+ const useFirstMounted = ()=>{
13
+ const ref = react.useRef(true);
14
+ react.useEffect(()=>{
15
+ ref.current = false;
16
+ }, []);
17
+ return ref.current;
18
+ };
19
+
20
+ const usePrefetch = (options)=>{
21
+ const isFirstMounted = useFirstMounted();
22
+ if (isFirstMounted) {
23
+ const startTiming = performance.now();
24
+ index.logger.info(`2. Start Get Prefetch Data: ${options.id} - ${options.functionId || 'default'} - ${startTiming}`);
25
+ }
26
+ const { id, functionId, deferId } = options;
27
+ const prefetchInfo = {
28
+ id,
29
+ functionId
30
+ };
31
+ const mfScope = runtimeUtils.getScope();
32
+ let state;
33
+ const prefetchResult = universal.prefetch(options);
34
+ if (deferId) {
35
+ if (prefetchResult instanceof Promise) {
36
+ state = prefetchResult.then((deferredData)=>deferredData.data[deferId]);
37
+ } else {
38
+ state = prefetchResult.data[deferId];
39
+ }
40
+ } else {
41
+ state = prefetchResult;
42
+ }
43
+ const [prefetchState, setPrefetchState] = react.useState(state);
44
+ const prefetchInstance = prefetch.MFDataPrefetch.getInstance(mfScope);
45
+ react.useEffect(()=>{
46
+ const useEffectTiming = performance.now();
47
+ index.logger.info(`3. Start Execute UseEffect: ${options.id} - ${options.functionId || 'default'} - ${useEffectTiming}`);
48
+ return ()=>{
49
+ prefetchInstance == null ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
50
+ };
51
+ }, []);
52
+ const refreshExecutor = (refetchParams)=>{
53
+ const refetchOptions = polyfills._extends({}, options);
54
+ if (refetchParams) {
55
+ refetchOptions.refetchParams = refetchParams;
56
+ }
57
+ prefetchInstance == null ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
58
+ const newVal = universal.prefetch(refetchOptions);
59
+ let newState;
60
+ if (deferId) {
61
+ if (newVal instanceof Promise) {
62
+ newState = newVal.then((deferredData)=>deferredData.data[deferId]);
63
+ } else {
64
+ newState = newVal.data[deferId];
65
+ }
66
+ } else {
67
+ newState = newVal;
68
+ }
69
+ setPrefetchState(newState);
70
+ };
71
+ return [
72
+ prefetchState,
73
+ refreshExecutor
74
+ ];
75
+ };
76
+
77
+ exports.usePrefetch = usePrefetch;
@@ -0,0 +1 @@
1
+ export * from "./src/react/index";
@@ -0,0 +1,75 @@
1
+ import { _ as _extends } from './polyfills.esm.js';
2
+ import { useRef, useEffect, useState } from 'react';
3
+ import { l as logger } from './index.esm2.js';
4
+ import { M as MFDataPrefetch } from './prefetch.esm.js';
5
+ import { prefetch } from './universal.esm.js';
6
+ import { g as getScope } from './runtime-utils.esm.js';
7
+ import '@module-federation/sdk';
8
+ import '@module-federation/runtime';
9
+
10
+ const useFirstMounted = ()=>{
11
+ const ref = useRef(true);
12
+ useEffect(()=>{
13
+ ref.current = false;
14
+ }, []);
15
+ return ref.current;
16
+ };
17
+
18
+ const usePrefetch = (options)=>{
19
+ const isFirstMounted = useFirstMounted();
20
+ if (isFirstMounted) {
21
+ const startTiming = performance.now();
22
+ logger.info(`2. Start Get Prefetch Data: ${options.id} - ${options.functionId || 'default'} - ${startTiming}`);
23
+ }
24
+ const { id, functionId, deferId } = options;
25
+ const prefetchInfo = {
26
+ id,
27
+ functionId
28
+ };
29
+ const mfScope = getScope();
30
+ let state;
31
+ const prefetchResult = prefetch(options);
32
+ if (deferId) {
33
+ if (prefetchResult instanceof Promise) {
34
+ state = prefetchResult.then((deferredData)=>deferredData.data[deferId]);
35
+ } else {
36
+ state = prefetchResult.data[deferId];
37
+ }
38
+ } else {
39
+ state = prefetchResult;
40
+ }
41
+ const [prefetchState, setPrefetchState] = useState(state);
42
+ const prefetchInstance = MFDataPrefetch.getInstance(mfScope);
43
+ useEffect(()=>{
44
+ const useEffectTiming = performance.now();
45
+ logger.info(`3. Start Execute UseEffect: ${options.id} - ${options.functionId || 'default'} - ${useEffectTiming}`);
46
+ return ()=>{
47
+ prefetchInstance == null ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
48
+ };
49
+ }, []);
50
+ const refreshExecutor = (refetchParams)=>{
51
+ const refetchOptions = _extends({}, options);
52
+ if (refetchParams) {
53
+ refetchOptions.refetchParams = refetchParams;
54
+ }
55
+ prefetchInstance == null ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
56
+ const newVal = prefetch(refetchOptions);
57
+ let newState;
58
+ if (deferId) {
59
+ if (newVal instanceof Promise) {
60
+ newState = newVal.then((deferredData)=>deferredData.data[deferId]);
61
+ } else {
62
+ newState = newVal.data[deferId];
63
+ }
64
+ } else {
65
+ newState = newVal;
66
+ }
67
+ setPrefetchState(newState);
68
+ };
69
+ return [
70
+ prefetchState,
71
+ refreshExecutor
72
+ ];
73
+ };
74
+
75
+ export { usePrefetch };
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var runtime = require('@module-federation/runtime');
4
+ var sdk = require('@module-federation/sdk');
5
+
6
+ const getScope = ()=>{
7
+ return runtime.getInstance().options.name;
8
+ };
9
+ const getPrefetchId = (id)=>sdk.encodeName(`${id}/${sdk.MFPrefetchCommon.identifier}`);
10
+ const compatGetPrefetchId = (id)=>sdk.encodeName(`${id}/VmokPrefetch`);
11
+ const getSignalFromManifest = (remoteSnapshot)=>{
12
+ if (!remoteSnapshot) {
13
+ return false;
14
+ }
15
+ if (!('prefetchEntry' in remoteSnapshot) && !('prefetchInterface' in remoteSnapshot)) {
16
+ return false;
17
+ }
18
+ if (!remoteSnapshot.prefetchEntry && !remoteSnapshot.prefetchInterface) {
19
+ return false;
20
+ }
21
+ return true;
22
+ };
23
+
24
+ exports.compatGetPrefetchId = compatGetPrefetchId;
25
+ exports.getPrefetchId = getPrefetchId;
26
+ exports.getScope = getScope;
27
+ exports.getSignalFromManifest = getSignalFromManifest;
@@ -0,0 +1,22 @@
1
+ import { getInstance } from '@module-federation/runtime';
2
+ import { encodeName, MFPrefetchCommon } from '@module-federation/sdk';
3
+
4
+ const getScope = ()=>{
5
+ return getInstance().options.name;
6
+ };
7
+ const getPrefetchId = (id)=>encodeName(`${id}/${MFPrefetchCommon.identifier}`);
8
+ const compatGetPrefetchId = (id)=>encodeName(`${id}/VmokPrefetch`);
9
+ const getSignalFromManifest = (remoteSnapshot)=>{
10
+ if (!remoteSnapshot) {
11
+ return false;
12
+ }
13
+ if (!('prefetchEntry' in remoteSnapshot) && !('prefetchInterface' in remoteSnapshot)) {
14
+ return false;
15
+ }
16
+ if (!remoteSnapshot.prefetchEntry && !remoteSnapshot.prefetchInterface) {
17
+ return false;
18
+ }
19
+ return true;
20
+ };
21
+
22
+ export { getSignalFromManifest as a, getPrefetchId as b, compatGetPrefetchId as c, getScope as g };
@@ -0,0 +1,2 @@
1
+ export * from "./src/shared/index";
2
+ export { default } from "./src/shared/index";
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ const sharedStrategy = ()=>({
4
+ name: 'shared-strategy',
5
+ beforeInit (args) {
6
+ const { userOptions } = args;
7
+ const shared = userOptions.shared;
8
+ if (shared) {
9
+ Object.keys(shared).forEach((sharedKey)=>{
10
+ const sharedConfigs = shared[sharedKey];
11
+ const arraySharedConfigs = Array.isArray(sharedConfigs) ? sharedConfigs : [
12
+ sharedConfigs
13
+ ];
14
+ arraySharedConfigs.forEach((s)=>{
15
+ s.strategy = 'loaded-first';
16
+ });
17
+ });
18
+ console.warn(`[Module Federation Data Prefetch]: Your shared strategy is set to 'loaded-first', this is a necessary condition for data prefetch`);
19
+ }
20
+ return args;
21
+ }
22
+ });
23
+
24
+ module.exports = sharedStrategy;
@@ -0,0 +1,2 @@
1
+ export * from "./src/shared/index";
2
+ export { default } from "./src/shared/index";
@@ -0,0 +1,22 @@
1
+ const sharedStrategy = ()=>({
2
+ name: 'shared-strategy',
3
+ beforeInit (args) {
4
+ const { userOptions } = args;
5
+ const shared = userOptions.shared;
6
+ if (shared) {
7
+ Object.keys(shared).forEach((sharedKey)=>{
8
+ const sharedConfigs = shared[sharedKey];
9
+ const arraySharedConfigs = Array.isArray(sharedConfigs) ? sharedConfigs : [
10
+ sharedConfigs
11
+ ];
12
+ arraySharedConfigs.forEach((s)=>{
13
+ s.strategy = 'loaded-first';
14
+ });
15
+ });
16
+ console.warn(`[Module Federation Data Prefetch]: Your shared strategy is set to 'loaded-first', this is a necessary condition for data prefetch`);
17
+ }
18
+ return args;
19
+ }
20
+ });
21
+
22
+ export { sharedStrategy as default };
@@ -1,5 +1,4 @@
1
- import { moduleFederationPlugin } from '@module-federation/sdk';
2
-
1
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
3
2
  interface BabelPluginOptions {
4
3
  hook_id: string;
5
4
  import_pkg: string;
@@ -35,5 +34,4 @@ declare const _default: (babel: {
35
34
  }): void;
36
35
  };
37
36
  };
38
-
39
- export { _default as default };
37
+ export default _default;
@@ -1,10 +1,8 @@
1
- import * as webpack from 'webpack';
2
- import { WebpackPluginInstance, Compiler } from 'webpack';
3
1
  import { moduleFederationPlugin } from '@module-federation/sdk';
4
-
5
- declare const RuntimeGlobals: typeof webpack.RuntimeGlobals;
6
- declare function getFederationGlobalScope(runtimeGlobals: typeof RuntimeGlobals): string;
7
- declare class PrefetchPlugin implements WebpackPluginInstance {
2
+ import type { Compiler, WebpackPluginInstance } from 'webpack';
3
+ declare const RuntimeGlobals: typeof import("webpack").RuntimeGlobals;
4
+ export declare function getFederationGlobalScope(runtimeGlobals: typeof RuntimeGlobals): string;
5
+ export declare class PrefetchPlugin implements WebpackPluginInstance {
8
6
  options: moduleFederationPlugin.ModuleFederationPluginOptions;
9
7
  private _reWriteExports;
10
8
  constructor(options: moduleFederationPlugin.ModuleFederationPluginOptions);
@@ -15,5 +13,4 @@ declare class PrefetchPlugin implements WebpackPluginInstance {
15
13
  static setRemoteIdentifier(): string;
16
14
  static removeRemoteIdentifier(): string;
17
15
  }
18
-
19
- export { PrefetchPlugin, getFederationGlobalScope };
16
+ export {};
@@ -0,0 +1 @@
1
+ export declare const TEMP_DIR = ".mf";
@@ -0,0 +1 @@
1
+ export * from './constant';
@@ -0,0 +1,2 @@
1
+ export declare const fileExistsWithCaseSync: (filepath: string) => boolean;
2
+ export declare const fixPrefetchPath: (exposePath: string) => Array<string>;
@@ -0,0 +1,5 @@
1
+ import { ModuleInfo } from '@module-federation/sdk';
2
+ export declare const getScope: () => string;
3
+ export declare const getPrefetchId: (id: string) => string;
4
+ export declare const compatGetPrefetchId: (id: string) => string;
5
+ export declare const getSignalFromManifest: (remoteSnapshot: ModuleInfo) => boolean;
@@ -0,0 +1,2 @@
1
+ export * from './prefetch';
2
+ export * from './plugin';
@@ -0,0 +1,3 @@
1
+ import { Logger } from '@module-federation/sdk';
2
+ declare const _default: Logger;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import type { FederationRuntimePlugin } from '@module-federation/runtime/types';
2
+ export declare const prefetchPlugin: () => FederationRuntimePlugin;
3
+ export default prefetchPlugin;
@@ -1,7 +1,6 @@
1
1
  import { FederationHost } from '@module-federation/runtime';
2
2
  import { ModuleInfo } from '@module-federation/sdk';
3
3
  import { Remote } from '@module-federation/runtime/types';
4
-
5
4
  declare module '@module-federation/runtime' {
6
5
  interface Federation {
7
6
  __PREFETCH__: {
@@ -12,19 +11,19 @@ declare module '@module-federation/runtime' {
12
11
  }
13
12
  }
14
13
  type PrefetchExports = Record<string, any>;
15
- interface DataPrefetchOptions {
14
+ export interface DataPrefetchOptions {
16
15
  name: string;
17
16
  remote?: Remote;
18
17
  origin?: FederationHost;
19
18
  remoteSnapshot?: ModuleInfo;
20
19
  }
21
- interface prefetchOptions {
20
+ export interface prefetchOptions {
22
21
  id: string;
23
22
  functionId?: string;
24
23
  cacheStrategy?: () => boolean;
25
24
  refetchParams?: any;
26
25
  }
27
- declare class MFDataPrefetch {
26
+ export declare class MFDataPrefetch {
28
27
  prefetchMemory: Map<string, Promise<any>>;
29
28
  recordOutdate: Record<string, Record<string, boolean>>;
30
29
  private _exports;
@@ -41,5 +40,4 @@ declare class MFDataPrefetch {
41
40
  markOutdate(markOptions: Omit<prefetchOptions, 'cacheStrategy'>, isOutdate: boolean): void;
42
41
  checkOutdate(outdateOptions: prefetchOptions): boolean;
43
42
  }
44
-
45
- export { DataPrefetchOptions as D, MFDataPrefetch as M, prefetchOptions as p };
43
+ export {};
@@ -0,0 +1,11 @@
1
+ import { type prefetchOptions } from '../prefetch';
2
+ type refetchParams = any;
3
+ type prefetchReturnType<T> = [
4
+ Promise<T>,
5
+ (refetchParams?: refetchParams) => void
6
+ ];
7
+ type UsePrefetchOptions = prefetchOptions & {
8
+ deferId?: string;
9
+ };
10
+ export declare const usePrefetch: <T>(options: UsePrefetchOptions) => prefetchReturnType<T>;
11
+ export {};
@@ -0,0 +1 @@
1
+ export * from './hooks';
@@ -0,0 +1 @@
1
+ export declare const useFirstMounted: () => boolean;
@@ -0,0 +1,3 @@
1
+ import type { FederationRuntimePlugin } from '@module-federation/runtime';
2
+ declare const sharedStrategy: () => FederationRuntimePlugin;
3
+ export default sharedStrategy;
@@ -0,0 +1,2 @@
1
+ import { type prefetchOptions } from '../prefetch';
2
+ export declare function prefetch(options: prefetchOptions): Promise<any>;
@@ -0,0 +1 @@
1
+ export * from "./src/universal/index";
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ var prefetch$1 = require('./prefetch.cjs.js');
4
+ var runtimeUtils = require('./runtime-utils.cjs.js');
5
+ require('@module-federation/runtime');
6
+ require('@module-federation/sdk');
7
+
8
+ function prefetch(options) {
9
+ const { id, functionId = 'default' } = options;
10
+ const mfScope = runtimeUtils.getScope();
11
+ const prefetchInstance = prefetch$1.MFDataPrefetch.getInstance(mfScope) || new prefetch$1.MFDataPrefetch({
12
+ name: mfScope
13
+ });
14
+ const res = prefetchInstance.getProjectExports();
15
+ if (res instanceof Promise) {
16
+ const promise = res.then(()=>{
17
+ const result = prefetchInstance.prefetch(options);
18
+ prefetchInstance.memorize(id + functionId, result);
19
+ return result;
20
+ });
21
+ return promise;
22
+ } else {
23
+ const result = prefetchInstance.prefetch(options);
24
+ prefetchInstance.memorize(id + functionId, result);
25
+ return result;
26
+ }
27
+ }
28
+
29
+ exports.prefetch = prefetch;
@@ -0,0 +1 @@
1
+ export * from "./src/universal/index";
@@ -0,0 +1,27 @@
1
+ import { M as MFDataPrefetch } from './prefetch.esm.js';
2
+ import { g as getScope } from './runtime-utils.esm.js';
3
+ import '@module-federation/runtime';
4
+ import '@module-federation/sdk';
5
+
6
+ function prefetch(options) {
7
+ const { id, functionId = 'default' } = options;
8
+ const mfScope = getScope();
9
+ const prefetchInstance = MFDataPrefetch.getInstance(mfScope) || new MFDataPrefetch({
10
+ name: mfScope
11
+ });
12
+ const res = prefetchInstance.getProjectExports();
13
+ if (res instanceof Promise) {
14
+ const promise = res.then(()=>{
15
+ const result = prefetchInstance.prefetch(options);
16
+ prefetchInstance.memorize(id + functionId, result);
17
+ return result;
18
+ });
19
+ return promise;
20
+ } else {
21
+ const result = prefetchInstance.prefetch(options);
22
+ prefetchInstance.memorize(id + functionId, result);
23
+ return result;
24
+ }
25
+ }
26
+
27
+ export { prefetch };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@module-federation/data-prefetch",
3
3
  "description": "Module Federation Data Prefetch",
4
- "version": "0.0.0-next-20241010084324",
4
+ "version": "0.0.0-next-20241011070539",
5
5
  "author": "nieyan <nyqykk@foxmail.com>",
6
6
  "homepage": "https://github.com/module-federation/core",
7
7
  "license": "MIT",
@@ -10,57 +10,60 @@
10
10
  },
11
11
  "exports": {
12
12
  ".": {
13
- "import": "./dist/esm/index.js",
14
- "require": "./dist/index.js",
15
- "types": "./dist/index.d.ts"
13
+ "import": "./dist/index.esm.js",
14
+ "require": "./dist/index.cjs",
15
+ "types": "./dist/index.cjs.d.ts"
16
16
  },
17
17
  "./react": {
18
- "import": "./dist/esm/react/index.js",
19
- "require": "./dist/react/index.js",
20
- "types": "./dist/react/index.d.ts"
18
+ "import": "./dist/react.esm.js",
19
+ "require": "./dist/react.cjs.js",
20
+ "types": "./dist/react.cjs.d.ts"
21
21
  },
22
22
  "./cli": {
23
- "import": "./dist/esm/cli/index.js",
24
- "require": "./dist/cli/index.js",
25
- "types": "./dist/cli/index.d.ts"
23
+ "import": "./dist/cli.esm.js",
24
+ "require": "./dist/cli.cjs.js",
25
+ "types": "./dist/cli.cjs.d.ts"
26
26
  },
27
27
  "./babel-plugin": {
28
- "import": "./dist/esm/cli/babel.js",
29
- "require": "./dist/cli/babel.js",
30
- "types": "./dist/cli/babel.d.ts"
28
+ "import": "./dist/babel.esm.js",
29
+ "require": "./dist/babel.cjs.js",
30
+ "types": "./dist/babel.cjs.d.ts"
31
31
  },
32
32
  "./universal": {
33
- "import": "./dist/esm/universal/index.js",
34
- "require": "./dist/universal/index.js",
35
- "types": "./dist/universal/index.d.ts"
33
+ "import": "./dist/universal.esm.js",
34
+ "require": "./dist/universal.cjs.js",
35
+ "types": "./dist/universal.cjs.d.ts"
36
36
  },
37
37
  "./shared": {
38
- "import": "./dist/esm/shared/index.js",
39
- "require": "./dist/shared/index.js",
40
- "types": "./dist/shared/index.d.ts"
38
+ "import": "./dist/shared.esm.js",
39
+ "require": "./dist/shared.cjs.js",
40
+ "types": "./dist/shared/.cjs.d.ts"
41
41
  }
42
42
  },
43
43
  "typesVersions": {
44
44
  "*": {
45
45
  ".": [
46
- "./dist/index.d.ts"
46
+ "./dist/index.cjs.d.ts"
47
47
  ],
48
48
  "react": [
49
- "./dist/react/index.d.ts"
49
+ "./dist/react.cjs.d.ts"
50
50
  ],
51
51
  "cli": [
52
- "./dist/cli/index.d.ts"
52
+ "./dist/cli.cjs.d.ts"
53
53
  ],
54
54
  "universal": [
55
- "./dist/universal/index.d.ts"
55
+ "./dist/universal.cjs.d.ts"
56
56
  ],
57
57
  "shared": [
58
- "./dist/shared/index.d.ts"
58
+ "./dist/shared.cjs.d.ts"
59
+ ],
60
+ "babel-plugin": [
61
+ "./dist/babel.cjs.d.ts"
59
62
  ]
60
63
  }
61
64
  },
62
- "main": "dist/index.js",
63
- "module": "dist/esm/index.js",
65
+ "main": "dist/index.cjs",
66
+ "module": "dist/index.esm.js",
64
67
  "peerDependencies": {
65
68
  "react": ">=16.9.0",
66
69
  "react-dom": ">=16.9.0"
@@ -75,8 +78,8 @@
75
78
  "jest": "^29.7.0",
76
79
  "jest-environment-jsdom": "^29.7.0",
77
80
  "minimist": "^1.2.8",
78
- "react": "^18.2.0",
79
- "react-dom": "^18.2.0",
81
+ "react": "^18.3.1",
82
+ "react-dom": "^18.3.1",
80
83
  "react-router": "^6.21.3",
81
84
  "react-test-renderer": "^18.2.0",
82
85
  "ts-jest": "29.0.1",
@@ -85,8 +88,8 @@
85
88
  },
86
89
  "dependencies": {
87
90
  "fs-extra": "9.1.0",
88
- "@module-federation/sdk": "0.0.0-next-20241010084324",
89
- "@module-federation/runtime": "0.0.0-next-20241010084324"
91
+ "@module-federation/runtime": "0.0.0-next-20241011070539",
92
+ "@module-federation/sdk": "0.0.0-next-20241011070539"
90
93
  },
91
94
  "scripts": {
92
95
  "dev": "cross-env WATCH=true tsup",
package/project.json CHANGED
@@ -1,21 +1,63 @@
1
1
  {
2
- "name": "module-federation/data-prefetch",
2
+ "name": "data-prefetch",
3
3
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
4
  "sourceRoot": "packages/data-prefetch/src",
5
5
  "projectType": "library",
6
+ "tags": ["type:pkg"],
6
7
  "targets": {
7
8
  "build": {
8
- "executor": "nx:run-commands",
9
+ "executor": "@nx/rollup:rollup",
10
+ "outputs": ["{options.outputPath}"],
9
11
  "options": {
10
- "commands": ["npm run build --prefix packages/data-prefetch"]
12
+ "outputPath": "packages/data-prefetch/dist",
13
+ "main": "packages/data-prefetch/src/index.ts",
14
+ "tsConfig": "packages/data-prefetch/tsconfig.lib.json",
15
+ "assets": [],
16
+ "project": "packages/data-prefetch/package.json",
17
+ "rollupConfig": "packages/data-prefetch/rollup.config.js",
18
+ "compiler": "swc",
19
+ "format": ["cjs", "esm"]
11
20
  }
12
21
  },
13
22
  "test": {
23
+ "executor": "@nx/jest:jest",
24
+ "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
25
+ "options": {
26
+ "jestConfig": "packages/data-prefetch/jest.config.js",
27
+ "passWithNoTests": true
28
+ },
29
+ "configurations": {
30
+ "ci": {
31
+ "ci": true,
32
+ "codeCoverage": true
33
+ }
34
+ }
35
+ },
36
+ "lint": {
37
+ "executor": "@nx/linter:eslint",
38
+ "outputs": ["{options.outputFile}"],
39
+ "options": {
40
+ "lintFilePatterns": [
41
+ "packages/data-prefetch/**/*.ts",
42
+ "packages/data-prefetch/package.json"
43
+ ]
44
+ }
45
+ },
46
+ "pre-release": {
14
47
  "executor": "nx:run-commands",
15
48
  "options": {
16
- "commands": ["npm run test --prefix packages/data-prefetch"]
49
+ "parallel": false,
50
+ "commands": [
51
+ {
52
+ "command": "nx run data-prefetch:test",
53
+ "forwardAllArgs": false
54
+ },
55
+ {
56
+ "command": "nx run data-prefetch:build",
57
+ "forwardAllArgs": false
58
+ }
59
+ ]
17
60
  }
18
61
  }
19
- },
20
- "tags": ["type:pkg"]
62
+ }
21
63
  }