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

[import/no-unresolved] when importing from another package in a monorepo #210

Open
tpluscode opened this issue Jan 30, 2023 · 6 comments
Open

Comments

@tpluscode
Copy link

Specifically, I have a package with an export map like this

{
  "name": "@hydrofoil/roadshow-ng",
  "exports": {
    ".": "./index.js",
    "./rs-view.js": "./rs-view.js",
    "./viewers.js": "./viewers.js"
  }
}

In other packages I import '@hydrofoil/roadshow-ng/rs-view.js' etc. This gets reported as unresolved.

Interestingly, if I drop the extension or change to .ts, the import plugin no longer complains...

@tpluscode
Copy link
Author

Anyone?

@simondean
Copy link

Hi. This fixed a similar issue for me. I didn't need to add a exports entry to my package.json files though.

I fixed my issue by adding this to my eslint.cjs file in the root of my monorepo:

    parserOptions: {
        project: ['tsconfig.json', 'packages/*/tsconfig.json'],
        node: true,
    },
    settings: {
        'import/parsers': {
            '@typescript-eslint/parser': ['.ts'],
        },
        'import/resolver': {
            typescript: {
                // See https://github.com/import-js/eslint-import-resolver-typescript for documentation of these settings
                // This `project` entry is needed, in addition to the `project` entry above under `parserOptions`,
                // otherwise eslint-plugin-import's `import/no-unused-modules` rule will not work correctly
                project: ['tsconfig.json', 'packages/*/tsconfig.json'],
            },
        },
    },

@JounQin
Copy link
Collaborator

JounQin commented Dec 6, 2023

@tpluscode Sorry I'm very late here, can you please provide an online runnable reproduction?

tpluscode added a commit to tminuscode/resolver-typescript-package-exports that referenced this issue Dec 6, 2023
@tpluscode
Copy link
Author

@JounQin: https://github.com/tminuscode/resolver-typescript-package-exports

@tpluscode
Copy link
Author

Have you had a chance to to look into it @JounQin \

@JounQin
Copy link
Collaborator

JounQin commented Mar 26, 2024

See #275 and webpack/enhanced-resolve#413

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

No branches or pull requests

3 participants