-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add compilation variables report option to allow getting all variables (even undeclared or internal) #6192
Add compilation variables report option to allow getting all variables (even undeclared or internal) #6192
Conversation
Thanks for taking a stab at this! This isn't enough yet though
|
Thank you! 👍 Yeah I know, I wanted to collect your feedbacks before going further. Your feedbacks looks good for me but I have some questions:
I don't understand this one. Can you detail you thought? Update: I think I understood, do you mean this? svelte/src/compiler/compile/index.ts Line 11 in dafbdc2
Shouldn't we specify that this variable is undeclared in some way? |
Yes
That can be infered from the other properties (neither |
Should we also add a validation in |
1b1eab4
to
7053ea3
Compare
I implemented your changes in I also added a test in |
I would add two more tests: One without a script block entirely (just
You also need to enhance the docs and mention the new option. Other than that this looks good to me. @Conduitry does this look good for you, too? |
4ba61e4
to
7ed38cc
Compare
Missing tests added. |
The documentation was updated with the new On my side, I'm all done. Feel free to start the code review and give me your feedbacks. |
@dummdidumm, Thanks for this approval. I tried to use this new option on However, if the template uses Is there an option, to force the compilation even when errors occurs? Update: Update 2: Indeed, the compiler expects Update 3: This seems to work well on If you agree, I will open a third PR for this to have create a new discussion thread. |
This sounds good, maybe #4818 is handled by this as well. |
Thank you for merging this PR, I will restart my work on the |
This has been released in 3.39.0 - thanks! |
Description
This PR adds a new option
varsReport
toCompileOptions
to allow getting the full variables report from the compilation process.This allows external modules (like
svelte-preprocess
) to make their own decision about how to handle variables.To avoid breaking change, the old behavior is still the default option (
strict
).This PR is part of a work on the
svelte-preprocess
side to improve the preprocessing of TypeScript files:sveltejs/svelte-preprocess#318
A first feature was implemented in the following PR:
#6169
References
Suggestion from @dummdidumm:
#6169 (comment)
TODO:
add_var
to allow non-looked-up variableadd_reference
to add used variablestest/vars
Review
Before adding tests and docs about this new behavior I would like to collect your feedbacks about:
varsReport
name?string
mode (full
|strict
| false)?Before submitting the PR, please make sure you do the following
Tests
npm test
and lint the project withnpm run lint
Many thanks