Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Presence of .flowconfig causing module resolve issues #21

Closed
mwalkerwells opened this issue Sep 10, 2016 · 5 comments
Closed

Presence of .flowconfig causing module resolve issues #21

mwalkerwells opened this issue Sep 10, 2016 · 5 comments

Comments

@mwalkerwells
Copy link
Contributor

mwalkerwells commented Sep 10, 2016

Not sure what the fix is (other than removing the .flowconfig file on a build step), but wanted to bring this to your attention.

Flow 0.32.0

Error:

This modules resolves to "<<PROJECT_ROOT>>/../assert/package.json", which is outside both your root directory and all of the entries in the [include] section of your .flowconfig. You should either add this directory to the [include] section of your .flowconfig, move your .flowconfig file higher in the project directory tree, or move this package under your Flow root directory.

Files:
test.zip

Read up on something similar here: facebook/flow#1891

Before removing .flowconfig in /node_modules/flow-static-land/
screen shot 2016-09-09 at 7 38 46 pm

After removing .flowconfig in /node_modules/flow-static-land/
screen shot 2016-09-09 at 7 39 35 pm

@mwalkerwells
Copy link
Contributor Author

I couldn't figure out a way to tell Flow not to actually type check the library, yet still get the type definitions on module import. Removing the .flowconfig file was the way I accomplished this.

There is the new "flow gen-flow-files": https://github.com/facebook/flow/releases/tag/v0.32.0

@gcanti
Copy link
Owner

gcanti commented Sep 10, 2016

Being this repo experimental I didn't put much love in the distribution problem so far. I guess it's time to publish a first release.

Here's my plan:

  • move all the source files in a src dir
  • compile the source files with babel to a lib dir
  • use flow-copy-source in order to copy the sources files to lib with the .flow suffix appended to the filename (named "shadow files", see No simple way to author and share flow packages. facebook/flow#1996 for context)
  • maybe find a better name for the project? (flow-static-land/lib/<thing> seems a bit verbose as import)
  • publish a 0.1.0 version on npm

Then, as usual, one can install flow-static-land with npm install flow-static-land --save and use it like this

// @flow
import * as arr from 'flow-static-land/lib/Arr' // <= note the /lib here

arr.map(n => n * 2, arr.inj(['a'])) // <= error

@mwalkerwells
Copy link
Contributor Author

My 2 cents re: module imports:

import { Monad, Monoid, Functor } from './flow-static-land';

@gcanti
Copy link
Owner

gcanti commented Sep 11, 2016

That would be handy but it means you end up importing all the modules, even those which you don't actually use in your app.

Another option, which seems more flexible, is to define your own prelude. So instead of:

// app.js
import * as arr from 'flow-static-land/lib/Arr'
import * as maybe from 'flow-static-land/lib/Maybe'
import * as tuple from 'flow-static-land/lib/Tuple'

// your code here

you first define a prelude.js containing only the relevant modules for your app and then you just import the prelude

// prelude.js
import type { Arr } from 'flow-static-land/lib/Arr'
import type { Maybe } from 'flow-static-land/lib/Maybe'
import type { Tuple } from 'flow-static-land/lib/Tuple'

import * as arr from 'flow-static-land/lib/Arr'
import * as maybe from 'flow-static-land/lib/Maybe'
import * as tuple from 'flow-static-land/lib/Tuple'

export type {
  Arr,
  Maybe,
  Tuple
}

export {
  arr,
  maybe,
  tuple
}
// app.js
import { arr, maybe, tuple } from './prelude'

// your code here

gcanti added a commit that referenced this issue Sep 12, 2016
gcanti added a commit that referenced this issue Sep 12, 2016
@gcanti
Copy link
Owner

gcanti commented Sep 12, 2016

Published a first version on npm (https://github.com/gcanti/flow-static-land/releases/tag/0.1.0)

@gcanti gcanti closed this as completed Sep 12, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants