Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: tidy up the typings of the build result in dev #267

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/clever-turtles-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"wrangler": patch
---

refactor: tidy up the typings of the build result in dev

In #262 some of the strict null fixes were removed to resolve a regression.
This refactor re-applies these fixes in a way that avoids that problem.
6 changes: 2 additions & 4 deletions packages/wrangler/src/dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ function useEsbuild(props: {
const { entry, destination, staticRoot, jsxFactory, jsxFragment } = props;
const [bundle, setBundle] = useState<EsbuildBundle>();
useEffect(() => {
let result: esbuild.BuildResult;
let result: esbuild.BuildResult | undefined;
async function build() {
if (!destination || !entry) return;
const moduleCollector = makeModuleCollector();
Expand Down Expand Up @@ -508,9 +508,7 @@ function useEsbuild(props: {
// so this is a no-op error handler
});
return () => {
if (result && result.stop) {
result.stop();
}
result?.stop?.();
};
}, [entry, destination, staticRoot, jsxFactory, jsxFragment]);
return bundle;
Expand Down