Remove the opinionated (wrongly so most of the time) middleman that
brings more config pain than value.
Things to check:
- [x] Parallel build performance vs rush
- [ ] Publishing with submodule
- [x] Changesets
Add vitest ui package and `test:ui` command to popup the vitest UI
https://vitest.dev/guide/ui
Import the common vitest config from the workspace so each package
doesn't need to define all of it.
Added `watchExclude: []` to the common config to preven vitest from
excluding dist and node_modules folder which is required so it can auto
rerun the test on when a dependency (monorepo dep) rebuilds
Added debug config to debug the current test. As the vitest extensions
is quite unreliable this should help
Add a new library template with:
- `@alernateName` decorator with some custom diagnostics and tests for
it.
- a linter rule and 2 rulesets(`recommended` and `all`)
Get rid of mocha and upgrade to vitest which is a more modern
alternative providing, watch, direct typescript compilation out of the
box, expect library and more.
Advantage over mocha:
- Much better cli
- watch mode
- better diff
- Better extension:
- tree organization for files too (not everything flattened)
- update in real time the test(no more need to refresh manually to
discover where are the tests)
- just a little buggy
- Compiles typescript directly
- provides more expectation apis(like jest)
Cons over mocha:
- Slower(about 2x) but that means we don't need to build the test as
part of build which would speed up that part(not as much as is lost)
Todo:
- typespec-azure migration
Playground usage was completely broken when used as a package. Local
reference seems to make it work but hwne the package is in node_modules
vite doesn't allow certain things
fix [#3017](https://github.com/Azure/typespec-azure/issues/3017)
Run the samples as test which allows all of them to run without crashing
on the first one, lets us run it in the test explorer.
This also make the sample regeneration much faster(typespec azure repo):
- Before `~90s`
- Now `~12s`
![image](https://github.com/microsoft/typespec/assets/1031227/a3356a90-7847-43cf-a473-4ecda0c53330)
## New `resolveCompilerOptions` utils
This also include the addition of a new util `resolveCompilerOptions`
that resolve the compiler options programtically in the same way that
the cli would have for a given entrypoint.
I can move this into a dedicated PR if people prefer.
---------
Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
* Adding back Cadl to all compiler public artifacts got renamed with TypeSpec
* initial restructuring
* Green compile with re-structuring mostly done.
* 0.41.0 file rename and package version update added
* TypeSpec replacement done
* tidy up the code with comments and output
* finishing up yargs
* update package.json to avoid rebase conflict
* adding test scenario
* adding cli help
* Fixing PR comments
* fixing PR checks
* tspconfig migration code working
* Update change log for migrate
* Remove eslint warning by setting no-console to false as this is a CLI tool
## Summary
* Make syntax trees deeply `readonly` in their TS typing.
* Remove mutation of symbol tables contained in syntax trees in checker.
* Reuse syntax trees for unchanged files in language server.
* Reuse entire program when no files have changed in language server.
* Fix other miscellaneous perf issues found while profiling the impact of
this change:
* Avoid repeat loading of config file
* Avoid repeat creation of schema validators
* Avoid unnecessary parse in findDocumentHighlight.
* Add environment variables to log language server call timing and/or save
.cpuprofile files to help with future perf work in this area.
## Performance
I'm seeing approximately 2X less time spent in language server for typing
the same sequence into petstore.cadl and navigating around with
goto-definition, document-highlight.
## Details
* We used to inject symbols into symbol tables hanging off syntax trees to
implement using statements including the implicit `using Cadl` and member
references. To avoid this, we now do a copy-on-write to the symbol
tables. This adds an extra map lookup for each call to
resolveIdentifierInTable, where we first look for a copy of the table and
then do the actual lookup. No noticeable slowdown was observed in
profiling based on this. It does double the time in
resolveIdentifierInTable as 1 lookup becomes two, but this does not make a
significant difference overall and I think it's a worthwhile trade to get
the reuse.
* `createProgram` gains a new `oldProgram` argument from which we will reuse
syntax trees if the host gave us identical `SourceFile` instances. We will
also reuse the entire oldProgram and skip checking if we find that the
compiler options and source file set are unchanged. Language server keeps
track of last compilation for a given entry point to provide
oldProgram. Over time, it's possible that we can reuse more of oldProgram
in more cases.
* `CompilerHost` gains a new optional `parseCache` that allows sharing
syntax trees between programs even if oldProgram is not supplied or the
oldProgram didn't have a particular source file. This is particularly
useful for language server features that do not need an entire program but
just the syntax tree of the current document. The language server also
uses this.
* ParseOptions (currently include comments or not) can now be specified on
`CompilerOptions`. Language server uses this to always include comments so
that features that need comments can share trees with features that don't.
1. Format *.cadl on save in our repo. This required some extra knobs in
.vscode/settings.json and .prettierrc.json. These are not required when
referencing the prettier plugin via npm, but we need a workaround to consume
the plugin this way from source.
2. Fix a formatter bug with operations that return anonymous models where
the braces around the return model were dropped.
3. Add cadl syntax highlighting to markdown ```cadl blocks