🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

metro-transformer-registry

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metro-transformer-registry

Use multiple transformer for metro-bundler, the main bundler of react-native

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

Metro-Transformer-Registry

Use different transformers in metro-bundler, which is the main bundler for react-native

Usage

First install dependencies:

yarn add metro-transformer-registry

Config your 'rn-cli.config.js'

'use strict';

const path = require('path');
const blacklist = require('metro-bundler/src/blacklist');

const config = {
  // Define file extensions for every source code.
  getSourceExts() {
    return ['js', 'json', 'ts', 'tsx', 'txt'];
  },

  // Use Metro-Transformer-Registry as transformer entry.
  getTransformModulePath() {
    return require.resolve('metro-transformer-registry');
  },

  // Define every rule list.
  getTransformRuleList() {
    return [
      {
        include: '/\.tsx?$',
        transformer: require('metro-transformer-registry/transformers/typescript'),
      },
      {
        include: '/\.txt$',
        transformer: require('metro-transformer-registry/transformers/raw'),
      },
    ]
  }
};

module.exports = config;

If you wish to use typescript with react native, you also should install following dependencies:

yarn add typescript sourcemap

and add a tsconfig.json file:

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es5",
    "sourceMap": true,
    "jsx": "react",
    "strict": true,
    "importHelpers": true,
    "noImplicitAny": true,
    "experimentalDecorators": true,
    "outDir": "./lib",
    "rootDir": "./src",
    "lib": [
      "es5",
      "es6",
      "es2015",
      "DOM"
    ]
  },
  "compileOnSave": false,
  "exclude": [
    "node_modules"
  ]
}

FAQs

Package last updated on 01 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts