Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !2775

CRA_BABEL_PRESET_FILE to handle optional dependencies.

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/kogosoftwarellc/optional-babel-dependencies into master Jul 12, 2017
  • Overview 11
  • Commits 1
  • Pipelines 0
  • Changes 2

Created by: jsdevel

  • This will allow for optional babel dependencies to be added without ejecting cra.
  • CRA_BABEL_PRESET_FILE=relative/path/to/babel/preset can be added to package.json.

I verified this locally by copying index.js to node_modules/babel-preset-react-app/index.js within one of my projects. Here is the package.json for my project:

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "babel-plugin-relay": "^1.1.0",
    "react": "^15.6.1",
    "react-dom": "^15.6.1",
    "react-router-dom": "^4.1.1",
    "react-scripts": "1.0.10",
    "shared-git-hooks": "^1.2.1"
  },
  "scripts": {
    "start": "CRA_BABEL_PRESET_FILE=.babel-preset-react-app react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "homepage": "."
}

I'm doing this because I want to use relay modern in my app. My .babel-preset-react-app.js file is exactly what @maletor had in PR https://github.com/facebookincubator/create-react-app/pull/2343

cc @gaearon Is this an acceptable approach per your comment https://github.com/facebookincubator/create-react-app/pull/2343#issuecomment-311409607 ?

Also relates to #2001 (closed)

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/kogosoftwarellc/optional-babel-dependencies