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
  • !3566

Target specific node modules with babel.

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/XerxesNoble/babel-target-node-modules into master Dec 08, 2017
  • Overview 4
  • Commits 2
  • Pipelines 0
  • Changes 2

Created by: XerxesNoble

The pull request is motivated by: https://github.com/facebookincubator/create-react-app/issues/1125

From what I gathered from the thread, the only reason node_modules was not included in the babel transpile is because of performance, and the make perfect sense. However, app developers should at least be able to specify what modules they need transpiled.

Each module inside node_modules the applications requires to be transpiled can be specified in the applications package.json through the new property transpileDependencies.

Example

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-scripts": "file:../packages/react-scripts/react-scripts-1.0.17.tgz",
    "@my-org/some-es6-module": "^0.0.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "transpileDependencies": [
    "@my-org/some-es6-module"
  ]
}

According to CONTRIBUTING.md this goes against the Core Ideas of the software, but I couldn't think of a better way (with my limited knowledge of this software) to implement this. Perhaps this will just serve as a concept.

Initially I wanted to make these changes to packages/react-scripts/config/paths.js as that is where most paths are kept, however, this is a dynamic list of paths, so I opted to add the code into each webpack config file.

Test Plan

Not the most ideal, but I verified this change with the following steps

  • npm run create-react-app my-app
  • cd my-app
  • npm install @my-org/some-es6-module
  • npm start / npm run build
  • *Verify the source code was transpiled.
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/XerxesNoble/babel-target-node-modules