graysonhicks / gatsby-plugin-loadable-components-ssr

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

Add loadable stats file path prefix to fix Gatsby v4 validation issue #46

Closed edword closed 3 years ago

edword commented 3 years ago

Summary

Adding a possible fix to address the issue reported in #45 where gatsby build in Gatsby v4 fails in the Validating Rendering Engines step.

Details

gatsby build run in v4 with gatsby-plugin-loadable-components-ssr fails in the Validating Rendering Engines step with the following error message :

failed Validating Rendering Engines - 1.942s ERROR #98001 WEBPACK Built Rendering Engines failed validation failed validation. Please open an issue with a reproduction at https://github.com/gatsbyjs/gatsby/issues/new for more help Error: Generated engines use disallowed import "gatsby-project/.cache/loadable-stats-build-javascript.json". Only allowed imports are to Node.js builtin modules or engines internals.

It seems that validation handling was added in Gatsby v4 which checks artifact paths against an allowed prefix list (specifically here).

This PR adds the allowed page-ssr prefix to the path and also adds a slight refactor so the loadable-stats file path can be used across gatsby-ssr and gatsby-node.

Unsure of all the use-cases to check for this, but this fix all seems to be working for me. Entirely possible something was missed, but hopefully this PR helps :)

laneparton commented 3 years ago

Just wanted to add, this resolved the error I was facing 🥂

graysonhicks commented 3 years ago

Cool thanks @edword I can get this merged and released ASAP.