Skip to content

Version 1.10.1 breaks absolute paths in typescript #2068

Closed
@iRoachie

Description

@iRoachie

🐛 bug report

When updating to version 1.10.0 of parcel-bundler from 1.9.7, absolute paths in typescript are no longer working.

🎛 Configuration (.babelrc, package.json, cli command)

// package.json
{
  "name": "register",
  "version": "1.0.0",
  "main": "src/index.js",
  "private": true,
  "license": "MIT",
  "scripts": {
    "start": "parcel public/index.html",
    "build": "parcel build public/index.html",
    "lint": "tslint -c tslint.json --project tsconfig.json 'src/**/*.ts?(x)'",
    "precommit": "lint-staged"
  },
  "devDependencies": {
    "@types/react": "^16.4.14",
    "@types/react-document-title": "^2.0.3",
    "@types/react-dom": "^16.0.7",
    "@types/react-router-dom": "^4.3.1",
    "husky": "^0.14.3",
    "lint-staged": "^7.2.2",
    "parcel-bundler": "^1.10.1",
    "parcel-plugin-typescript": "^1.0.0",
    "prettier": "^1.14.2",
    "tslint": "^5.11.0",
    "tslint-config-airbnb": "^5.11.0",
    "tslint-config-prettier": "^1.15.0",
    "tslint-react": "^3.6.0",
    "typescript": "^3.0.3"
  },
  "dependencies": {
    "antd": "^3.9.2",
    "date-fns": "^1.29.0",
    "firebase": "^5.5.0",
    "react": "^16.5.1",
    "react-document-title": "^2.0.3",
    "react-dom": "^16.5.1",
    "react-router-dom": "^4.3.1",
    "styled-components": "^3.4.6"
  },
  "lint-staged": {
    "*.{ts,tsx}": [
      "tslint -c tslint.json --project tsconfig.json 'src/**/*.ts?(x)'",
      "git add"
    ]
  }
}

// tsconfig.json
{
  "compilerOptions": {
    "module": "esnext",
    "target": "es5",
    "lib": ["es7", "dom", "esnext.asynciterable"],
    "sourceMap": true,
    "jsx": "react",
    "moduleResolution": "node",
    "rootDir": "src",
    "forceConsistentCasingInFileNames": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": true,
    "allowSyntheticDefaultImports": true,
    "skipLibCheck": true,
    "baseUrl": "src", // This is what allows the absolute paths to work
    "paths": {
      "@styled": ["utils/styled"]
    },
    "types": ["node"]
  }
}

Directory structure

screen shot 2018-09-27 at 7 14 33 am

🤔 Expected Behavior

When running parcel index.html, it should resolve the absolute paths and run the app. Since my baseUrl is set to src in tsconfig.json, then it should resolve the path as src/config/firebase

😯 Current Behavior

Parcel displays an error in which it's unable to resolve the path.
register/src/index.tsx:5:7: Cannot resolve dependency 'config/firebase'

💁 Possible Solution

Not sure what changes occurred in the 1.10.0 release, but the app was working fine using 1.9.4.
Remove my absolute path and use a relative path.

🔦 Context

It affects me as i'm no longer able to build my app. Here's link to source code https://github.com/iRoachie/register

💻 Code Sample

// index.tsx
import React from 'react';
import ReactDOM from 'react-dom';
import 'antd/dist/antd.css';

import 'config/firebase';

import Shell from './containers/Shell';

ReactDOM.render(<Shell />, document.getElementById('root'));

🌍 Your Environment

Software Version(s)
Parcel 1.10.1
Node 8.11.4
npm/Yarn yarn 1.9.4
Operating System mac os 10.14

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions