next.js
be37d3ea - Fix build worker callback arg missing correct page path (#61347)

Commit
2 years ago
Fix build worker callback arg missing correct page path (#61347) ### What The `arg` in the worker callback is alwasy `any`, when we access the page path the argument could be in different form as the arg types are different. This PR align the argument type to object for `isPageStatic`, `getDefinedNamedExports`, `hasCustomGetInitialProps` methods in static worker. So they can share the similar shape of type of argument when accessing `page` path. This will avoid the case that logged `page` in the warning is `undefined` Import the helpers from utils instead of workers as the worker itself don't need to contain other exports that is not used for static worker. ### Why This PR align the callback type of callback argument type of static worker, so that we could get the actual page path value in a type-safe way. We have 4 methods for static worker, `exportPage`, `isPageStatic`, `getDefinedNamedExports`, `hasCustomGetInitialProps`, which the rest of 3 methods share the same format of warnings but their argument are different. It's easily ended up with wrong argument type, and log with a bad page path in the warning. Closes NEXT-2289
Author
Parents
Loading