@module-federation/data-prefetch
Advanced tools
Comparing version 0.0.0-next-20241009075733 to 0.0.0-next-20241009081924
# @module-federation/data-prefetch | ||
## 0.0.0-next-20241009075733 | ||
## 0.0.0-next-20241009081924 | ||
### Patch Changes | ||
- 5364c07: fix(data-prefetch): apply DataPrefetchPlugin on demand | ||
- 026c308: fix(data-prefetch): set sharedStrategy in build options instead of using runtime plugin | ||
- Updated dependencies [b704f30] | ||
- Updated dependencies [5364c07] | ||
- @module-federation/runtime@0.0.0-next-20241009075733 | ||
- @module-federation/sdk@0.0.0-next-20241009075733 | ||
- @module-federation/runtime@0.0.0-next-20241009081924 | ||
- @module-federation/sdk@0.0.0-next-20241009081924 | ||
@@ -14,0 +11,0 @@ ## 0.6.9 |
@@ -8,3 +8,2 @@ 'use strict'; | ||
var runtimeUtils = require('./runtime-utils.cjs.js'); | ||
var constant = require('./constant.cjs.js'); | ||
require('@module-federation/runtime'); | ||
@@ -45,3 +44,3 @@ | ||
apply(compiler) { | ||
var _this_options_runtimePlugins; | ||
var _this_options_runtimePlugins, _this_options_runtimePlugins1; | ||
const { name, exposes } = this.options; | ||
@@ -59,8 +58,8 @@ if (!exposes) { | ||
const runtimePath = path.resolve(__dirname, './plugin.esm.js'); | ||
const sharedPath = path.resolve(__dirname, './shared.esm.js'); | ||
if (!((_this_options_runtimePlugins = this.options.runtimePlugins) == null ? void 0 : _this_options_runtimePlugins.includes(runtimePath))) { | ||
this.options.runtimePlugins.push(runtimePath); | ||
} | ||
if (this.options.shareStrategy !== constant.SHARED_STRATEGY) { | ||
this.options.shareStrategy = constant.SHARED_STRATEGY; | ||
console.warn(`[Module Federation Data Prefetch]: Your shared strategy is set to '${constant.SHARED_STRATEGY}', this is a necessary condition for data prefetch`); | ||
if (!((_this_options_runtimePlugins1 = this.options.runtimePlugins) == null ? void 0 : _this_options_runtimePlugins1.includes(sharedPath))) { | ||
this.options.runtimePlugins.push(sharedPath); | ||
} | ||
@@ -67,0 +66,0 @@ const encodedName = sdk.encodeName(name); |
@@ -6,3 +6,2 @@ import path from 'path'; | ||
import { b as getPrefetchId } from './runtime-utils.esm.js'; | ||
import { S as SHARED_STRATEGY } from './constant.esm.js'; | ||
import '@module-federation/runtime'; | ||
@@ -43,3 +42,3 @@ | ||
apply(compiler) { | ||
var _this_options_runtimePlugins; | ||
var _this_options_runtimePlugins, _this_options_runtimePlugins1; | ||
const { name, exposes } = this.options; | ||
@@ -57,8 +56,8 @@ if (!exposes) { | ||
const runtimePath = path.resolve(__dirname, './plugin.esm.js'); | ||
const sharedPath = path.resolve(__dirname, './shared.esm.js'); | ||
if (!((_this_options_runtimePlugins = this.options.runtimePlugins) == null ? void 0 : _this_options_runtimePlugins.includes(runtimePath))) { | ||
this.options.runtimePlugins.push(runtimePath); | ||
} | ||
if (this.options.shareStrategy !== SHARED_STRATEGY) { | ||
this.options.shareStrategy = SHARED_STRATEGY; | ||
console.warn(`[Module Federation Data Prefetch]: Your shared strategy is set to '${SHARED_STRATEGY}', this is a necessary condition for data prefetch`); | ||
if (!((_this_options_runtimePlugins1 = this.options.runtimePlugins) == null ? void 0 : _this_options_runtimePlugins1.includes(sharedPath))) { | ||
this.options.runtimePlugins.push(sharedPath); | ||
} | ||
@@ -65,0 +64,0 @@ const encodedName = encodeName(name); |
@@ -9,3 +9,2 @@ 'use strict'; | ||
require('./index.cjs2.js'); | ||
require('./constant.cjs.js'); | ||
@@ -12,0 +11,0 @@ |
@@ -7,2 +7,1 @@ export { M as MFDataPrefetch } from './prefetch.esm.js'; | ||
import './index.esm2.js'; | ||
import './constant.esm.js'; |
@@ -9,2 +9,4 @@ { | ||
"scripts": { | ||
"dev": "cross-env WATCH=true tsup", | ||
"build": "rm -rf dist && tsup", | ||
"test": "jest" | ||
@@ -40,2 +42,7 @@ }, | ||
"types": "./dist/universal.cjs.d.ts" | ||
}, | ||
"./shared": { | ||
"import": "./dist/shared.esm.js", | ||
"require": "./dist/shared.cjs.js", | ||
"types": "./dist/shared/.cjs.d.ts" | ||
} | ||
@@ -57,2 +64,5 @@ }, | ||
], | ||
"shared": [ | ||
"./dist/shared.cjs.d.ts" | ||
], | ||
"babel-plugin": [ | ||
@@ -75,2 +85,3 @@ "./dist/babel.cjs.d.ts" | ||
"@types/react": "~18.0.38", | ||
"esbuild-plugin-replace": "^1.4.0", | ||
"jest": "^29.7.0", | ||
@@ -84,2 +95,3 @@ "jest-environment-jsdom": "^29.7.0", | ||
"ts-jest": "29.0.1", | ||
"tsup": "6.2.0", | ||
"webpack": "5.75.0" | ||
@@ -86,0 +98,0 @@ }, |
@@ -9,7 +9,7 @@ 'use strict'; | ||
var index = require('./index.cjs2.js'); | ||
var constant = require('./constant.cjs.js'); | ||
require('@module-federation/runtime'); | ||
const loadingArray = []; | ||
let sharedFlag = constant.SHARED_STRATEGY; | ||
const strategy = 'loaded-first'; | ||
let sharedFlag = strategy; | ||
// eslint-disable-next-line max-lines-per-function | ||
@@ -32,3 +32,3 @@ const prefetchPlugin = ()=>({ | ||
} | ||
if (sharedFlag !== constant.SHARED_STRATEGY) { | ||
if (sharedFlag !== strategy) { | ||
throw new Error(`[Module Federation Data Prefetch]: If you want to use data prefetch, the shared strategy must be 'loaded-first'`); | ||
@@ -93,3 +93,3 @@ } | ||
} | ||
if (sharedFlag !== constant.SHARED_STRATEGY) { | ||
if (sharedFlag !== strategy) { | ||
throw new Error(`[Module Federation Data Prefetch]: If you want to use data prefetch, the shared strategy must be 'loaded-first'`); | ||
@@ -96,0 +96,0 @@ } |
@@ -5,7 +5,7 @@ import { getResourceUrl } from '@module-federation/sdk'; | ||
import { l as logger } from './index.esm2.js'; | ||
import { S as SHARED_STRATEGY } from './constant.esm.js'; | ||
import '@module-federation/runtime'; | ||
const loadingArray = []; | ||
let sharedFlag = SHARED_STRATEGY; | ||
const strategy = 'loaded-first'; | ||
let sharedFlag = strategy; | ||
// eslint-disable-next-line max-lines-per-function | ||
@@ -28,3 +28,3 @@ const prefetchPlugin = ()=>({ | ||
} | ||
if (sharedFlag !== SHARED_STRATEGY) { | ||
if (sharedFlag !== strategy) { | ||
throw new Error(`[Module Federation Data Prefetch]: If you want to use data prefetch, the shared strategy must be 'loaded-first'`); | ||
@@ -89,3 +89,3 @@ } | ||
} | ||
if (sharedFlag !== SHARED_STRATEGY) { | ||
if (sharedFlag !== strategy) { | ||
throw new Error(`[Module Federation Data Prefetch]: If you want to use data prefetch, the shared strategy must be 'loaded-first'`); | ||
@@ -92,0 +92,0 @@ } |
{ | ||
"name": "@module-federation/data-prefetch", | ||
"description": "Module Federation Data Prefetch", | ||
"version": "0.0.0-next-20241009075733", | ||
"version": "0.0.0-next-20241009081924", | ||
"author": "nieyan <nyqykk@foxmail.com>", | ||
@@ -36,2 +36,7 @@ "homepage": "https://github.com/module-federation/core", | ||
"types": "./dist/universal.cjs.d.ts" | ||
}, | ||
"./shared": { | ||
"import": "./dist/shared.esm.js", | ||
"require": "./dist/shared.cjs.js", | ||
"types": "./dist/shared/.cjs.d.ts" | ||
} | ||
@@ -53,2 +58,5 @@ }, | ||
], | ||
"shared": [ | ||
"./dist/shared.cjs.d.ts" | ||
], | ||
"babel-plugin": [ | ||
@@ -71,2 +79,3 @@ "./dist/babel.cjs.d.ts" | ||
"@types/react": "~18.0.38", | ||
"esbuild-plugin-replace": "^1.4.0", | ||
"jest": "^29.7.0", | ||
@@ -80,2 +89,3 @@ "jest-environment-jsdom": "^29.7.0", | ||
"ts-jest": "29.0.1", | ||
"tsup": "6.2.0", | ||
"webpack": "5.75.0" | ||
@@ -85,8 +95,10 @@ }, | ||
"fs-extra": "9.1.0", | ||
"@module-federation/runtime": "0.0.0-next-20241009075733", | ||
"@module-federation/sdk": "0.0.0-next-20241009075733" | ||
"@module-federation/runtime": "0.0.0-next-20241009081924", | ||
"@module-federation/sdk": "0.0.0-next-20241009081924" | ||
}, | ||
"scripts": { | ||
"dev": "cross-env WATCH=true tsup", | ||
"build": "rm -rf dist && tsup", | ||
"test": "jest" | ||
} | ||
} |
@@ -21,2 +21,3 @@ const copy = require('rollup-plugin-copy'); | ||
plugin: 'packages/data-prefetch/src/plugin.ts', | ||
shared: 'packages/data-prefetch/src/shared/index.ts', | ||
}; | ||
@@ -23,0 +24,0 @@ |
@@ -15,3 +15,2 @@ import path from 'path'; | ||
import { getPrefetchId } from '../common/runtime-utils'; | ||
import { SHARED_STRATEGY } from '../constant'; | ||
@@ -53,10 +52,8 @@ const { RuntimeGlobals, Template } = require( | ||
const runtimePath = path.resolve(__dirname, './plugin.esm.js'); | ||
const sharedPath = path.resolve(__dirname, './shared.esm.js'); | ||
if (!this.options.runtimePlugins?.includes(runtimePath)) { | ||
this.options.runtimePlugins!.push(runtimePath); | ||
} | ||
if (this.options.shareStrategy !== SHARED_STRATEGY) { | ||
this.options.shareStrategy = SHARED_STRATEGY; | ||
console.warn( | ||
`[Module Federation Data Prefetch]: Your shared strategy is set to '${SHARED_STRATEGY}', this is a necessary condition for data prefetch`, | ||
); | ||
if (!this.options.runtimePlugins?.includes(sharedPath)) { | ||
this.options.runtimePlugins!.push(sharedPath); | ||
} | ||
@@ -63,0 +60,0 @@ |
@@ -7,3 +7,2 @@ import type { FederationRuntimePlugin } from '@module-federation/runtime/types'; | ||
import logger from './logger'; | ||
import { SHARED_STRATEGY } from './constant'; | ||
@@ -20,3 +19,4 @@ interface Loading { | ||
const loadingArray: Array<Loading> = []; | ||
let sharedFlag = SHARED_STRATEGY; | ||
const strategy = 'loaded-first'; | ||
let sharedFlag = strategy; | ||
// eslint-disable-next-line max-lines-per-function | ||
@@ -40,3 +40,3 @@ export const prefetchPlugin = (): FederationRuntimePlugin => ({ | ||
} | ||
if (sharedFlag !== SHARED_STRATEGY) { | ||
if (sharedFlag !== strategy) { | ||
throw new Error( | ||
@@ -115,3 +115,3 @@ `[Module Federation Data Prefetch]: If you want to use data prefetch, the shared strategy must be 'loaded-first'`, | ||
if (sharedFlag !== SHARED_STRATEGY) { | ||
if (sharedFlag !== strategy) { | ||
throw new Error( | ||
@@ -118,0 +118,0 @@ `[Module Federation Data Prefetch]: If you want to use data prefetch, the shared strategy must be 'loaded-first'`, |
111305
82
2734
16
+ Added@module-federation/runtime@0.0.0-next-20241009081924(transitive)
+ Added@module-federation/sdk@0.0.0-next-20241009081924(transitive)
- Removed@module-federation/runtime@0.0.0-next-20241009075733(transitive)
- Removed@module-federation/sdk@0.0.0-next-20241009075733(transitive)