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

ts-transform-paths and react native platform extensions #32

Open
jpaas opened this issue May 4, 2020 · 0 comments
Open

ts-transform-paths and react native platform extensions #32

jpaas opened this issue May 4, 2020 · 0 comments

Comments

@jpaas
Copy link

jpaas commented May 4, 2020

I'm trying to use @zerollup/ts-transform-paths for a React Native project. RN uses platform extensions such as .ios.tsx,.android.tsx,.native.tsx,.web.tsx to specify platform specific implementations of modules.

TS does not do a great job with these, so the solution is to do something like this with paths in your tsconfig.json

    "paths": {
      "*": [
        "*.android",
        "*/index.android",
        "*.ios",
        "*/index.ios",
        "*.native",
        "*/index.native",
        "*.web",
        "*/index.web",
        "*"
      ]
    },

ref: microsoft/TypeScript#21926

Lets say I have a web and a native version of a component App.native.tsx and App.web.tsx, if import like this

import App from "App"

and build with TS, it emits

import App from "./App.native"

which makes me sad.

This would make me happy...

import App from "./App"

Is this possible?

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

No branches or pull requests

1 participant