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

How to treat imports inside a monorepo as internal #1125

Closed
bensampaio opened this issue Jun 26, 2018 · 5 comments · Fixed by #1491
Closed

How to treat imports inside a monorepo as internal #1125

bensampaio opened this issue Jun 26, 2018 · 5 comments · Fixed by #1491

Comments

@bensampaio
Copy link

I am working on a monorepo where I have some files with a list of imports that looks like this:

import React from 'react';

import MyComponent from '@my/src/MyComponent';

import styles from './styles.scss';

In this example, the second import refers to a package inside the monorepo and I would like it to be treated as an internal import by import/order. Is this possible to achieve?

@ljharb
Copy link
Member

ljharb commented Jun 26, 2018

Since technically it’s not internal - that syntax is for npm-installed scoped modules - i don’t believe it’s currently possible.

@bensampaio
Copy link
Author

Would it be possible to add an option to import/order that allows you to pass a regex to identify internal imports? In that way I could simply specify that all internal imports start with @my.

@ljharb
Copy link
Member

ljharb commented Jul 10, 2018

Is it not an option to use a prefix that isn't also a valid npm package name?

@bensampaio
Copy link
Author

I don't think that is possible in a monorepo. The packages inside a monorepo will always have valid package names since you have to create a package.json for each one of them. Besides that, I need my packages in the monorepo to be scoped. This is also how other projects like babel and jest are doing it.

Another option would also be to check via the root package.json if the current project is a monorepo, to determine where the modules are located and consider those internal (I mean by reading the workspaces property). Or is this the wrong way around?

@loopmode
Copy link

I think it should simply be possible for us to specify what's treated as "internal".
See also my comment in #807 (comment), which actually belongs here rather than in the other issue.

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

Successfully merging a pull request may close this issue.

3 participants