feat(app-vite&app-webpack): upgrade tsconfig preset #17301
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Minumum accepted TS version would be 5, since we'll use
bundler
option formoduleResolution
The PR fulfills these requirements:
dev
branch (orv[X]
branch)fix: #xxx[,#xxx]
, where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information:
I tested Vite new preset on a couple of projects of ours and aside the problems I reported down there, which should be used as base for a migration guide, I didn't have other problems
TS reference suggests to avoid using
baseUrl
and rely on relative values forpath
optionThis isn't possible in our case, since we ship default "paths" in the presets instead of the devland tsconfig
Using relative paths in the preset would cause the mapping to search types relatively to the preset tsconfig location and not the devland project folder
There doesn't seem to be another way to achieve this feature, and putting the paths back into the devland tsconfig would remove a good chunk of our flexibility to update those paths on the user behalf
Instead, I added comments to explain this where needed
We could remove "baseUrl" from jsconfig or older tsconfig from Qv1 which weren't using a tsconfig preset, but it doesn't really make sense changing something that's not broken
Switching to
bundler
option formoduleResolution
breaks any kind of deep import, since it nows honorsexports
field inpackage.json
when definedDeep imports are still possible, but the dev needs to define an appropriate entry in
paths
option mapping to the deep import location intonode_modules
folderE.g.
Additionally,
bundler
mode won't recognize CJS imports, thus any kind of CJS file, especiallyquasar.conf.js
orquasar.conf.cjs
in our case, isn't correctly interpreted by TSI haven't tried, but I expect
quasar.conf.ts
orquasar.conf.mjs
to work with this setupI added a new version of the presets which is even stricter, and thus could not fit everyone
useDefineForClassFields
in Vite tsconfig preset isn't needed, since it's true by default whentarget
isesnext
as it is.This is true since Vite 2.5 apparently
Regarding
target
option, it's actually ignored by Vite, so setting it toesnext
is a good way to forceuseDefineForClassFields
to true and accept any kind of new syntax and featureFor webpack,
target
is apparently used to determine what to transpile, so I guess we should still keep it set toes6
From TS documentation: