Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Custom build time extension #200

Closed
alburdette619 opened this issue Jan 10, 2024 · 4 comments
Closed

Custom build time extension #200

alburdette619 opened this issue Jan 10, 2024 · 4 comments

Comments

@alburdette619
Copy link

alburdette619 commented Jan 10, 2024

I have a project that has build time extensions in React Native, like #4, but for app white labels. So expand the concepts of that issue to:

Body.tsx
Body.android.tsx
Boby.ios.tsx
Body.native.tsx
Body.xyz.tsx
Body.abc.tsx

We don't use the .android/ios/native, but do use .xyz/abc. Is there any way to use the configuration to have unimported sense these files as imported under special conditions like the other RN files? I have added them to my extensions like I see here, but I'm not sure how to customize my entry to enable this or if it's possible.

Simply ignoring files with these extensions shows some other files as unimported erroneously.

@alburdette619
Copy link
Author

alburdette619 commented Jan 10, 2024

...or if it's possible

#96 may be the answer to this currently, but it seems like the typing for config allows objects for entry items.

@alburdette619
Copy link
Author

alburdette619 commented Jan 12, 2024

I tried the following config to mimic what is in the preset for RN, but it didn't seem to work. I tried adding an index.xyz.js & updating the corresponding entry's file & extensions, but that didn't seem to help & only reported the new file as unimported.

{

  "entry": [
    {
      "file": "index.js",
      "label": "android",
      "extend": {
        "extensions": [
          ".android.js",
          ".android.ts",
          ".android.tsx",
          ".native.js",
          ".native.ts",
          ".native.tsx",
          ".js",
          ".ts",
          ".tsx"
        ]
      }
    },
    {
      "file": "index.js",
      "label": "ios",
      "extend": {
        "extensions": [
          ".ios.js",
          ".ios.ts",
          ".ios.tsx",
          ".native.js",
          ".native.ts",
          ".native.tsx",
          ".js",
          ".ts",
          ".tsx"
        ]
      }
    },
    {
      "file": "index.js",
      "label": "xyz",
      "extend": {
        "extensions": [".ts", ".tsx", ".js", ".xyz.ts", ".xyz.tsx"]
      }
    },
    {
      "file": "index.js",
      "label": "abc",
      "extend": {
        "extensions": [".ts", ".tsx", ".js", ".abc.ts", ".abc.tsx"]
      }
    }
  ],
  "extensions": [
    ".ts",
    ".tsx",
    ".js"
  ],
...
}

@alburdette619
Copy link
Author

Figured this out, apparently it came down to not having the base config extensions in each entry's extend.extensions. I'm still getting reports for xyz files but they are actually unimported.

@alburdette619
Copy link
Author

alburdette619 commented Jan 12, 2024

To support this fully, below is my entry & extensions from my config. Firstly, I was wrong, we do use the platform extensions. The android & ios extensions had to be added to the base config, there were issues resolving without this. But they also had to be listed in their entry extend.extensions or I'd get false positives.

{
  "entry": [
    {
      "file": "index.js",
      "label": "android",
      "extend": {
        "extensions": [".android.js", ".android.ts", ".android.tsx"]
      }
    },
    {
      "file": "index.js",
      "label": "ios",
      "extend": {
        "extensions": [".ios.js", ".ios.ts", ".ios.tsx"]
      }
    },
    {
      "file": "index.js",
      "label": "abc",
      "extend": {
        "extensions": [".abc.js", ".abc.jsx", ".abc.ts", ".abc.tsx"]
      }
    },
    {
      "file": "index.js",
      "label": "xyz",
      "extend": {
        "extensions": [".xyz.js", ".xyz.jsx", ".xyz.ts", ".xyz.tsx"]
      }
    }
  ],
  "extensions": [
    ".android.js",
    ".android.ts",
    ".android.tsx",
    ".d.ts",
    ".ios.js",
    ".ios.ts",
    ".ios.tsx",
    ".js",
    ".jsx",
    ".ts",
    ".tsx"
  ],
...
}

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

No branches or pull requests

1 participant