flow/flow-bin

Flow is not compatible with ESM (ES6 Node Modules)

Closed this issue · 2 comments

__filename and __dirname are no longer available with the new ESM specs.

Flow is unable to parse the new import.meta.url property, which is used to resolve __filename and __dirname:

import { fileURLToPath } from 'url'
import { dirname } from 'path'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

Returns the error:

Unexpected token .

I am no longer able to type check files that require those informations.

I tried to go and see if I can make a PR, I'm pretty sure it's related to this, but I have no knowledge of the ML language, and as it's a pretty abnormal language I can't even try without going through a lot of learning about it.

I think it should be a pretty simple thing to implement, and it's pretty important for the future of Node (as right now it's an experimental feature, even if we decided to enable it in production as it's pretty much stable).

mroch commented

this is being tracked in facebook/flow#6913

thanks for the report! this is useful context.