Closed Pearce-Ropion closed 2 years ago
Thanks for the issue and PR @Pearce-Ropion ! For posterity and clarity, what are the steps to reproduce this? Does it happen on every build or randomly? Is this OS dependent? Thanks and I'll get this merged and released asap!
I'm currently running on Debian 9, so it might be OS specific. I know Linux sometimes does weird stuff with paths.
As for when this happens, it appears to happen on every build and development build on the latest version of gatsby. I had to look through a bunch of the files in the gatsby codebase while researching what was the problem and found a lot of places where they reference the /page-ssr directory like you do during gatsby-node API process. But I couldn't find anywhere where they try to access a file in /page-ssr during the gatsby-ssr API process. So maybe this is just how gatsby works during the SSR step.
I was just testing this in my local repository, but if you'd like I could try to make a repro.
Yea, if you don't mind, that'd be great! I just want to be careful on this pathing because there have been several fixes related to OS here and don't want a regression. Thanks!
This is happening to me on Gatsby Cloud too :)
Released 4.1.1 with a fix for this. Thanks @Pearce-Ropion !
@graysonhicks – it's back, reverting from 4.1.2 to to 4.1.1 fixes it--leading / strikes again:
abe2da04408c505cbacf11beeca24fbd98a809ba <-- I think this commit broke it
@pieh Any ideas why one breaks the other?
My guess would be that the path needs to be resolved still--it's looking for .cache in the system root, not the project root.
Yep, importing from any path that starts with / will import from the system root.
As long as you aren't using DSG, you can stay on 4.1.1
I think you forgot the leading ./ in your import path to make it relative.
Can't tell if that / is important for the DSG aspect: https://github.com/graysonhicks/gatsby-plugin-loadable-components-ssr/pull/50#discussion_r770928104
@graysonhicks I can test on our project if a beta release is tagged
Adding .
before /
does not help.
Module not found: Error: Can't resolve './.cache/page-ssr/loadable-stats-build-javascript.json' in
'/path-to-project/node_modules/gatsby-plugin-loadable-components-ssr'
But notice the path. It tries to find the file in the plugin dir, not in the project root.
Could we at least reopen this issue?
@pieh Any ideas on this commit causing this problem? Ideally this should work with v4 + DSG.
Path starting with /
is intentional as that should resolve to project root in Gatsby. And in test sites that I had as well as at least 1 user case it does work correctly.
To fix the problem I do need to be able to reproduce it - do any of you folks seeing this issue have (public) site I could pull and reproduce this on?
We've got the same issue when updating to 4.1.2
. I don't know if this helps but we've got a mono repo setup and from what I can tell it can't find the loadable-stats-build-javascript.json
file since it's trying to find it in the plugin directory inside the node_modules
folder instead of the projects folder where the .cache
directory is as @Leksat pointed out.
I got the same issue when I've deleted the .cache folder, I didn't update anything, I'm on Mac 13 m1.
Can't run the project. Any fast workarounds?
I got the same issue when I've deleted the .cache folder, I didn't update anything, I'm on Mac 13 m1.
Can't run the project. Any fast workarounds?
If you install 4.1.1, you should be able to avoid this error.
@reilnuud that didn't help I've tried. I actually didn't change the version just after the cache was deleted by me it stopped to work not sure how it happened.
@graysonhicks I did some debugging. And I am sure that the 'loadable-stats-build-javascript.json' is created not at the right time(after it was requested by the module).
What steps I've made?
Please can you check the lifecycle and ensure that the 'loadable-stats-build-javascript.json' was created in the time as requested by the module? Let me know if I can help you debug it in my environment.
UPD: Can confirm that I could run ^4.1.2 by following the steps above.
One thing that I think needs to happen is the plugin will essentially be ignored in develop because it's not necessary and is where I think this error occurs.
After that, build with v4 and DSG should work and this error would go away in develop.
I opened PR with essentially what @graysonhicks mentioned ("ignoring" develop) - https://github.com/graysonhicks/gatsby-plugin-loadable-components-ssr/pull/51 (so plugin should be no-op for develop, but continue to add Githubissues.
Hi,
I am experiencing an error on
gatsby develop
andgatsby build
. Essentially the new location forloadable-stats-build-javascript.json
in the latest version cannot be resolved during the SSR phase.From my testing,
process.cwd()
resolves to/
during the gatsby SSR phase. Therefore, the resulting json file path ingatsby-ssr
is/.cache/page-ssr/loadable-stats-build-javascript.json
(note the leading slash/
and not./
)One option to fix this is to export only the relative path from
constant.js
and then in
gatsby-node
and in
gatsby-ssr
:I am happy to submit a PR if needed.