graysonhicks / gatsby-plugin-loadable-components-ssr

Gatsby plugin for using @loadable/component with Gatsby's SSR
49 stars 26 forks source link

Fix broken loadable stats path during SSR #49

Closed Pearce-Ropion closed 2 years ago

Pearce-Ropion commented 2 years ago

Fixes #48 The new location for loadable-stats-build-javascript.json in the latest version cannot be resolved during the SSR phase.

During SSR, process.cwd() resolves to /. Therefore, the resulting json file path in gatsby-ssr is /.cache/page-ssr/loadable-stats-build-javascript.json (note the leading slash / and not ./)

This change does not include process.cwd() in the exported loadable stats json path inside gatsby-ssr. Instead, it reverts to the previous method of resolving the json file path using path.resolve()