@module-federation/data-prefetch
Advanced tools
Comparing version 0.0.0-next-20241014085010 to 0.0.0-next-20241014092946
# @module-federation/data-prefetch | ||
## 0.0.0-next-20241014085010 | ||
## 0.0.0-next-20241014092946 | ||
### Patch Changes | ||
- Updated dependencies [ea6d417] | ||
- Updated dependencies [d5a3072] | ||
- @module-federation/runtime@0.0.0-next-20241014092946 | ||
- @module-federation/sdk@0.0.0-next-20241014092946 | ||
## 0.6.10 | ||
### Patch Changes | ||
- 22a3b83: fix(data-prefetch): apply DataPrefetchPlugin on demand | ||
- 22a3b83: fix(data-prefetch): set sharedStrategy in build options instead of using runtime plugin | ||
- Updated dependencies [b704f30] | ||
- Updated dependencies [22a3b83] | ||
- @module-federation/runtime@0.6.10 | ||
- @module-federation/sdk@0.6.10 | ||
## 0.6.9 | ||
### Patch Changes | ||
- @module-federation/runtime@0.6.9 | ||
- @module-federation/sdk@0.6.9 | ||
## 0.6.8 | ||
### Patch Changes | ||
- Updated dependencies [32db0ac] | ||
- Updated dependencies [32db0ac] | ||
- @module-federation/sdk@0.0.0-next-20241014085010 | ||
- @module-federation/runtime@0.0.0-next-20241014085010 | ||
- Updated dependencies [6c5f444] | ||
- Updated dependencies [fac6ecf] | ||
- @module-federation/sdk@0.6.8 | ||
- @module-federation/runtime@0.6.8 | ||
@@ -12,0 +41,0 @@ ## 0.6.7 |
@@ -8,2 +8,3 @@ 'use strict'; | ||
var runtimeUtils = require('./runtime-utils.cjs.js'); | ||
var constant = require('./constant.cjs.js'); | ||
require('@module-federation/runtime'); | ||
@@ -44,3 +45,3 @@ | ||
apply(compiler) { | ||
var _this_options_runtimePlugins, _this_options_runtimePlugins1; | ||
var _this_options_runtimePlugins; | ||
const { name, exposes } = this.options; | ||
@@ -58,8 +59,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_runtimePlugins1 = this.options.runtimePlugins) == null ? void 0 : _this_options_runtimePlugins1.includes(sharedPath))) { | ||
this.options.runtimePlugins.push(sharedPath); | ||
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`); | ||
} | ||
@@ -66,0 +67,0 @@ const encodedName = sdk.encodeName(name); |
@@ -6,2 +6,3 @@ 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'; | ||
@@ -42,3 +43,3 @@ | ||
apply(compiler) { | ||
var _this_options_runtimePlugins, _this_options_runtimePlugins1; | ||
var _this_options_runtimePlugins; | ||
const { name, exposes } = this.options; | ||
@@ -56,8 +57,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_runtimePlugins1 = this.options.runtimePlugins) == null ? void 0 : _this_options_runtimePlugins1.includes(sharedPath))) { | ||
this.options.runtimePlugins.push(sharedPath); | ||
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`); | ||
} | ||
@@ -64,0 +65,0 @@ const encodedName = encodeName(name); |
@@ -9,2 +9,3 @@ 'use strict'; | ||
require('./index.cjs2.js'); | ||
require('./constant.cjs.js'); | ||
@@ -11,0 +12,0 @@ |
@@ -7,1 +7,2 @@ export { M as MFDataPrefetch } from './prefetch.esm.js'; | ||
import './index.esm2.js'; | ||
import './constant.esm.js'; |
{ | ||
"name": "@module-federation/data-prefetch", | ||
"description": "Module Federation Data Prefetch", | ||
"version": "0.6.7", | ||
"version": "0.6.10", | ||
"author": "nieyan <nyqykk@foxmail.com>", | ||
@@ -9,4 +9,2 @@ "homepage": "https://github.com/module-federation/core", | ||
"scripts": { | ||
"dev": "cross-env WATCH=true tsup", | ||
"build": "rm -rf dist && tsup", | ||
"test": "jest" | ||
@@ -42,7 +40,2 @@ }, | ||
"types": "./dist/universal.cjs.d.ts" | ||
}, | ||
"./shared": { | ||
"import": "./dist/shared.esm.js", | ||
"require": "./dist/shared.cjs.js", | ||
"types": "./dist/shared/.cjs.d.ts" | ||
} | ||
@@ -64,5 +57,2 @@ }, | ||
], | ||
"shared": [ | ||
"./dist/shared.cjs.d.ts" | ||
], | ||
"babel-plugin": [ | ||
@@ -85,3 +75,2 @@ "./dist/babel.cjs.d.ts" | ||
"@types/react": "~18.0.38", | ||
"esbuild-plugin-replace": "^1.4.0", | ||
"jest": "^29.7.0", | ||
@@ -95,3 +84,2 @@ "jest-environment-jsdom": "^29.7.0", | ||
"ts-jest": "29.0.1", | ||
"tsup": "6.2.0", | ||
"webpack": "5.75.0" | ||
@@ -98,0 +86,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 = []; | ||
const strategy = 'loaded-first'; | ||
let sharedFlag = strategy; | ||
let sharedFlag = constant.SHARED_STRATEGY; | ||
// eslint-disable-next-line max-lines-per-function | ||
@@ -32,3 +32,3 @@ const prefetchPlugin = ()=>({ | ||
} | ||
if (sharedFlag !== strategy) { | ||
if (sharedFlag !== constant.SHARED_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 !== strategy) { | ||
if (sharedFlag !== constant.SHARED_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 = []; | ||
const strategy = 'loaded-first'; | ||
let sharedFlag = strategy; | ||
let sharedFlag = SHARED_STRATEGY; | ||
// eslint-disable-next-line max-lines-per-function | ||
@@ -28,3 +28,3 @@ const prefetchPlugin = ()=>({ | ||
} | ||
if (sharedFlag !== strategy) { | ||
if (sharedFlag !== SHARED_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 !== strategy) { | ||
if (sharedFlag !== SHARED_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-20241014085010", | ||
"version": "0.0.0-next-20241014092946", | ||
"author": "nieyan <nyqykk@foxmail.com>", | ||
@@ -36,7 +36,2 @@ "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" | ||
} | ||
@@ -58,5 +53,2 @@ }, | ||
], | ||
"shared": [ | ||
"./dist/shared.cjs.d.ts" | ||
], | ||
"babel-plugin": [ | ||
@@ -79,3 +71,2 @@ "./dist/babel.cjs.d.ts" | ||
"@types/react": "~18.0.38", | ||
"esbuild-plugin-replace": "^1.4.0", | ||
"jest": "^29.7.0", | ||
@@ -89,3 +80,2 @@ "jest-environment-jsdom": "^29.7.0", | ||
"ts-jest": "29.0.1", | ||
"tsup": "6.2.0", | ||
"webpack": "5.75.0" | ||
@@ -95,10 +85,8 @@ }, | ||
"fs-extra": "9.1.0", | ||
"@module-federation/runtime": "0.0.0-next-20241014085010", | ||
"@module-federation/sdk": "0.0.0-next-20241014085010" | ||
"@module-federation/runtime": "0.0.0-next-20241014092946", | ||
"@module-federation/sdk": "0.0.0-next-20241014092946" | ||
}, | ||
"scripts": { | ||
"dev": "cross-env WATCH=true tsup", | ||
"build": "rm -rf dist && tsup", | ||
"test": "jest" | ||
} | ||
} |
@@ -21,3 +21,2 @@ const copy = require('rollup-plugin-copy'); | ||
plugin: 'packages/data-prefetch/src/plugin.ts', | ||
shared: 'packages/data-prefetch/src/shared/index.ts', | ||
}; | ||
@@ -24,0 +23,0 @@ |
@@ -15,2 +15,3 @@ import path from 'path'; | ||
import { getPrefetchId } from '../common/runtime-utils'; | ||
import { SHARED_STRATEGY } from '../constant'; | ||
@@ -52,8 +53,10 @@ 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.runtimePlugins?.includes(sharedPath)) { | ||
this.options.runtimePlugins!.push(sharedPath); | ||
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`, | ||
); | ||
} | ||
@@ -60,0 +63,0 @@ |
@@ -7,2 +7,3 @@ import type { FederationRuntimePlugin } from '@module-federation/runtime/types'; | ||
import logger from './logger'; | ||
import { SHARED_STRATEGY } from './constant'; | ||
@@ -19,4 +20,3 @@ interface Loading { | ||
const loadingArray: Array<Loading> = []; | ||
const strategy = 'loaded-first'; | ||
let sharedFlag = strategy; | ||
let sharedFlag = SHARED_STRATEGY; | ||
// eslint-disable-next-line max-lines-per-function | ||
@@ -40,3 +40,3 @@ export const prefetchPlugin = (): FederationRuntimePlugin => ({ | ||
} | ||
if (sharedFlag !== strategy) { | ||
if (sharedFlag !== SHARED_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 !== strategy) { | ||
if (sharedFlag !== SHARED_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'`, |
14
107776
79
2643
+ Added@module-federation/runtime@0.0.0-next-20241014092946(transitive)
+ Added@module-federation/sdk@0.0.0-next-20241014092946(transitive)
- Removed@module-federation/runtime@0.0.0-next-20241014085010(transitive)
- Removed@module-federation/sdk@0.0.0-next-20241014085010(transitive)