Skip to content

Commit

Permalink
fix: make webpack cache work (#479)
Browse files Browse the repository at this point in the history
* fix: make webpack cache work

* chore(repack): add changeset for webpack caching fix

---------

Co-authored-by: Rafał Zakrzewski <[email protected]>
  • Loading branch information
ambar and RafikiTiki authored Dec 18, 2023
1 parent e1476e6 commit b1ad518
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/serious-hairs-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"testerapp": patch
"@callstack/repack": patch
---

Added the ability to fully leverage the webpack built-in caching mechanism to optimise cold build times.
4 changes: 4 additions & 0 deletions packages/TesterApp/webpack.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export default (env) => {
entries: false,
},
},
cache: {
type: 'filesystem',
name: `${platform}-${mode}`,
},
/**
* `getInitializationEntries` will return necessary entries with setup and initialization code.
* If you don't want to use Hot Module Replacement, set `hmr` option to `false`. By default,
Expand Down
12 changes: 12 additions & 0 deletions packages/repack/src/commands/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,17 @@ export async function bundle(
}
}
});
// eslint-disable-next-line promise/prefer-await-to-then
}).then(() => {
return new Promise<void>((resolve, reject) => {
// make cache work: https://webpack.js.org/api/node/#run
compiler.close((error) => {
if (error) {
reject();
} else {
resolve();
}
});
});
});
}

0 comments on commit b1ad518

Please sign in to comment.