Skip to content

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

@jpaas

Description

@jpaas

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions