@module-federation/data-prefetch 2.1.0 → 2.2.1

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.
@@ -84,6 +84,7 @@ const external_constant_cjs_namespaceObject = require("../constant.cjs");
84
84
 
85
85
 
86
86
 
87
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
87
88
  const { RuntimeGlobals, Template } = require((0,normalize_webpack_path_namespaceObject.normalizeWebpackPath)('webpack'));
88
89
  const createBundlerLogger = typeof sdk_namespaceObject.createInfrastructureLogger === 'function' ? sdk_namespaceObject.createInfrastructureLogger : sdk_namespaceObject.createLogger;
89
90
  const logger = createBundlerLogger('[ Module Federation Data Prefetch Plugin ]');
@@ -106,19 +107,10 @@ class PrefetchPlugin {
106
107
  if (!Array.isArray(runtimePlugins)) {
107
108
  this.options.runtimePlugins = [];
108
109
  }
109
- const runtimePluginCandidates = process.env.IS_ESM_BUILD === 'true' ? [
110
- '../plugin.js',
111
- '../plugin.cjs'
112
- ] : [
113
- '../plugin.cjs',
114
- '../plugin.js'
115
- ];
116
- const runtimePath = runtimePluginCandidates.map((candidate)=>external_path_default().resolve(__dirname, candidate)).find((candidatePath)=>external_fs_extra_default().existsSync(candidatePath));
117
- if (!runtimePath) {
118
- throw new Error([
119
- '[Module Federation Data Prefetch]: Unable to resolve runtime plugin file.',
120
- `Checked paths: ${runtimePluginCandidates.map((candidate)=>external_path_default().resolve(__dirname, candidate)).join(', ')}`
121
- ].join('\n'));
110
+ const runtimePluginFile = process.env.IS_ESM_BUILD === 'true' ? '../plugin.js' : '../plugin.cjs';
111
+ const runtimePath = external_path_default().resolve(__dirname, runtimePluginFile);
112
+ if (!external_fs_extra_default().existsSync(runtimePath)) {
113
+ throw new Error(`[Module Federation Data Prefetch]: Unable to resolve runtime plugin file at ${runtimePath}.`);
122
114
  }
123
115
  if (!((_this_options_runtimePlugins = this.options.runtimePlugins) === null || _this_options_runtimePlugins === void 0 ? void 0 : _this_options_runtimePlugins.includes(runtimePath))) {
124
116
  this.options.runtimePlugins.push(runtimePath);
@@ -132,6 +124,7 @@ class PrefetchPlugin {
132
124
  if (external_fs_extra_default().existsSync(asyncEntryPath)) {
133
125
  external_fs_extra_default().unlinkSync(asyncEntryPath);
134
126
  }
127
+ // @ts-ignore
135
128
  if (!this.options.dataPrefetch) {
136
129
  return;
137
130
  }
@@ -1,6 +1,6 @@
1
1
  import { moduleFederationPlugin } from '@module-federation/sdk';
2
- import type { Compiler, WebpackPluginInstance } from 'webpack';
3
- declare const RuntimeGlobals: typeof import("webpack").RuntimeGlobals;
2
+ import type { Compiler, WebpackPluginInstance } from '@module-federation/webpack-type';
3
+ declare const RuntimeGlobals: typeof import("@module-federation/webpack-type/lib/RuntimeGlobals");
4
4
  export declare function getFederationGlobalScope(runtimeGlobals: typeof RuntimeGlobals): string;
5
5
  export declare class PrefetchPlugin implements WebpackPluginInstance {
6
6
  options: moduleFederationPlugin.ModuleFederationPluginOptions;
@@ -1,6 +1,6 @@
1
1
  import { moduleFederationPlugin } from '@module-federation/sdk';
2
- import type { Compiler, WebpackPluginInstance } from 'webpack';
3
- declare const RuntimeGlobals: typeof import("webpack").RuntimeGlobals;
2
+ import type { Compiler, WebpackPluginInstance } from '@module-federation/webpack-type';
3
+ declare const RuntimeGlobals: typeof import("@module-federation/webpack-type/lib/RuntimeGlobals");
4
4
  export declare function getFederationGlobalScope(runtimeGlobals: typeof RuntimeGlobals): string;
5
5
  export declare class PrefetchPlugin implements WebpackPluginInstance {
6
6
  options: moduleFederationPlugin.ModuleFederationPluginOptions;
package/dist/cli/index.js CHANGED
@@ -32,6 +32,7 @@ import { SHARED_STRATEGY } from "../constant.js";
32
32
 
33
33
 
34
34
 
35
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
35
36
  const { RuntimeGlobals, Template } = require(normalizeWebpackPath('webpack'));
36
37
  const createBundlerLogger = typeof createInfrastructureLogger === 'function' ? createInfrastructureLogger : createLogger;
37
38
  const logger = createBundlerLogger('[ Module Federation Data Prefetch Plugin ]');
@@ -54,19 +55,10 @@ class PrefetchPlugin {
54
55
  if (!Array.isArray(runtimePlugins)) {
55
56
  this.options.runtimePlugins = [];
56
57
  }
57
- const runtimePluginCandidates = process.env.IS_ESM_BUILD === 'true' ? [
58
- '../plugin.js',
59
- '../plugin.cjs'
60
- ] : [
61
- '../plugin.cjs',
62
- '../plugin.js'
63
- ];
64
- const runtimePath = runtimePluginCandidates.map((candidate)=>path.resolve(__dirname, candidate)).find((candidatePath)=>fs_extra.existsSync(candidatePath));
65
- if (!runtimePath) {
66
- throw new Error([
67
- '[Module Federation Data Prefetch]: Unable to resolve runtime plugin file.',
68
- `Checked paths: ${runtimePluginCandidates.map((candidate)=>path.resolve(__dirname, candidate)).join(', ')}`
69
- ].join('\n'));
58
+ const runtimePluginFile = process.env.IS_ESM_BUILD === 'true' ? '../plugin.js' : '../plugin.cjs';
59
+ const runtimePath = path.resolve(__dirname, runtimePluginFile);
60
+ if (!fs_extra.existsSync(runtimePath)) {
61
+ throw new Error(`[Module Federation Data Prefetch]: Unable to resolve runtime plugin file at ${runtimePath}.`);
70
62
  }
71
63
  if (!((_this_options_runtimePlugins = this.options.runtimePlugins) === null || _this_options_runtimePlugins === void 0 ? void 0 : _this_options_runtimePlugins.includes(runtimePath))) {
72
64
  this.options.runtimePlugins.push(runtimePath);
@@ -80,6 +72,7 @@ class PrefetchPlugin {
80
72
  if (fs_extra.existsSync(asyncEntryPath)) {
81
73
  fs_extra.unlinkSync(asyncEntryPath);
82
74
  }
75
+ // @ts-ignore
83
76
  if (!this.options.dataPrefetch) {
84
77
  return;
85
78
  }
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": "2.1.0",
4
+ "version": "2.2.1",
5
5
  "type": "module",
6
6
  "author": "nieyan <nyqykk@foxmail.com>",
7
7
  "homepage": "https://github.com/module-federation/core",
@@ -119,14 +119,18 @@
119
119
  "react-router": "^6.30.2",
120
120
  "react-test-renderer": "^18.2.0",
121
121
  "ts-jest": "29.0.1",
122
- "webpack": "5.104.1"
122
+ "@module-federation/webpack-type": "0.0.1"
123
123
  },
124
124
  "dependencies": {
125
125
  "fs-extra": "9.1.0",
126
- "@module-federation/runtime": "2.1.0",
127
- "@module-federation/sdk": "2.1.0"
126
+ "@module-federation/sdk": "2.2.1",
127
+ "@module-federation/runtime": "2.2.1"
128
128
  },
129
129
  "scripts": {
130
- "test": "jest"
130
+ "test": "jest",
131
+ "build": "rslib build",
132
+ "test:ci": "pnpm exec jest --config jest.config.cjs --passWithNoTests --ci --coverage",
133
+ "lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint --ignore-pattern node_modules \"**/*.ts\" \"package.json\"",
134
+ "pre-release": "pnpm run test && pnpm run build"
131
135
  }
132
136
  }