fix: build error when script setup has lang="ts"#69
Open
YuyaItabashi3594 wants to merge 1 commit intounplugin:mainfrom
Open
fix: build error when script setup has lang="ts"#69YuyaItabashi3594 wants to merge 1 commit intounplugin:mainfrom
YuyaItabashi3594 wants to merge 1 commit intounplugin:mainfrom
Conversation
|
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
this PR fixes #53
Description
This PR solves that esbuild transforms markdown twice when <script setup lang="ts"> is in markdown.
#53 is easily reproduced if you add
<script setup lang="ts"> inexamples/vite/README.md` and build.Situation and Debugging
I use this package for my blog,and I face same issue as #53 . Because I thought this is the opportunity to start contributing, I started debugging.
First,I checked this code in
markdown.ts. I added debugging codes in node_modules in my repo that export code as .vue file.Then I found:lang="ts"was exported twice. The one was like<template><div class="markdown-body"><p>import { defineComponent as _defineComponent } from ‘vue’and the other was clean same as other md files.Next,I checked
transforminunpluginFactory. After several AI generating,I found transforming markdown file with query likeREADME.md?vue&type=script&setup=true&lang.ts:1:15caused this error. I added if sentence not to runmarkdownToVuewhen that markdown is already transformed.Linked Issues
Additional context
Solutions
I don't fully understand how esbuild/vite work, so there will be better solution. My code looks smell as it solves too honesty.
Others
As my profile this is my 1st contribution,and due to my low development skill I'm afraid this PR might be considered as AI slop. I appreciate if you find better solutions to address this issue,or improve this PR.
How I used AI
I used Gemini for following things: