Skip to content

Commit

Permalink
refactor: tidy up the typings of the build result in dev
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
petebacondarwin committed Jan 19, 2022
1 parent 402c77d commit e22f9d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
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

0 comments on commit e22f9d7

Please sign in to comment.