🐛 bug report
🎛 Configuration (.babelrc, package.json, cli command)
tsconfig.json:
{
"compilerOptions": {
"outDir": "./dist/",
"baseUrl": "./src",
"sourceMap": true,
"module": "commonjs",
"target": "es5",
"removeComments": true
}
}
🤔 Expected Behavior
structure:
- project
- src
- component
Custom.ts
Main.ts
index.html
tsconfig.json
component/Custom.ts:
export default function hello() {
console.log('Hello!');
};
Main.ts:
import hello from 'component/Custom';
hello();
console should show 'Hello!'
😯 Current Behavior
Running from shell:
$ parcel index.html
/Users/shunia/Documents/parcel-test/src/Main.ts:3:23: Cannot resolve dependency 'components/Custom'
1 | import hello from "components/Custom";
2 |
> 3 | hello();
💁 Possible Solution
The compiler should read tsconfig.json file right, and understands that baseUrl has made the from part of import ... from ... no need to be the actual relative path from the current file.
In my case, because of baseUrl set to ./src, the original import hello from '../componet/Custom' can be replaced as import hello from 'component/Custom'`.
This might because of the way typescript compiles the import part just as what is written in the codes:
import hello from "components/Custom";
is just compiled to:
var Custom_1 = require("components/Custom");
And then, parcel-require can not recognize the path and throws error.
🔦 Context
Our actual project are full of relative paths based on baseUrl, which we omitted the ../ parts when using relative import. With webpack and awesome-typescript-loader it works as expected. So when we are trying to get our hands on parcel, this problem really blocks us from going further.
🌍 Your Environment
| Software |
Version(s) |
| Parcel |
1.1.0 |
| Node |
v8.9.3 |
| npm/Yarn |
Yarn 1.3.2 |
| Operating System |
macOS Sierra 10.12.6 |
Sorry for my poor english.
🐛 bug report
🎛 Configuration (.babelrc, package.json, cli command)
tsconfig.json:🤔 Expected Behavior
structure:
component/Custom.ts:
Main.ts:
console should show 'Hello!'
😯 Current Behavior
Running from shell:
💁 Possible Solution
The compiler should read
tsconfig.jsonfile right, and understands thatbaseUrlhas made thefrompart ofimport ... from ...no need to be the actual relative path from the current file.In my case, because of
baseUrlset to./src, the originalimport hello from '../componet/Custom' can be replaced asimport hello from 'component/Custom'`.This might because of the way typescript compiles the
importpart just as what is written in the codes:is just compiled to:
And then, parcel-require can not recognize the path and throws error.
🔦 Context
Our actual project are full of relative paths based on
baseUrl, which we omitted the../parts when using relative import. Withwebpackandawesome-typescript-loaderit works as expected. So when we are trying to get our hands on parcel, this problem really blocks us from going further.🌍 Your Environment
Sorry for my poor english.