I believe the root of the problem lies in the version of WebPack I am using (
"webpack-cli": "3.3.11"
). Before embarking on another round of debugging to upgrade WebPack (attempted version 5 but faced issues due to lack of a config file), I want to confirm my assumption. I seem to be pushing against the boundaries of the instructions, skimming over the manual as I go along.
Within tsconfig.base.js
, the following configuration is present:
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
(The rationale behind using a separate tsconfig.base.json
is explained in the linked question below.)
Additionally, this import can be found:
import { RegistrationStepManager } from "@/helpers";
within the file
./src/some/path/RegistrationStepper.tsx
.
Upon running npm start
with CRA and react-scripts v4.0.3
, an error is displayed without causing a crash:
Failed to compile.
./src/some/path/RegistrationStepper.tsx
Module not found: Can't resolve '@/helpers' in '/my-path/my-project/src/some/other/path'.
Despite VS Code tooltips and autocompletion indicating correct importation, there are only minor warnings, no red underlines.
The suspicion is that the alias for "@/*"
isn't functioning properly, although VS Code seems to handle it flawlessly, suggesting a potential bug.
How does TypeScript interact with WebPack in light of such failures? Is upgrading to WebPack 5 necessary?
An additional query within the same timeframe and codebase has been raised by me: How can I import an enum through an intermediate TS file?.
Thank you.
Update 1
I stumbled upon this post, prompting me to transition from CRA to standalone WebPack since my project holds more significance than mere experimentation. Could you possibly recommend a migration guide from CRA to WebPack? The initial issue in this inquiry may stem from a deficient WebPack setup. I possess an outdated WebPack configuration file that could be contributing to the problem.