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

Feature request: flow-node should follow symlinks in monorepo #8872

Open
debel27 opened this issue Apr 15, 2022 · 0 comments
Open

Feature request: flow-node should follow symlinks in monorepo #8872

debel27 opened this issue Apr 15, 2022 · 0 comments

Comments

@debel27
Copy link

debel27 commented Apr 15, 2022

Proposal

Currently, whenever flow-node (from the flow-remove-types package) encounters a require statement, it considers the contents of that package to be written in Flow.

However, this is not the case for Node packages written with import statements.

This is an issue if the import specifier refers to a symlinked package inside the same monorepo. The developer would expect flow-node to transpile the contents of such packages.

Use case

Consider a monorepo project with two packages: package-a and package-b

packages
├── package-a
│   ├── index.js
│   └── package.json
└── package-b
    ├── index.js
    └── package.json

The contents of package-a/index.js are

// @flow
export function log(str: string) {
  console.log(str);
}

The contents of package-b/index.js are

// @flow
import { log } from "package-a";
log("abc");

When running npx flow-node packages/package-b/index.js, you'll get an error because flow-node won't understand the flow syntax in package-a.

export function log(str: string) {
                       ^

SyntaxError: Unexpected token ':'
    at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:139:18)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:236:14)

When removing the type annotations, or converting packages to use exports/require statements, it works.

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

No branches or pull requests

1 participant