@module-federation/dts-plugin
Advanced tools
Comparing version 0.0.0-next-20250115034449 to 0.0.0-next-20250121095540
# @module-federation/dts-plugin | ||
## 0.8.9 | ||
### Patch Changes | ||
- 6e3afc6: feat(dts-plugin): support pass headers when request types url | ||
- 1be9d62: feat(dts-plugin): add dts.displayErrorInTerminal to help control display error | ||
- 6e3afc6: fix(dts-plugin): set outputDir default value | ||
- 6e3afc6: fix(dts-plugin): use remoteTarPath first to fetch hot types | ||
- 6e3afc6: fix(dts-plugin): only consume types in dev | ||
- 6e3afc6: fix(dts-plugin): throw error while downloading types archive hit historyApiFallback | ||
- 6e3afc6: fix(dts-plugin): generateTypes should after consumeTypes finished | ||
- 6e3afc6: fix(dts-plugin): dev plugin should apply after fetchPromise resolved | ||
- @module-federation/sdk@0.8.9 | ||
- @module-federation/managers@0.8.9 | ||
- @module-federation/third-party-dts-extractor@0.8.9 | ||
- @module-federation/error-codes@0.8.9 | ||
## 0.8.8 | ||
@@ -4,0 +21,0 @@ |
@@ -372,49 +372,100 @@ import { | ||
const generateTypesFn = getGenerateTypesFn(); | ||
let compiledOnce = false; | ||
compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => { | ||
compilation.hooks.processAssets.tapPromise({ | ||
name: "mf:generateTypes", | ||
stage: ( | ||
// @ts-expect-error use runtime variable in case peer dep not installed | ||
compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER | ||
) | ||
}, () => __async(this, null, function* () { | ||
const emitTypesFiles = /* @__PURE__ */ __name((compilation) => __async(this, null, function* () { | ||
try { | ||
yield consumeTypesPromise; | ||
try { | ||
if (pluginOptions.dev === false && compiledOnce) { | ||
return; | ||
} | ||
if (compiledOnce) { | ||
return; | ||
} | ||
const { zipTypesPath, apiTypesPath, zipName, apiFileName } = retrieveTypesAssetsInfo(finalOptions.remote); | ||
if (zipName && compilation.getAsset(zipName)) { | ||
return; | ||
} | ||
yield generateTypesFn(finalOptions); | ||
const config = finalOptions.remote.moduleFederationConfig; | ||
let zipPrefix = ""; | ||
if (typeof config.manifest === "object" && config.manifest.filePath) { | ||
zipPrefix = config.manifest.filePath; | ||
} else if (typeof config.manifest === "object" && config.manifest.fileName) { | ||
zipPrefix = path5.dirname(config.manifest.fileName); | ||
} else if (config.filename) { | ||
zipPrefix = path5.dirname(config.filename); | ||
} | ||
const { zipTypesPath, apiTypesPath, zipName, apiFileName } = retrieveTypesAssetsInfo(finalOptions.remote); | ||
if (isProd && zipName && compilation.getAsset(zipName)) { | ||
return; | ||
} | ||
yield generateTypesFn(finalOptions); | ||
const config = finalOptions.remote.moduleFederationConfig; | ||
let zipPrefix = ""; | ||
if (typeof config.manifest === "object" && config.manifest.filePath) { | ||
zipPrefix = config.manifest.filePath; | ||
} else if (typeof config.manifest === "object" && config.manifest.fileName) { | ||
zipPrefix = path5.dirname(config.manifest.fileName); | ||
} else if (config.filename) { | ||
zipPrefix = path5.dirname(config.filename); | ||
} | ||
if (isProd) { | ||
const zipAssetName = path5.join(zipPrefix, zipName); | ||
const apiAssetName = path5.join(zipPrefix, apiFileName); | ||
if (zipTypesPath && !compilation.getAsset(zipAssetName)) { | ||
compilation.emitAsset(path5.join(zipPrefix, zipName), new compiler.webpack.sources.RawSource(fs2.readFileSync(zipTypesPath), false)); | ||
compilation.emitAsset(zipAssetName, new compiler.webpack.sources.RawSource(fs2.readFileSync(zipTypesPath), false)); | ||
} | ||
const apiAssetName = path5.join(zipPrefix, apiFileName); | ||
if (apiTypesPath && !compilation.getAsset(apiAssetName)) { | ||
compilation.emitAsset(path5.join(zipPrefix, apiFileName), new compiler.webpack.sources.RawSource(fs2.readFileSync(apiTypesPath), false)); | ||
compilation.emitAsset(apiAssetName, new compiler.webpack.sources.RawSource(fs2.readFileSync(apiTypesPath), false)); | ||
} | ||
compiledOnce = true; | ||
callback(); | ||
} catch (err) { | ||
} else { | ||
const isEEXIST = /* @__PURE__ */ __name((err) => { | ||
return err.code == "EEXIST"; | ||
}, "isEEXIST"); | ||
if (zipTypesPath) { | ||
const zipContent = fs2.readFileSync(zipTypesPath); | ||
const zipOutputPath = path5.join(compiler.outputPath, zipPrefix, zipName); | ||
yield new Promise((resolve2, reject) => { | ||
compiler.outputFileSystem.mkdir(path5.dirname(zipOutputPath), (err) => { | ||
if (err) { | ||
if (!isEEXIST(err)) { | ||
reject(err); | ||
} | ||
} else { | ||
compiler.outputFileSystem.writeFile(zipOutputPath, zipContent, (writeErr) => { | ||
if (writeErr) { | ||
if (!isEEXIST(writeErr)) { | ||
reject(writeErr); | ||
} | ||
} else { | ||
resolve2(); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
} | ||
if (apiTypesPath) { | ||
const apiContent = fs2.readFileSync(apiTypesPath); | ||
const apiOutputPath = path5.join(compiler.outputPath, zipPrefix, apiFileName); | ||
yield new Promise((resolve2, reject) => { | ||
compiler.outputFileSystem.mkdir(path5.dirname(apiOutputPath), (err) => { | ||
if (err) { | ||
if (!isEEXIST(err)) { | ||
reject(err); | ||
} | ||
} else { | ||
compiler.outputFileSystem.writeFile(apiOutputPath, apiContent, (writeErr) => { | ||
if (writeErr) { | ||
if (!isEEXIST(writeErr)) { | ||
reject(writeErr); | ||
} | ||
} else { | ||
resolve2(); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
} | ||
callback(); | ||
if (finalOptions.displayErrorInTerminal) { | ||
console.error("Error in mf:generateTypes processAssets hook:", err); | ||
} | ||
} | ||
} catch (err) { | ||
callback(); | ||
if (finalOptions.displayErrorInTerminal) { | ||
console.error("Error in mf:generateTypes processAssets hook:", err); | ||
} | ||
} | ||
}), "emitTypesFiles"); | ||
compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => { | ||
compilation.hooks.processAssets.tapPromise({ | ||
name: "mf:generateTypes", | ||
stage: ( | ||
// @ts-expect-error use runtime variable in case peer dep not installed | ||
compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER | ||
) | ||
}, () => __async(this, null, function* () { | ||
const emitTypesFilesPromise = emitTypesFiles(compilation); | ||
if (isProd) { | ||
yield emitTypesFilesPromise; | ||
} | ||
})); | ||
@@ -421,0 +472,0 @@ }); |
{ | ||
"name": "@module-federation/dts-plugin", | ||
"version": "0.8.8", | ||
"version": "0.8.9", | ||
"author": "hanric <hanric.zhang@gmail.com>", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
{ | ||
"name": "@module-federation/dts-plugin", | ||
"version": "0.0.0-next-20250115034449", | ||
"version": "0.0.0-next-20250121095540", | ||
"author": "hanric <hanric.zhang@gmail.com>", | ||
@@ -63,6 +63,6 @@ "main": "./dist/index.js", | ||
"ws": "8.18.0", | ||
"@module-federation/sdk": "0.0.0-next-20250115034449", | ||
"@module-federation/managers": "0.0.0-next-20250115034449", | ||
"@module-federation/third-party-dts-extractor": "0.0.0-next-20250115034449", | ||
"@module-federation/error-codes": "0.0.0-next-20250115034449" | ||
"@module-federation/sdk": "0.0.0-next-20250121095540", | ||
"@module-federation/managers": "0.0.0-next-20250121095540", | ||
"@module-federation/third-party-dts-extractor": "0.0.0-next-20250121095540", | ||
"@module-federation/error-codes": "0.0.0-next-20250121095540" | ||
}, | ||
@@ -76,3 +76,3 @@ "devDependencies": { | ||
"vue-tsc": "^2.0.26", | ||
"@module-federation/runtime": "0.0.0-next-20250115034449" | ||
"@module-federation/runtime": "0.0.0-next-20250121095540" | ||
}, | ||
@@ -79,0 +79,0 @@ "peerDependencies": { |
Sorry, the diff of this file is too big to display
586192
14573
+ Added@module-federation/error-codes@0.0.0-next-20250121095540(transitive)
+ Added@module-federation/managers@0.0.0-next-20250121095540(transitive)
+ Added@module-federation/sdk@0.0.0-next-20250121095540(transitive)
+ Added@module-federation/third-party-dts-extractor@0.0.0-next-20250121095540(transitive)
- Removed@module-federation/error-codes@0.0.0-next-20250115034449(transitive)
- Removed@module-federation/managers@0.0.0-next-20250115034449(transitive)
- Removed@module-federation/sdk@0.0.0-next-20250115034449(transitive)
- Removed@module-federation/third-party-dts-extractor@0.0.0-next-20250115034449(transitive)
Updated@module-federation/error-codes@0.0.0-next-20250121095540
Updated@module-federation/managers@0.0.0-next-20250121095540
Updated@module-federation/third-party-dts-extractor@0.0.0-next-20250121095540