@module-federation/esbuild 0.0.115 → 0.0.117

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.
@@ -1,2 +1,2 @@
1
1
  import { BuildResult } from 'esbuild';
2
- export declare const writeRemoteManifest: (config: any, result: BuildResult) => Promise<void>;
2
+ export declare const writeRemoteManifest: (config: any, result: BuildResult, absWorkingDir: string) => Promise<void>;
@@ -70,7 +70,7 @@ const external_collect_exports_js_namespaceObject = require("./collect-exports.j
70
70
 
71
71
 
72
72
 
73
- const writeRemoteManifest = async (config, result)=>{
73
+ const writeRemoteManifest = async (config, result, absWorkingDir)=>{
74
74
  if (result.errors && result.errors.length > 0) {
75
75
  console.warn('Build errors detected, skipping writeRemoteManifest.');
76
76
  return;
@@ -145,7 +145,7 @@ const writeRemoteManifest = async (config, result)=>{
145
145
  let { version } = config;
146
146
  if (!version) {
147
147
  try {
148
- const packageJsonPath = await (0,external_collect_exports_js_namespaceObject.resolve)(process.cwd(), `${pkg}/package.json`);
148
+ const packageJsonPath = await (0,external_collect_exports_js_namespaceObject.resolve)(absWorkingDir, `${pkg}/package.json`);
149
149
  if (packageJsonPath) {
150
150
  version = JSON.parse(external_fs_default().readFileSync(packageJsonPath, 'utf-8')).version;
151
151
  }
@@ -207,14 +207,14 @@ const writeRemoteManifest = async (config, result)=>{
207
207
  },
208
208
  types,
209
209
  globalName: config.name,
210
- pluginVersion: "0.0.115",
210
+ pluginVersion: "0.0.117",
211
211
  publicPath
212
212
  },
213
213
  shared,
214
214
  remotes,
215
215
  exposes
216
216
  };
217
- const manifestPath = external_path_default().join(external_path_default().dirname(outputMap[containerName].chunk), 'mf-manifest.json');
217
+ const manifestPath = external_path_default().resolve(absWorkingDir, external_path_default().dirname(outputMap[containerName].chunk), 'mf-manifest.json');
218
218
  external_fs_default().writeFileSync(manifestPath, JSON.stringify(manifest, null, 2), 'utf-8');
219
219
  };
220
220
 
@@ -8,7 +8,7 @@ import { resolve } from "./collect-exports.mjs";
8
8
 
9
9
 
10
10
 
11
- const writeRemoteManifest = async (config, result)=>{
11
+ const writeRemoteManifest = async (config, result, absWorkingDir)=>{
12
12
  if (result.errors && result.errors.length > 0) {
13
13
  console.warn('Build errors detected, skipping writeRemoteManifest.');
14
14
  return;
@@ -83,7 +83,7 @@ const writeRemoteManifest = async (config, result)=>{
83
83
  let { version } = config;
84
84
  if (!version) {
85
85
  try {
86
- const packageJsonPath = await resolve(process.cwd(), `${pkg}/package.json`);
86
+ const packageJsonPath = await resolve(absWorkingDir, `${pkg}/package.json`);
87
87
  if (packageJsonPath) {
88
88
  version = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')).version;
89
89
  }
@@ -145,14 +145,14 @@ const writeRemoteManifest = async (config, result)=>{
145
145
  },
146
146
  types,
147
147
  globalName: config.name,
148
- pluginVersion: "0.0.115",
148
+ pluginVersion: "0.0.117",
149
149
  publicPath
150
150
  },
151
151
  shared,
152
152
  remotes,
153
153
  exposes
154
154
  };
155
- const manifestPath = path.join(path.dirname(outputMap[containerName].chunk), 'mf-manifest.json');
155
+ const manifestPath = path.resolve(absWorkingDir, path.dirname(outputMap[containerName].chunk), 'mf-manifest.json');
156
156
  fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2), 'utf-8');
157
157
  };
158
158
 
@@ -239,6 +239,8 @@ const linkSharedPlugin = (config)=>({
239
239
  const moduleFederationPlugin = (config)=>({
240
240
  name: 'module-federation',
241
241
  setup (build) {
242
+ // esbuild reports metafile paths relative to absWorkingDir, which defaults to process.cwd().
243
+ const absWorkingDir = build.initialOptions.absWorkingDir || process.cwd();
242
244
  build.initialOptions.metafile = true;
243
245
  const externals = (0,get_externals_js_namespaceObject.getExternals)(config);
244
246
  if (build.initialOptions.external) {
@@ -316,12 +318,13 @@ const moduleFederationPlugin = (config)=>({
316
318
  if (!value.entryPoint) continue;
317
319
  if (!value.entryPoint.startsWith('container:')) continue;
318
320
  if (!value.entryPoint.endsWith(remoteFile)) continue;
319
- const container = external_fs_default().readFileSync(outputPath, 'utf-8');
321
+ const outputFile = external_path_default().resolve(absWorkingDir, outputPath);
322
+ const container = external_fs_default().readFileSync(outputFile, 'utf-8');
320
323
  const withExports = container.replace('"__MODULE_MAP__"', `${JSON.stringify(exposedEntries)}`).replace("'__MODULE_MAP__'", `${JSON.stringify(exposedEntries)}`);
321
- external_fs_default().writeFileSync(outputPath, withExports, 'utf-8');
324
+ external_fs_default().writeFileSync(outputFile, withExports, 'utf-8');
322
325
  }
323
326
  }
324
- await (0,external_manifest_js_namespaceObject.writeRemoteManifest)(config, result);
327
+ await (0,external_manifest_js_namespaceObject.writeRemoteManifest)(config, result, absWorkingDir);
325
328
  console.log(`build ended with ${result.errors.length} errors`);
326
329
  });
327
330
  }
@@ -156,6 +156,8 @@ const linkSharedPlugin = (config)=>({
156
156
  const moduleFederationPlugin = (config)=>({
157
157
  name: 'module-federation',
158
158
  setup (build) {
159
+ // esbuild reports metafile paths relative to absWorkingDir, which defaults to process.cwd().
160
+ const absWorkingDir = build.initialOptions.absWorkingDir || process.cwd();
159
161
  build.initialOptions.metafile = true;
160
162
  const externals = getExternals(config);
161
163
  if (build.initialOptions.external) {
@@ -233,12 +235,13 @@ const moduleFederationPlugin = (config)=>({
233
235
  if (!value.entryPoint) continue;
234
236
  if (!value.entryPoint.startsWith('container:')) continue;
235
237
  if (!value.entryPoint.endsWith(remoteFile)) continue;
236
- const container = fs.readFileSync(outputPath, 'utf-8');
238
+ const outputFile = path.resolve(absWorkingDir, outputPath);
239
+ const container = fs.readFileSync(outputFile, 'utf-8');
237
240
  const withExports = container.replace('"__MODULE_MAP__"', `${JSON.stringify(exposedEntries)}`).replace("'__MODULE_MAP__'", `${JSON.stringify(exposedEntries)}`);
238
- fs.writeFileSync(outputPath, withExports, 'utf-8');
241
+ fs.writeFileSync(outputFile, withExports, 'utf-8');
239
242
  }
240
243
  }
241
- await writeRemoteManifest(config, result);
244
+ await writeRemoteManifest(config, result, absWorkingDir);
242
245
  console.log(`build ended with ${result.errors.length} errors`);
243
246
  });
244
247
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/esbuild",
3
- "version": "0.0.115",
3
+ "version": "0.0.117",
4
4
  "author": "Zack Jackson (@ScriptedAlchemy)",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -58,9 +58,9 @@
58
58
  "esbuild": "0.28.1",
59
59
  "json5": "2.2.3",
60
60
  "npmlog": "7.0.1",
61
- "@module-federation/runtime": "2.9.1",
62
- "@module-federation/webpack-bundler-runtime": "2.9.1",
63
- "@module-federation/sdk": "2.9.1"
61
+ "@module-federation/sdk": "2.9.3",
62
+ "@module-federation/runtime": "2.9.3",
63
+ "@module-federation/webpack-bundler-runtime": "2.9.3"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@rslib/core": "^0.23.2",
@@ -69,6 +69,7 @@
69
69
  "scripts": {
70
70
  "build": "rslib build",
71
71
  "lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint --ignore-pattern node_modules \"**/*.ts\" \"package.json\"",
72
+ "test": "node --test __tests__/*.spec.mjs",
72
73
  "build-debug": "FEDERATION_DEBUG=true rslib build",
73
74
  "pre-release": "pnpm run build"
74
75
  }