Skip to content

Commit

Permalink
Merge pull request #1858 from didi/fix-setup-compiler-move-error
Browse files Browse the repository at this point in the history
fix: 修复<script setup>标签后顶格写import语句时构建报错
  • Loading branch information
hiyuki authored Feb 21, 2025
2 parents 04829fa + 5e06a05 commit 27f60d6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/webpack-plugin/lib/script-setup-compiler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ function compileScriptSetup (

if (node.type === 'ImportDeclaration') {
// import declarations are moved to top
_s.move(start, end, 0)
if (start !== 0) {
_s.move(start, end, 0)
}
// dedupe imports
let removed = 0
const removeSpecifier = (i) => {
Expand Down Expand Up @@ -533,7 +535,9 @@ function compileScriptSetup (
(node.type === 'VariableDeclaration' && node.declare)
) {
recordType(node, declaredTypes)
_s.move(node.start, node.end + 1, 0)
if (node.start !== 0) {
_s.move(node.start, node.end + 1, 0)
}
}
}

Expand Down

0 comments on commit 27f60d6

Please sign in to comment.