Skip to content

Fix baseUrl for NODE_PATH=src #5692

Closed
Closed

Description

@Timer

title

Activity

  1. added this to the 2.1.2 milestone on Nov 2, 2018
  2. niekert commented on Nov 3, 2018

    @niekert

    Out of curiosity, would this allow absolute imports in TS apps created with create-react-app?

    I've been trying to get it working and remember setting the NODE_PATH for JS projects. Loving the Typescript support 🙏

  3. Timer commented on Nov 3, 2018

    @Timer
    ContributorAuthor

    Yes, this will start permitting absolute imports in TS apps.

  4. tddyco commented on Nov 5, 2018

    @tddyco

    Will this work with NODE_PATH=. as well?

    I use this because it forces referencing src/, removing any ambiguity as to what is being imported.

  5. Timer commented on Nov 5, 2018

    @Timer
    ContributorAuthor

    Not sure if we'll allow . or not, there's always #5118 which will let you import via @/.

  6. dawnmist commented on Nov 6, 2018

    @dawnmist

    We use the same as @tkazec, so that instead of having to have a dozen different absolute paths (plus paths for files that were under src itself...I'm not sure how src/App.ts would be referenced without the src prefix present) we only had one, and thus had a lot less risk of a name clash between one of our folders and an npm package name.

  7. unzico commented on Nov 18, 2018

    @unzico

    @niekert
    If you're looking for a way to enable absolute path imports, see #5118 (comment)

  8. modified the milestones: 2.1.2, 2.1.3 on Dec 23, 2018
  9. modified the milestones: 2.1.3, 2.1.4 on Jan 4, 2019
  10. modified the milestones: 2.1.4, 2.1.5 on Feb 10, 2019
  11. jamesg1 commented on Feb 11, 2019

    @jamesg1

    Adding "baseUrl": "./src", to my compilerOptions options in tsconfig.json worked for me.

  12. mindjuice commented on Mar 5, 2019

    @mindjuice

    @jamesg1 That's been working for me for over a year too, but on this new project, whenever I run yarn start, the baseUrl entry is removed from tsconfig.json!

    Anyone have a way to prevent this?

  13. jamesg1 commented on Mar 5, 2019

    @jamesg1

    @mindjuice Yeah I think there was a change which resets the baseUrl might have to use react rewired.

    See #5118 (comment)

  14. agido-freudenreich commented on Mar 5, 2019

    @agido-freudenreich

    @mindjuice The tsconfig is rewritten on every start. You have to use extends (#5645 (comment))

  15. modified the milestones: 2.1.6, 2.1.x, 3.x on Mar 6, 2019
  16. added a commit that references this issue on Apr 11, 2019
  17. iansu commented on Apr 23, 2019

    @iansu
    Contributor

    We now support setting baseUrl in tsconfig.json (and jsconfig.json). Currently you can only set it to node_modules (the default) and src. We are hoping to add support for aliases in the near future and may look at relaxing the restriction on baseUrl.

    NODE_PATH is now deprecated and since you can just set baseUrl directly I think this can be closed.

  18. locked and limited conversation to collaborators on Apr 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions