Skip to content

Commit 9146cc4

Browse files
cexbrayatyyx990803
authored andcommitted
fix(compiler-sfc): <script setup> warning
The warning was showing even if the component is only using a classic `<script>`
1 parent 5f61aa0 commit 9146cc4

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/compiler-sfc/__tests__/compileScript.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ describe('SFC compile <script setup>', () => {
457457
)
458458
})
459459

460-
test('error on duplicated defalut export', () => {
460+
test('error on duplicated default export', () => {
461461
expect(
462462
parse(`
463463
<script>

packages/compiler-sfc/src/compileScript.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ export function compileScript(
4040
sfc: SFCDescriptor,
4141
options: SFCScriptCompileOptions = {}
4242
): SFCScriptBlock {
43-
if (__DEV__ && !__TEST__ && !hasWarned) {
43+
const { script, scriptSetup, styles, source, filename } = sfc
44+
45+
if (__DEV__ && !__TEST__ && !hasWarned && scriptSetup) {
4446
hasWarned = true
45-
console.log(
47+
// @ts-ignore `console.info` cannot be null error
48+
console[console.info ? 'info' : 'log'](
4649
`\n[@vue/compiler-sfc] <script setup> is still an experimental proposal.\n` +
4750
`Follow https://github.com/vuejs/rfcs/pull/182 for its status.\n`
4851
)
4952
}
5053

51-
const { script, scriptSetup, styles, source, filename } = sfc
5254
const hasCssVars = styles.some(s => typeof s.attrs.vars === 'string')
5355

5456
const isTS =

0 commit comments

Comments
 (0)