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

Add types resolutions to package.json exports field to support NodeNext/Node16 module resolution. #196

Closed
wants to merge 1 commit into from

Conversation

ssalbdivad
Copy link

Hey there! First of all wanted to thank you for building this very useful and underappreciated library :-) It's clear how much care was put into ensuring it works across all flavors of JS in the JS/TS ecosystem!

TS 4.7 added "NodeNext" and "Node16" as possible settings for "compilerOptions/moduleResolution" in tsconfig.json.

If either of these settings are used, TS is no longer enable to resolve the types for get-current-line:

image

As a temporary workaround, I explicitly added get-current-line's types to my tsconfig's mapped "paths":

{
    "extends": "../../tsconfig",
    "compilerOptions": {
        "paths": {
            "get-current-line": [
                "./node_modules/get-current-line/compiled-types/index.d.ts"
            ]
        }
    }
}

Unfortunately, this kind of problem can be quite tricky to resolve for developers who are relatively new to the quirks of Node/TypeScript's module resolution behavior.

I added a reference to the package's types in the package.json "exports" map, and, based on some very superficial testing, the types appear to be resolvable in all Node environments by default. I'm not sure what impact this might have in non-Node environments, but none seems like a safe assumption (or at least nothing should break 🤣).

Thanks again for the great work, and wishing you all the best!

@ssalbdivad
Copy link
Author

Closed as duplicate of #187

@balupton
Copy link
Member

this should now be resolved with v6.10.0
fb441a2#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519

shoutout to my GitHub Sponsors for affording me the time to make this happen

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

Successfully merging this pull request may close these issues.

2 participants