I would like Parcel to resolve different file extensions without necessity to type .js, .jsx or .ts in import.
Trying to import file without extension and parcel should be able to find best match, e.g. when I have App.jsx, it should try to find App.js -> fail, App.ts -> fail, App.jsx -> should be used.
// index.tsx
import React from 'react'
import {render} from 'react-dom'
import App from './App';
render(<App/>,
document.getElementById('root')
);
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.12.2 |
| Node | v8.16.0 |
| npm/Yarn | 6.10.2|
| Operating System | Linux Mint |
Is this a bug report or a feature request? This should work already
@mischnic initially I thought it was bug, but then I realized it was related to cache. I cleared .cache folder and error was gone. I think imports were cached and this is why I had this error.
I don't know if this is expected behaviour? Should Parcel try to write better error message in this case?
I don't know if this is expected behaviour?
No ๐
Should Parcel try to write better error message in this case?
There should never be an error in the first place.
Are you able to reproduce this consistently?
Not sure if this is fixed in Parcel 2
@mischnic I assume then that it is a bug because .cache was causing parcel to search for incorrect file extension.
I assume then that it is a bug because .cache was causing parcel to search for incorrect file extension.
Yes, I'm guessing the file once existed and Parcel didn't reevaluate the extensions after the file was deleted/renamed.
Closing because it's likely fixed with Parcel 2 and this can't be investiaged without a way to reliably reproduce this situation.
@mischnic Here are the steps to reproduce:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.
As a workaround, temporarily writing:
import App from "./App.jsx";
seems to be sufficient to make parcel start tracking the file in its new path. You can then change the line back to just "./App".
Most helpful comment
@mischnic I assume then that it is a bug because .cache was causing parcel to search for incorrect file extension.