@module-federation/dts-plugin
Advanced tools
Comparing version 0.0.0-next-20250109083623 to 0.0.0-next-20250109101432
@@ -133,4 +133,2 @@ import { | ||
__publicField(this, "_devWorker"); | ||
__publicField(this, "updateDebounceTimer", null); | ||
__publicField(this, "UPDATE_DEBOUNCE_DELAY", 300); | ||
__publicField(this, "fetchTypesPromise"); | ||
@@ -173,17 +171,5 @@ this._options = options; | ||
} | ||
_debouncedUpdate() { | ||
if (this.updateDebounceTimer) { | ||
clearTimeout(this.updateDebounceTimer); | ||
} | ||
this.updateDebounceTimer = setTimeout(() => __async(this, null, function* () { | ||
var _a; | ||
try { | ||
(_a = this._devWorker) == null ? void 0 : _a.update(); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
}), this.UPDATE_DEBOUNCE_DELAY); | ||
} | ||
_afterEmit() { | ||
this._debouncedUpdate(); | ||
var _a; | ||
(_a = this._devWorker) == null ? void 0 : _a.update(); | ||
} | ||
@@ -342,6 +328,2 @@ apply(compiler) { | ||
__publicField(this, "callback"); | ||
__publicField(this, "debounceTimer", null); | ||
__publicField(this, "isProcessing", false); | ||
__publicField(this, "pendingTask", false); | ||
__publicField(this, "DEBOUNCE_DELAY", 300); | ||
this.pluginOptions = pluginOptions; | ||
@@ -388,75 +370,58 @@ this.dtsOptions = dtsOptions; | ||
let compiledOnce = false; | ||
const debouncedEmitTypesFilesDev = /* @__PURE__ */ __name(() => __async(this, null, function* () { | ||
if (this.isProcessing) { | ||
this.pendingTask = true; | ||
return; | ||
} | ||
if (this.debounceTimer) { | ||
clearTimeout(this.debounceTimer); | ||
} | ||
this.debounceTimer = setTimeout(() => __async(this, null, function* () { | ||
try { | ||
this.isProcessing = true; | ||
if (!isDev()) { | ||
return; | ||
} | ||
const { zipTypesPath, apiTypesPath, zipName, apiFileName } = retrieveTypesAssetsInfo(finalOptions.remote); | ||
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 (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 && err.code !== "EEXIST") { | ||
reject(err); | ||
} else { | ||
compiler.outputFileSystem.writeFile(zipOutputPath, zipContent, (writeErr) => { | ||
if (writeErr) | ||
reject(writeErr); | ||
else | ||
resolve2(); | ||
}); | ||
} | ||
}); | ||
const emitTypesFilesDev = /* @__PURE__ */ __name(() => __async(this, null, function* () { | ||
try { | ||
if (!isDev()) { | ||
return; | ||
} | ||
const { zipTypesPath, apiTypesPath, zipName, apiFileName } = retrieveTypesAssetsInfo(finalOptions.remote); | ||
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 (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 && err.code !== "EEXIST") { | ||
reject(err); | ||
} else { | ||
compiler.outputFileSystem.writeFile(zipOutputPath, zipContent, (writeErr) => { | ||
if (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 && err.code !== "EEXIST") { | ||
reject(err); | ||
} else { | ||
compiler.outputFileSystem.writeFile(apiOutputPath, apiContent, (writeErr) => { | ||
if (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 && err.code !== "EEXIST") { | ||
reject(err); | ||
} else { | ||
compiler.outputFileSystem.writeFile(apiOutputPath, apiContent, (writeErr) => { | ||
if (writeErr) | ||
reject(writeErr); | ||
else | ||
resolve2(); | ||
}); | ||
} | ||
}); | ||
} | ||
} catch (err) { | ||
console.error(err); | ||
} finally { | ||
this.isProcessing = false; | ||
this.debounceTimer = null; | ||
if (this.pendingTask) { | ||
this.pendingTask = false; | ||
yield debouncedEmitTypesFilesDev(); | ||
} | ||
}); | ||
} | ||
}), this.DEBOUNCE_DELAY); | ||
}), "debouncedEmitTypesFilesDev"); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
}), "emitTypesFilesDev"); | ||
compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => { | ||
@@ -476,3 +441,3 @@ compilation.hooks.processAssets.tapPromise({ | ||
if (compiledOnce) { | ||
debouncedEmitTypesFilesDev(); | ||
emitTypesFilesDev(); | ||
return; | ||
@@ -528,3 +493,3 @@ } | ||
extractThirdParty: true, | ||
extractRemoteTypes: true | ||
extractRemoteTypes: false | ||
}; | ||
@@ -531,0 +496,0 @@ const defaultConsumeTypes = { |
{ | ||
"name": "@module-federation/dts-plugin", | ||
"version": "0.0.0-next-20250109083623", | ||
"version": "0.0.0-next-20250109101432", | ||
"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-20250109083623", | ||
"@module-federation/managers": "0.0.0-next-20250109083623", | ||
"@module-federation/third-party-dts-extractor": "0.0.0-next-20250109083623", | ||
"@module-federation/error-codes": "0.0.0-next-20250109083623" | ||
"@module-federation/sdk": "0.0.0-next-20250109101432", | ||
"@module-federation/managers": "0.0.0-next-20250109101432", | ||
"@module-federation/third-party-dts-extractor": "0.0.0-next-20250109101432", | ||
"@module-federation/error-codes": "0.0.0-next-20250109101432" | ||
}, | ||
@@ -76,3 +76,3 @@ "devDependencies": { | ||
"vue-tsc": "^2.0.26", | ||
"@module-federation/runtime": "0.0.0-next-20250109083623" | ||
"@module-federation/runtime": "0.0.0-next-20250109101432" | ||
}, | ||
@@ -79,0 +79,0 @@ "peerDependencies": { |
Sorry, the diff of this file is too big to display
580439
14491
+ Added@module-federation/error-codes@0.0.0-next-20250109101432(transitive)
+ Added@module-federation/managers@0.0.0-next-20250109101432(transitive)
+ Added@module-federation/sdk@0.0.0-next-20250109101432(transitive)
+ Added@module-federation/third-party-dts-extractor@0.0.0-next-20250109101432(transitive)
- Removed@module-federation/error-codes@0.0.0-next-20250109083623(transitive)
- Removed@module-federation/managers@0.0.0-next-20250109083623(transitive)
- Removed@module-federation/sdk@0.0.0-next-20250109083623(transitive)
- Removed@module-federation/third-party-dts-extractor@0.0.0-next-20250109083623(transitive)
Updated@module-federation/error-codes@0.0.0-next-20250109101432
Updated@module-federation/managers@0.0.0-next-20250109101432
Updated@module-federation/third-party-dts-extractor@0.0.0-next-20250109101432