Open al-the-x opened 1 month ago
The resolver does indeed only read tsconfig: https://github.com/parcel-bundler/parcel/blob/a2789a49b88b66c67a378b8c8813e504c77c8648/packages/utils/node-resolver-rs/src/lib.rs#L1124
The transformer reads both, but prefers tsconfig (and ignore jsconfig if both exist): https://github.com/parcel-bundler/parcel/blob/a2789a49b88b66c67a378b8c8813e504c77c8648/packages/transformers/js/src/JSTransformer.js#L204-L207
๐ bug report
I cannot get
parcel
to pick upjsconfig.json
using either the native Typescript transformer or@parcel/transform-typescript-tsc
as per previous issues reported by others and considered fixed in #6501:6389
4622
3287
614
I am specifically trying to compile
*.js
files respecting thebaseUrl
andinclude
settings in ourjsconfig.json
to avoid having to rewrite everyimport
statement in the project to use leading~
or similar bare specifiers.When no
tsconfig.json
is presentย and only ajsconfig.json
,parcel
will not attempt to compile any files to TypeScript and ignores thejsconfig.json
. Whentsconfig.json
is present withcompilerOptions.allowJs = true
,parcel
correctly transforms the JS files respecting thebaseUrl
value and other directives intsconfig.json
. Even when*.{js,jsx}
files are configured to use@parcel/transform-typescript-tsc
, thejsconfig.json
is ignored.๐ Configuration (.babelrc, package.json, cli command)
Project structure:
tsconfig.json
andjsconfig.json
are identicaljsconfig.json
should be discovered whentsconfig.json
is missingjsconfig.json
/tsconfig.json
minimally:package.json
minimally:.parcelrc
to enable compilation of JS files viatsc
:index.js
App.jsx
๐ค Expected Behavior
WHEN
jsconfig.json
is present andtsconfig.json
is NOT THENparcel
should findsrc/App.jsx
andsrc/components/HelloWorld.jsx
by referring to thebaseUrl
specified injsconfig.json
๐ฏ Current Behavior
THEN
parcel
complains about a missing dependency forApp
andcomponents
:๐ Possible Solution
Consider
jsconfig.json
for compiling JS files when TypeScript is enabled. Provide a configuration example of how to enable the native TypeScript compiler provided byparcel
for JS files that will consider thejsconfig.json
file.๐ฆ Context
I have a real world project that is using TypeScript for type hints during development but not full TypeScript features due to the volume of code in the project that we would have to convert. We consider JS files to be TS files in the IDE only, which is triggered by our existing
jsconfig.json
file.I would like to convert the codebase from CRA + Webpack +
react-scripts-rewired
to Parcel with minimal changes to the codebase, so prefixing everyimport
statement with/
(whichstandardjs
reports as a violation) or~
would exceed our "minimal changes" threshold. From the documentation, it appears thatparcel
SHOULD support bothjsconfig.json
andtsconfig.json
, just not both at the same time. However, in my numerous attempts, I cannot get either the native transformer nor@parcel/transformer-typescript-tsc
to recognizejsconfig.json
, onlytsconfig.json
.This isn't a huge blocker for us, as we can stand renaming
jsconfig.json
totsconfig.json
and adding theallowJs
flag.๐ป Code Sample
See above.
๐ Your Environment