New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot 'resolveSync' because the fileSystem is not sync #845
Comments
I had the same problem. next.js: 11.1.2, 11.1.0 (with webpack 5, with webpack 4) |
Here is a reproduction of the bug: bug.zip It is caused by a Resolve plugin which gets injected automatically by the jsconfig-paths-plugin as soon as you specify paths inside I asked the next team to fix it on their side: vercel/next.js#29410 |
@jantimon v3.0.0-beta.13 resolveSync code:https://github.com/callstack/linaria/blob/c49df269ebbbc956d43720b007a92f9f865662c5/packages/webpack5-loader/src/index.ts#L59 v3.0.0-beta.7 resolveSync code: but |
@J-env webpack-loader is only a small helper to load either webpack4-loader or webpack5-loader the resolve code of linaria is not the problem - linaria is using webpacks resolving logic. unfortunately the webpack resolving logic is sometimes sync and sometimes async depending on the webpack config. next js ships with a webpack config which will be sync by default but async as soon as tsconfig includes a paths mapping as soon as enhanced-require detects an async resolution hook it throws the best solution on linaria side would be to go from sync to async but that's not possible right now as babel does not allow aysnc path resolution (babel/babel#13798) |
@Anber I managed to fix it on nextjs side: vercel/next.js#29421 I also found a solution which is probably better than the current one as it has the following advantages:
however it comes also with disadvantage:
the solution would be to use webpacks this.importModule loader api which was developed exactly for cases like linaria |
@jantimon that's an interesting proposal!
It's not a problem, since we have different packages for v4 and v5.
It can be a problem, but maybe we can use those changes in other loaders too. |
Cool :) I'll try to find some time for a POC this week |
I have a first (very very limited) POC up and running 🎉 If you like we can have a short call next week to take a look :) |
Hi @jantimon! Looks like the problem is deeper than a simple bug in css-loader. Do you have any updates? |
I found a workaround for now but I'll also file a webpack bug |
So… is it still possible to implement a fix for webpack 5? |
Yes I have a first POC up and running for webpack 5. When the webpack loader is called for a source file 'foo.js' it will:
it would be easier to demonstrate and elaborate on next steps in a call - @Anber do you have time for a call next week? |
Next v11.1.3-canary.66 ships with a fix https://github.com/vercel/next.js/releases/tag/v11.1.3-canary.66 (it's only a stop gap solution and might not work in all cases) |
I've just added a fallback to the default configuration if an async plugin is detected. I hope it will allow releasing 3.0 without introducing significant changes suggested by @jantimon. However, I'm still interested in a better solution. @jantimon, can you open a PR with the implementation of your approach? |
It's rather a POC than a working PR.. but right now I set it on hold because Vercel is moving away from Babel.. |
I can confirm nextjs 12 works with linaria @ beta |
Ok, let's close this issue for now. Maybe I'll find time for supporting SWC. |
Environment
Description
Can't get linaria up and running as the @linaria/webpack-loader throws an error:
Reproducible Demo
Here is a reproduction of the bug: bug.zip
related issues:
The text was updated successfully, but these errors were encountered: