react / react/metro

Is there a clean way to pass custom options for a transformer?

Open
#127 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
5.6k
Forks
696
Avg merge
8m
Merged PRs (30d)
7

Description

I have created a couple of custom transformers for React Native (e.g. https://github.com/kristerkari/react-native-css-transformer).

Is there a clean way to add custom options for a transformer? So far I haven't found a way. I could always wrap the transformer and extend the options object, but it would be nice to have a way to do it from rn-cli.config.js.

Currently I can only add the extensions and the module/filename of the transfomer:

module.exports = {
  getTransformModulePath() {
    return require.resolve("react-native-css-transformer");
  },
  getSourceExts() {
    return ["css"];
  }
};

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the rn-cli.config.js entry points getTransformModulePath() and getSourceExts(), then trace how Metro passes configuration to custom transformers. Define completion as allowing transformer-specific options to be supplied from rn-cli.config.js without requiring a wrapper, with coverage for the documented configuration behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.