Skip to content
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 resolve fibers in optimism #6

Closed
viztor opened this issue Aug 1, 2018 · 11 comments
Closed

Cannot resolve fibers in optimism #6

viztor opened this issue Aug 1, 2018 · 11 comments

Comments

@viztor
Copy link

viztor commented Aug 1, 2018

WARNING in ./node_modules/optimism/lib/local.js

Module not found: Error: Can't resolve 'fibers' in '/Users/***/node_modules/optimism/lib'
@ ./node_modules/optimism/lib/local.js
@ ./node_modules/optimism/lib/index.js
@ ./node_modules/apollo-cache-inmemory/lib/optimism.js
@ ./node_modules/apollo-cache-inmemory/lib/readFromStore.js
@ ./node_modules/apollo-cache-inmemory/lib/index.js

@benjamn
Copy link
Owner

benjamn commented Aug 1, 2018

What version of optimism are you using?

@CAJazzer
Copy link

CAJazzer commented Aug 1, 2018

Got this also with [email protected]

@benjamn
Copy link
Owner

benjamn commented Aug 1, 2018

What bundler are you using? Webpack? Rollup? Something else? The import of fibers should fail and be caught, so any error reported by your bundler is a false positive:

optimism/lib/local.js

Lines 11 to 18 in 84624ab

try {
var Fiber = module.require("fibers");
// If we were able to require fibers, redefine the getCurrentFiber
// function so that it has a chance to return Fiber.current.
getCurrentFiber = function () {
return Fiber.current || fakeNullFiber;
};
} catch (e) {}

Please feel free to provide any more information that seems relevant.

@viztor
Copy link
Author

viztor commented Aug 2, 2018

I'm using Webpack. It is just a warning
I was just bit confused and concerned if there were something wrong on my end.
From your reply, It appears it's just a global-checking mechanism.

I guess this post can serve to that others won't be concerned about it when searched it online.

I'm not sure how other lib handle things like this, or maybe there's something wrong with my webpack config?

yarn said the following:

apollo-cache-inmemory@^1.3.0-beta.6:
  version "1.3.0-beta.6"
  resolved "***"
  dependencies:
    apollo-cache "^1.1.13"
    apollo-utilities "^1.0.17"
    optimism "^0.6.5"

optimism@^0.6.5:
  version "0.6.5"
  resolved "***"
  dependencies:
    immutable-tuple "^0.4.4"

@CAJazzer
Copy link

CAJazzer commented Aug 2, 2018

Webpack also. Thanks.

@kevinmarrec
Copy link

Got the warning too, using apollo-cache-inmemory which depends on optimism

@swernerx
Copy link

swernerx commented Aug 3, 2018

I see the same warning - also using apollo inmemory cache. Looks like index.js is importing local.js which is importing fibers, but fibers is only declared as a devDepenency.

@Torsten85
Copy link

Torsten85 commented Aug 3, 2018

This happens with webpack >= 4.16.2: https://github.com/webpack/webpack/releases/tag/v4.16.2
Related change: handle module.require like require

Here is an related issue: webpack/webpack#7777

@viztor
Copy link
Author

viztor commented Aug 14, 2018

Any plan on fixing it?

@benjamn
Copy link
Owner

benjamn commented Aug 14, 2018

Does everyone understand the point of the code in question?

The goal is to import fibers if and only if the package is installed in node_modules, and otherwise silently swallow the exception. Webpack is attempting to be "helpful" with webpack/webpack#7750, but fails to accommodate this legitimate use case (which works fine in Node and other runtime module systems)—another noisy warning perched precariously atop a mountain of unspecified hacks. Just so everyone is on the same page.

We've already "fixed" this sort of problem once before, but I suppose we will have to keep working around Webpack's unsound and incomplete attempts to statically analyze this code.

@benjamn
Copy link
Owner

benjamn commented Aug 14, 2018

This approach (just published in [email protected]) ought to buy us some time:

var Fiber = module["eriuqer".split("").reverse().join("")]("fibers");

Your move, Webpack. But also… could you just… not? 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants