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

can't load external file #6305

Closed
fatfatson opened this issue May 15, 2018 · 7 comments
Closed

can't load external file #6305

fatfatson opened this issue May 15, 2018 · 7 comments

Comments

@fatfatson
Copy link

in react-native, we can load external file(out of project directory) by many ways, such as

  1. extraNodeModules in rn-cli.js
  2. projectRoots in rn-cli.js
  3. babel-plugin-module-resolver

but none of them could be used in flow-bin,
so how can we load external file in flow checking?

@mrkev
Copy link
Contributor

mrkev commented May 20, 2018

not sure I understand what you mean / want to achieve. Care to elaborate?

@fatfatson
Copy link
Author

@mrkev for example, I have below diretory structure:
project
  |--common
  |   |--tools.js
  |--client
  |--server

both client and server will use some files in common
in ReactNative client, I can use a rn-cli config file for adding common to projectRoots and
import 'common/tools' will work
but flow could not load the files in common

@mrkev
Copy link
Contributor

mrkev commented May 21, 2018

That's odd. Flow should low everything you import on your file tree.

  1. Is your .flowconfig on the root of your project (right under project)?
  2. Do you have anything in your .flowconfig that might be blocking common from being imported?

@fatfatson
Copy link
Author

I'm running react-native and flow in client,
common is not visible to them normally.
however react-native has a rn-cli.js config to work around it,
but how could flow recegonize common/tools is in another directory outside the root?

@mrkev
Copy link
Contributor

mrkev commented May 21, 2018

This functionality is documented: https://flow.org/en/docs/config/include/

@mrkev mrkev closed this as completed May 21, 2018
@fatfatson
Copy link
Author

no, it does not work!
create a new project by react-native init ph
add the below line to index.js:

import { bindThis } from "tools.js";

and below to .flowconfig:

[include]
../common/
../common/*.js

running flow will complains:

Cannot resolve module tools.js.

4| import { bindThis } from "tools.js";
^^^^^^^^^^

@mrkev
Copy link
Contributor

mrkev commented May 21, 2018

import { bindThis } from "../common/tools.js";

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

2 participants