@module-federation/data-prefetch
Advanced tools
Comparing version 0.0.0-next-20240924091419 to 0.0.0-next-20240927010732
@@ -68,3 +68,3 @@ // Import the necessary modules and functions | ||
globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__[options.name] = | ||
Promise.resolve(projectExport); | ||
() => Promise.resolve(projectExport); | ||
@@ -76,2 +76,3 @@ await prefetch.getProjectExports(); | ||
}); | ||
// Prefetching with memory and executing prefetch function | ||
@@ -89,3 +90,3 @@ it('executes prefetch using prefetch function with and without memory', async () => { | ||
// Mock Project Exports | ||
globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__[id] = | ||
globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__[id] = () => | ||
Promise.resolve({ | ||
@@ -92,0 +93,0 @@ [encodeName(exposeId)]: prefetchExports, |
@@ -74,3 +74,3 @@ import { FederationHost, init } from '@module-federation/runtime'; | ||
globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__[options.name] = | ||
Promise.resolve(projectExport); | ||
() => Promise.resolve(projectExport); | ||
}); | ||
@@ -77,0 +77,0 @@ |
# @module-federation/data-prefetch | ||
## 0.0.0-next-20240924091419 | ||
## 0.0.0-next-20240927010732 | ||
### Patch Changes | ||
- Updated dependencies [3082116] | ||
- @module-federation/runtime@0.0.0-next-20240924091419 | ||
- @module-federation/sdk@0.0.0-next-20240924091419 | ||
- 9e32644: Refactored the way prefetch entries are imported for improved dynamic loading handling. | ||
- Changed the import of prefetch entries to use a function wrapper for more dynamic control. | ||
- Updated data types to ensure consistency with the new function-based import approach. | ||
- Modified the `injectPrefetch` function structure to incorporate the new import method. | ||
- Modified the `MFDataPrefetch` class to handle the new import function when resolving exports. | ||
- Updated dependencies [9e32644] | ||
- Updated dependencies [9e32644] | ||
- Updated dependencies [9e32644] | ||
- @module-federation/runtime@0.0.0-next-20240927010732 | ||
- @module-federation/sdk@0.0.0-next-20240927010732 | ||
## 0.6.6 | ||
@@ -12,0 +21,0 @@ |
@@ -27,4 +27,4 @@ // For a detailed explanation regarding each configuration property, visit: | ||
rootDir: __dirname, | ||
testMatch: ['<rootDir>__tests__/**/**.spec.[jt]s?(x)'], | ||
testMatch: ['<rootDir>/__tests__/**/*.spec.[jt]s?(x)'], | ||
testPathIgnorePatterns: ['/node_modules/'], | ||
}; |
{ | ||
"name": "@module-federation/data-prefetch", | ||
"description": "Module Federation Data Prefetch", | ||
"version": "0.0.0-next-20240924091419", | ||
"version": "0.0.0-next-20240927010732", | ||
"author": "nieyan <nyqykk@foxmail.com>", | ||
@@ -13,30 +13,30 @@ "homepage": "https://github.com/module-federation/core", | ||
".": { | ||
"import": "./dist/esm/index.js", | ||
"require": "./dist/index.js", | ||
"types": "./dist/index.d.ts" | ||
"import": "./dist/index.esm.js", | ||
"require": "./dist/index.cjs", | ||
"types": "./dist/index.cjs.d.ts" | ||
}, | ||
"./react": { | ||
"import": "./dist/esm/react/index.js", | ||
"require": "./dist/react/index.js", | ||
"types": "./dist/react/index.d.ts" | ||
"import": "./dist/react.esm.js", | ||
"require": "./dist/react.cjs.js", | ||
"types": "./dist/react.cjs.d.ts" | ||
}, | ||
"./cli": { | ||
"import": "./dist/esm/cli/index.js", | ||
"require": "./dist/cli/index.js", | ||
"types": "./dist/cli/index.d.ts" | ||
"import": "./dist/cli.esm.js", | ||
"require": "./dist/cli.cjs.js", | ||
"types": "./dist/cli.cjs.d.ts" | ||
}, | ||
"./babel-plugin": { | ||
"import": "./dist/esm/cli/babel.js", | ||
"require": "./dist/cli/babel.js", | ||
"types": "./dist/cli/babel.d.ts" | ||
"import": "./dist/babel.esm.js", | ||
"require": "./dist/babel.cjs.js", | ||
"types": "./dist/babel.cjs.d.ts" | ||
}, | ||
"./universal": { | ||
"import": "./dist/esm/universal/index.js", | ||
"require": "./dist/universal/index.js", | ||
"types": "./dist/universal/index.d.ts" | ||
"import": "./dist/universal.esm.js", | ||
"require": "./dist/universal.cjs.js", | ||
"types": "./dist/universal.cjs.d.ts" | ||
}, | ||
"./shared": { | ||
"import": "./dist/esm/shared/index.js", | ||
"require": "./dist/shared/index.js", | ||
"types": "./dist/shared/index.d.ts" | ||
"import": "./dist/shared.esm.js", | ||
"require": "./dist/shared.cjs.js", | ||
"types": "./dist/shared/.cjs.d.ts" | ||
} | ||
@@ -47,20 +47,23 @@ }, | ||
".": [ | ||
"./dist/index.d.ts" | ||
"./dist/index.cjs.d.ts" | ||
], | ||
"react": [ | ||
"./dist/react/index.d.ts" | ||
"./dist/react.cjs.d.ts" | ||
], | ||
"cli": [ | ||
"./dist/cli/index.d.ts" | ||
"./dist/cli.cjs.d.ts" | ||
], | ||
"universal": [ | ||
"./dist/universal/index.d.ts" | ||
"./dist/universal.cjs.d.ts" | ||
], | ||
"shared": [ | ||
"./dist/shared/index.d.ts" | ||
"./dist/shared.cjs.d.ts" | ||
], | ||
"babel-plugin": [ | ||
"./dist/babel.cjs.d.ts" | ||
] | ||
} | ||
}, | ||
"main": "dist/index.js", | ||
"module": "dist/esm/index.js", | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.esm.js", | ||
"peerDependencies": { | ||
@@ -90,4 +93,4 @@ "react": ">=16.9.0", | ||
"fs-extra": "9.1.0", | ||
"@module-federation/sdk": "0.0.0-next-20240924091419", | ||
"@module-federation/runtime": "0.0.0-next-20240924091419" | ||
"@module-federation/sdk": "0.0.0-next-20240927010732", | ||
"@module-federation/runtime": "0.0.0-next-20240927010732" | ||
}, | ||
@@ -94,0 +97,0 @@ "scripts": { |
{ | ||
"name": "module-federation/data-prefetch", | ||
"name": "data-prefetch", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
@@ -8,11 +8,53 @@ "sourceRoot": "packages/data-prefetch/src", | ||
"build": { | ||
"executor": "nx:run-commands", | ||
"executor": "@nx/rollup:rollup", | ||
"outputs": ["{options.outputPath}"], | ||
"options": { | ||
"commands": ["npm run build --prefix packages/data-prefetch"] | ||
"outputPath": "packages/data-prefetch/dist", | ||
"main": "packages/data-prefetch/src/index.ts", | ||
"tsConfig": "packages/data-prefetch/tsconfig.lib.json", | ||
"assets": [], | ||
"project": "packages/data-prefetch/package.json", | ||
"rollupConfig": "packages/data-prefetch/rollup.config.js", | ||
"compiler": "swc", | ||
"format": ["cjs", "esm"] | ||
} | ||
}, | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"], | ||
"options": { | ||
"jestConfig": "packages/data-prefetch/jest.config.js", | ||
"passWithNoTests": true | ||
}, | ||
"configurations": { | ||
"ci": { | ||
"ci": true, | ||
"codeCoverage": true | ||
} | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nx/linter:eslint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": [ | ||
"packages/data-prefetch/**/*.ts", | ||
"packages/data-prefetch/package.json" | ||
] | ||
} | ||
}, | ||
"pre-release": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"commands": ["npm run test --prefix packages/data-prefetch"] | ||
"parallel": false, | ||
"commands": [ | ||
{ | ||
"command": "nx run data-prefetch:test", | ||
"forwardAllArgs": false | ||
}, | ||
{ | ||
"command": "nx run data-prefetch:build", | ||
"forwardAllArgs": false | ||
} | ||
] | ||
} | ||
@@ -19,0 +61,0 @@ } |
@@ -50,4 +50,4 @@ import path from 'path'; | ||
const runtimePath = path.resolve(__dirname, '../esm/plugin.js'); | ||
const sharedPath = path.resolve(__dirname, '../esm/shared/index.js'); | ||
const runtimePath = path.resolve(__dirname, './plugin.esm.js'); | ||
const sharedPath = path.resolve(__dirname, './shared.esm.js'); | ||
if (!this.options.runtimePlugins?.includes(runtimePath)) { | ||
@@ -139,10 +139,12 @@ this.options.runtimePlugins!.push(runtimePath); | ||
'function injectPrefetch() {', | ||
`globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`, | ||
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] || {`, | ||
`entryLoading: {},`, | ||
`instance: new Map(),`, | ||
`__PREFETCH_EXPORTS__: {},`, | ||
`};`, | ||
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] || {};`, | ||
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}']['${options.name}'] = import('${prefetchEntry}');`, | ||
Template.indent([ | ||
`globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`, | ||
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] || {`, | ||
`entryLoading: {},`, | ||
`instance: new Map(),`, | ||
`__PREFETCH_EXPORTS__: {},`, | ||
`};`, | ||
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] || {};`, | ||
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}']['${options.name}'] = function(){ return import('${prefetchEntry}');}`, | ||
]), | ||
'}', | ||
@@ -149,0 +151,0 @@ `${federationGlobal}.prefetch = injectPrefetch`, |
@@ -20,3 +20,3 @@ import { | ||
instance: Map<string, MFDataPrefetch>; | ||
__PREFETCH_EXPORTS__: Record<string, Promise<Record<string, any>>>; | ||
__PREFETCH_EXPORTS__: Record<string, () => Promise<Record<string, any>>>; | ||
}; | ||
@@ -98,4 +98,8 @@ } | ||
const { name } = this._options; | ||
const exportsPromiseFn = | ||
globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__?.[name]; | ||
const exportsPromise = | ||
globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__?.[name]; | ||
typeof exportsPromiseFn === 'function' | ||
? exportsPromiseFn() | ||
: Promise.resolve({}); | ||
const resolve = exportsPromise.then( | ||
@@ -102,0 +106,0 @@ (exports: Record<string, Record<string, any>> = {}) => { |
@@ -25,4 +25,4 @@ { | ||
}, | ||
"include": ["src", "../../global.d.ts", "__tests__/**/*", "tsup.config.ts"], | ||
"include": ["src", "../../global.d.ts", "__tests__/**/*"], | ||
"exclude": ["node_modules/**/*", "../node_modules"] | ||
} |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
392410
72
10476
13
1
+ Added@module-federation/runtime@0.0.0-next-20240927010732(transitive)
+ Added@module-federation/sdk@0.0.0-next-20240927010732(transitive)
- Removed@module-federation/runtime@0.0.0-next-20240924091419(transitive)
- Removed@module-federation/sdk@0.0.0-next-20240924091419(transitive)