-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Pass full markup source to preprocessors #6169
Pass full markup source to preprocessors #6169
Conversation
I'm not sure if we would be able to use the svelte parser with |
Thank you for this response. I'm working on an experiment where I remove the script and style tag then run If think that we will need to walk the AST and generate a javascript/typescript equivalent of svelte expressions. eg: {#each list as item (item.id)}
<p>{item.title}</p>
{/each} should become: for (const item of list) {
let var0 = item.title;
} What do you think? |
That sounds like too much work. The svelte compiler returns a list of variables referenced in the markup, which can be used instead |
That sounds great. Do you know how can I retrieve this list? If possible, I would like to avoid running the full compilation process since it will force us to do a double compilation and it will drastically impact the compiler performance |
@dummdidumm, I tried to run the svelte compiler but the only way to make it reliable is to first compile typescript then compile svelte so the process will be very expensive... Moreover, this way is not 100% reliable, even Also, I suggest moving our discussion to the svelte-preprocess issue to avoid polluting this PR. |
15c99bf
to
cf9ea70
Compare
Wow, checks have failed in cascade. I'm not sure why... Can we rerun them? |
cf9ea70
to
3d7d104
Compare
Any news? This PR is needed to implement sveltejs/svelte-preprocess#318. Thank you |
I added a code comment above which you didn't answer yet. |
Ooops! I'm sorry, I didn't see it 😅! |
3d7d104
to
25dedbe
Compare
I wouldn't understand exactly what |
@benmccann, you're totally right. @dummdidumm, thanks for writing this. Next steps are on the |
I think we can add one more PR to Svelte to make |
That sounds great! If we want to do this, I think we need to add a new option on the svelte Maybe something like: svelte.compile(markup, { generate: false, includeAllVariables: true }); or: svelte.compile(markup, { generate: false, variables: "all" });
// variables could be: "all" or "strict" |
There is also one other solution that could work for us.
What do you think? |
This is not needed, if you pass |
This has been released in 3.38.0. |
Hi,
This is my first PR on this project so I want to thank you for building this amazing framework/compiler/library(?) 👍 !
Why?
This PR was done to allow the
typescript
preprocessor to better detect used imports in a Svelte component and automatically strips type/value mixed imports.It will help resolving this issue: sveltejs/svelte-preprocess#318.
You can see this comments for a road to implementation:
To summarize, it will alllow this code:
to become:
Please note that this PR is not resolving the issue by itself but it is needed to allow this issue to be resolved in
svelte-preprocess
.Additional notes
Testing
I did not add a test because I'm not sure it is necessary. It does not break existing tests and the only test I see would be to check that we have the
source
param available in thepreprocess
function. (it seems pretty useless)Do you want me to add this test?
Question
I asked this question in the
svelte-preprocess
issue referenced before:Is there a safe way (no regexp) to extract JS expressions (or variables) from markup without doing a full svelte compilation?
Update
I see that the windows+node v8 test failed because of a timout issue. I think that it's only an outage on Github. Is it possible to rerun this job to ensure that everything is OK?
Since all others tests are successful, I think there is no problem, but I like green ticks :-)
Before submitting the PR, please make sure you do the following
Tests
npm test
and lint the project withnpm run lint