Skip to content

Commit

Permalink
fix(compiler-sfc): <script setup> warning
Browse files Browse the repository at this point in the history
The warning was showing even if the component is only using a classic `<script>`
  • Loading branch information
cexbrayat authored and yyx990803 committed Jul 15, 2020
1 parent 5f61aa0 commit 9146cc4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/compiler-sfc/__tests__/compileScript.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ describe('SFC compile <script setup>', () => {
)
})

test('error on duplicated defalut export', () => {
test('error on duplicated default export', () => {
expect(
parse(`
<script>
Expand Down
8 changes: 5 additions & 3 deletions packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ export function compileScript(
sfc: SFCDescriptor,
options: SFCScriptCompileOptions = {}
): SFCScriptBlock {
if (__DEV__ && !__TEST__ && !hasWarned) {
const { script, scriptSetup, styles, source, filename } = sfc

if (__DEV__ && !__TEST__ && !hasWarned && scriptSetup) {
hasWarned = true
console.log(
// @ts-ignore `console.info` cannot be null error
console[console.info ? 'info' : 'log'](
`\n[@vue/compiler-sfc] <script setup> is still an experimental proposal.\n` +
`Follow https://github.com/vuejs/rfcs/pull/182 for its status.\n`
)
}

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

const isTS =
Expand Down

0 comments on commit 9146cc4

Please sign in to comment.