parcel
parcel copied to clipboard
Can't import module types locally
🐛 bug report
When importing Chart.JS types locally, ParcelJS always throws an error stating it can't find the module with types. Doing the following in a TypeScript file:
import { Chart } from "./chartjs/dist/types";
results in the following error
🚨 Build failed.
@parcel/core: Failed to resolve './chartjs/dist/types' from './src/gpachart/gpachart.ts'
/home/mahid/Documents/Skyward-GPA-calculator/src/gpachart/gpachart.ts:3:23
2 | import { Settings } from "../settings";
> 3 | import { Chart } from "./chartjs/dist/types";
> | ^^^^^^^^^^^^^^^^^^^^^^
4 |
5 | let GPAGraphArray: GraphValueType[];
@parcel/resolver-default: Cannot load file './chartjs/dist/types' in './src/gpachart'.
💡 Did you mean './chartjs/dist/types'?
💡 Did you mean './chartjs/dist/types.d'?
However, the module is indeed located at that path. It seems ParcelJS doesn't want to load the .d.ts files.
🎛 Configuration (.babelrc, package.json, cli command)
{
"scripts": {
"dev": "rm -rf .parcel-cache && parcel watch src/manifest.json --host localhost",
"build": "rm -rf .parcel-cache && parcel build src/manifest.json"
},
"devDependencies": {
"@eslint/js": "^9.8.0",
"@parcel/config-webextension": "^2.12.0",
"@parcel/transformer-typescript-tsc": "^2.12.0",
"@parcel/validator-typescript": "^2.12.0",
"@types/chrome": "^0.0.269",
"@types/eslint__js": "^8.42.3",
"eslint": "^9.8.0",
"parcel": "^2.12.0",
"prettier": "3.3.3",
"typescript": "^5.5.4",
"typescript-eslint": "^8.0.0"
}
}
🤔 Expected Behavior
This building perfectly fine
😯 Current Behavior
Getting an error where I can't import the module types
💁 Possible Solution
🔦 Context
💻 Code Sample
https://github.com/watchbutdonotlearn/Skyward-GPA-calculator/ (rewrite branch)
🌍 Your Environment
| Software | Version(s) |
|---|---|
| Parcel | 2.12.0 |
| Node | v18.20.4 |
| npm/Yarn | Yarn 1.22.22 |
| Operating System | Arch Linux |