parcel: Version 1.10.1 breaks absolute paths in typescript
π 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
π€ 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 |
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 8
- Comments: 16 (5 by maintainers)
https://github.com/fathyb/parcel-plugin-typescript/issues/59 issue is freezed for long time.
Same happens to me when switching from 1.9.7 to 1.10.1.
Yet I have an β@β character prepended to the paths, hence I got a different error message:
Failed to install @src/[...]Iβd assume that the bundler tries to install the missing dependency via yarn, instead of resolving it with the specified paths in the tsconfig.json file.