fix: handle local and module scripts separately#5464
Conversation
yyx990803
left a comment
There was a problem hiding this comment.
I realize this could technically happen in .vue files as well, when a user uses variables with the same name in both normal <script> and <script setup> (although this seems less common than in Svelte? I personally have never seen anyone do this)
So I think some level of hard-coding for this is unavoidable (before the refactor), but on a high level there would be two code paths:
- "Module" context script tags:
<script>in vue, and<script context="moule">in svelte. - "Local" context script tags:
<script setup>in vue, and<script>in svelte.
We should detect these two paths upfront and then apply the new virtual module logic to (2). This would allow us to limit the framework-specific part to the script context detection phase and make the virtual module handling framework agnostic.
6b8f8b5 to
1ef2e76
Compare
1ef2e76 to
12bea5b
Compare
|
I'm not sure I understood 100% of that comment, but I did add support for |
Description
Treat Svelte's
<script>and<script context="module">as separate contexts during import scanFixes #5446
Additional context
This is a very annoying issue that causes prebundling to fail so that the server won't start if you use variables with the same name in different script contexts, which is a very common thing to do in Svelte
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).