Skip to content

Commit

Permalink
fix: order issue
Browse files Browse the repository at this point in the history
  • Loading branch information
2heal1 committed Jan 21, 2025
1 parent 8d84222 commit 941401c
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions packages/dts-plugin/src/plugins/GenerateTypesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,11 @@ export class GenerateTypesPlugin implements WebpackPluginInstance {
const emitTypesFiles = async (compilation: Compilation) => {
// Dev types will be generated by DevPlugin, the archive filename usually is dist/.dev-server.zip
try {
await consumeTypesPromise;

const { zipTypesPath, apiTypesPath, zipName, apiFileName } =
retrieveTypesAssetsInfo(finalOptions.remote);

if (isProd && zipName && compilation.getAsset(zipName)) {
callback();
return;
}

Expand Down Expand Up @@ -153,19 +152,15 @@ export class GenerateTypesPlugin implements WebpackPluginInstance {
compiler.outputFileSystem.mkdir(
path.dirname(zipOutputPath),
(err) => {
if (err) {
if (!isEEXIST(err)) {
reject(err);
}
if (err && !isEEXIST(err)) {
reject(err);
} else {
compiler.outputFileSystem.writeFile(
zipOutputPath,
zipContent,
(writeErr) => {
if (writeErr) {
if (!isEEXIST(writeErr)) {
reject(writeErr);
}
if (writeErr && !isEEXIST(writeErr)) {
reject(writeErr);
} else {
resolve();
}
Expand All @@ -188,19 +183,15 @@ export class GenerateTypesPlugin implements WebpackPluginInstance {
compiler.outputFileSystem.mkdir(
path.dirname(apiOutputPath),
(err) => {
if (err) {
if (!isEEXIST(err)) {
reject(err);
}
if (err && !isEEXIST(err)) {
reject(err);
} else {
compiler.outputFileSystem.writeFile(
apiOutputPath,
apiContent,
(writeErr) => {
if (writeErr) {
if (!isEEXIST(writeErr)) {
reject(writeErr);
}
if (writeErr && !isEEXIST(writeErr)) {
reject(writeErr);
} else {
resolve();
}
Expand Down Expand Up @@ -231,6 +222,7 @@ export class GenerateTypesPlugin implements WebpackPluginInstance {
compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER,
},
async () => {
await consumeTypesPromise;
const emitTypesFilesPromise = emitTypesFiles(compilation);
if (isProd) {
await emitTypesFilesPromise;
Expand Down

0 comments on commit 941401c

Please sign in to comment.