Skip to content

Conversation

@linzhe141
Copy link
Contributor

@linzhe141 linzhe141 commented Oct 6, 2024

close #12114

Maybe more reasonable to hoist the comment nodes in the setup SFC.

this pr -- playgroud

@github-actions
Copy link

github-actions bot commented Oct 6, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 101 kB 38.1 kB 34.2 kB
vue.global.prod.js 160 kB 58 kB 51.5 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 49.1 kB 18.9 kB 17.3 kB
createApp 55.7 kB 21.4 kB 19.6 kB
createSSRApp 59.7 kB 23.1 kB 21 kB
defineCustomElement 60.4 kB 23 kB 20.9 kB
overall 69.4 kB 26.5 kB 24.1 kB

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 6, 2024

Open in Stackblitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@12115

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@12115

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@12115

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@12115

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@12115

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@12115

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@12115

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@12115

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@12115

vue

pnpm add https://pkg.pr.new/vue@12115

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@12115

commit: f7d9b2d

@edison1105 edison1105 added scope: sfc 🧹 p1-chore Priority 1: this doesn't change code behavior. labels Oct 7, 2024
if (node.leadingComments && node.leadingComments.every(i => !i.locate)) {
hoistLeadingCommentsNode(node)
}
const start = node.start! + startOffset
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if node has leading comments, maybe the proper fix should be:

start = leadingComment[0].start + startOffset

@linzhe141 linzhe141 marked this pull request as draft October 7, 2024 02:42
@linzhe141 linzhe141 changed the title fix(compiler-sfc): handle the leading comments in sfc fix(compiler-sfc): properly hoist comments in sfc Oct 7, 2024
@linzhe141 linzhe141 changed the title fix(compiler-sfc): properly hoist comments in sfc fix(compiler-sfc): properly hoist comments in the setup sfc Oct 7, 2024
@linzhe141 linzhe141 marked this pull request as ready for review October 7, 2024 07:53
@edison1105 edison1105 added the ready to merge The PR is ready to be merged. label Oct 7, 2024
@yyx990803
Copy link
Member

#12114 (comment)

Also, I don't think it's worth it to introduce such extra complexity for something that does not affect runtime behavior.

@yyx990803 yyx990803 closed this Oct 11, 2024
@linzhe141 linzhe141 deleted the fix-sfc-leading-comments branch October 11, 2024 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🧹 p1-chore Priority 1: this doesn't change code behavior. ready to merge The PR is ready to be merged. scope: sfc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When using the defineOptions macro in the setup script, the static literal header comment in the code is incorrectly positioned

3 participants