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

Support setting baseUrl to root directory

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/rovansteen/baseurl-root into master Sep 30, 2019
  • Overview 6
  • Commits 1
  • Pipelines 0
  • Changes 3

Created by: rovansteen

This PR adds support for setting the baseUrl in tsconfig.json/jsconfig.json to the root directory (.).

Initially I planned to add support for aliases but that turned out to be quite difficult due to difference in implementation between webpack and TypeScript. Instead this PR aims to facility the most requested option to import files with their absolute path (as seen from root) like src/components/Button.js. (https://github.com/facebook/create-react-app/issues/6850)

We don't want users to import from any directory other than src so the implementation maps a baseUrl of . to an alias that transforms src to the absolute appSrc directory. This should prevent users from doing something like import { something } from 'library/utils.js'.

  • Update error message to communicate that . is allowed as baseUrl
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/rovansteen/baseurl-root