-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!(app-vite): auto generate base tsconfig and types (#17549)
* feat(app-vite): generate .quasar/tsconfig.json * feat(app-vite): generate tsconfig exclude * feat(app-vite): add Capacitor dependencies to tsconfig paths the Vite aliases were already there, thanks to this, TypeScript won't complain about using Capacitor deps inside src/ anymore * feat(app-vite): handle folder module and file aliases in tsconfig paths * refactor(app-vite): extract tsconfig generation to a function * feat(app-vite): generate nested path aliases for capacitor deps too e.g. `@capacitor/dep/deep/import` * feat(app-vite): add build.typescript.extendTsConfig hook * feat(app-vite): create a better tsconfig, drop presets enforce TS >=5.4 to use module: 'preserve' forceConsistentCasingInFileNames defaults to true since TS 5.0 verbatimModuleSyntax will require user to update their codes jsx: preserve is no longer needed for Vue Language Tools strict: true and some of the other strict options will be added through a flag * feat(app-vite): add an option to generate tsconfig with strict rules compared to previous regular preset: noUnusedLocals is turned off as it produces extra noise when using ESLint, where the behavior is better as it's configurable compared to previous stricter config: noPropertyAccessFromIndexSignature is removed as it doesn't even allow process.env.DEV unless it's augmented explicitly, which we don't do at the moment. It enforces process.env['DEV'] instead, which is annoying and confusing to use. We can't augment the env variables as Node types enforce string, but our own types are actual boolean values. noImplicitReturns reduces the DX and is not that beneficial in app code compared to its use in library code. It still has it's uses, but it doesn't belong the usual strictness. * feat(app-vite): only generate .quasar/tsconfig.json if the app has TS * fix(app-vite): correctly handle non-existent aliases they were throwing errors, now we skip them for an even slimmer result * feat(create-quasar): adapt ts-vite-2 to latest specs * fix(app-vite): suppress the esbuild tsconfig.json warning when .quasar/tsconfig.json is missing prior to generation * feat(app-vite): split types generation, handle it on diff now it will re-generate the types if build.typescript or build.alias gets updated * feat(app-vite): add prepare command to generate tsconfig and types * feat(create-quasar): add postinstall script to run quasar prepare * feat(create-quasar): remove tsconfig.vue-tsc.json as it's not required anymore * feat(app-vite): move feature flags into .quasar * feat(create-quasar): remove unused store-flag.d.ts as feature flags are handled into .quasar now * docs(app-vite): document tsconfig changes * feat(app-vite): generate declarations and vue shims * feat(app-vite): make vue shim generation optional * feat(create-quasar): adapt to latest TS specs * docs(app-vite): document dts generation and feature flag changes * docs(app-vite): correctly reference .quasar/tsconfig * docs(app-vite): mention Capacitor TS changes * refactor(app-vite): queue generateTypes call instead of awaiting * docs(app-vite): enrich TS-related info in upgrade guide * Update bex-devserver.js * Update app-devserver.js * Update mode.js * feat(app-vite): generate and utilize tsconfig for JS projects too Co-authored-by: Razvan Stoenescu <[email protected]> --------- Co-authored-by: Razvan Stoenescu <[email protected]>
- Loading branch information
1 parent
2b3bc97
commit 76dc721
Showing
38 changed files
with
539 additions
and
329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import parseArgs from 'minimist' | ||
|
||
import { log } from '../utils/logger.js' | ||
|
||
const argv = parseArgs(process.argv.slice(2), { | ||
alias: { | ||
h: 'help' | ||
}, | ||
boolean: [ 'h' ] | ||
}) | ||
|
||
if (argv.help) { | ||
console.log(` | ||
Description | ||
Prepare the app for linting, type-checking, IDE integration, etc. | ||
It will generate the relevant files such as '.quasar/tsconfig.json', types files, etc. | ||
Running 'quasar dev' or 'quasar build' will automatically handle this for you. | ||
Use this command for a lightweight alternative to dev/build. Useful in CI/CD pipelines. | ||
Usage | ||
$ quasar prepare | ||
Options | ||
--help, -h Displays this message | ||
`) | ||
process.exit(0) | ||
} | ||
|
||
const { readFileSync } = await import('node:fs') | ||
|
||
console.log( | ||
readFileSync( | ||
new URL('../../assets/logo.art', import.meta.url), | ||
'utf8' | ||
) | ||
) | ||
|
||
const { getCtx } = await import('../utils/get-ctx.js') | ||
// ctx doesn't matter for this command | ||
const ctx = getCtx({ | ||
mode: 'spa', | ||
debug: false, | ||
prod: true | ||
}) | ||
|
||
const { QuasarConfigFile } = await import('../quasar-config-file.js') | ||
const quasarConfFile = new QuasarConfigFile({ | ||
ctx, | ||
// host and port don't matter for this command | ||
port: 9000, | ||
host: 'localhost' | ||
}) | ||
|
||
await quasarConfFile.init() | ||
|
||
const quasarConf = await quasarConfFile.read() | ||
|
||
const { generateTypes } = await import('../types-generator.js') | ||
await generateTypes(quasarConf) | ||
|
||
log('Generated tsconfig.json and types files in .quasar directory') | ||
log('The app is now prepared for linting, type-checking, IDE integration, etc.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.