Flow: Cannot resolve JSON file starting with a dot

Created on 26 Apr 2019  ยท  12Comments  ยท  Source: facebook/flow

Flow version:

version 0.97.0

Flow cannot resolve require with JSON filename starting with a dot:

const meta = require('../.meta.json');

It results in this error:

Error โ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆ src/apps/graphql-skymock/datasets/__tests__/MetafileConsistency.test.js:7:22

Cannot resolve module ../.meta.json.

      4โ”‚ import path from 'path';
      5โ”‚ import Ajv from 'ajv';
      6โ”‚
      7โ”‚ const meta = require('../.meta.json');
      8โ”‚
      9โ”‚ test('every dataset defined in metafile should exist', () => {
     10โ”‚   expect.hasAssertions();

However, when I remove the dot (and rename the file) everything is fine:

const meta = require('../meta.json');
No errors!

Thank you very much for checking it! :)

Has PR bug good first issue module resolution

Most helpful comment

I create a PR, #8045

All 12 comments

This is true even for JS files (.meta.js).

Yeah, Flow ignores all dotfiles, it probably should check if they have extension .meta vs .meta.js

Can I opt-out from this? I know it's unusual to start with a dot so it's not very common but it really makes sense in my case. Why does Flow ignore dot files by default?

No idea, it also wouldn't work with [include]

Maybe you can try symlinks

Hi, can I work on this ?

@gabrielrumiranda Sure you can, what you want to know about codebase?

@goodmind is my first contribution in project, i don't know much about codebase. The module who works with imports is flow/src/typing/import_export.ml ?

@goodmind the tests of this part of code is in tests/declarations_files_node ?

Not sure where the tests should be, maybe new folder?

I create a PR, #8045

Was this page helpful?
0 / 5 - 0 ratings