fix(compiler-sfc): <script> after <script setup> the script content not end with \\n
This commit is contained in:
parent
242914d938
commit
3b7b107120
@ -17,7 +17,7 @@ exports[`SFC analyze <script> bindings auto name inference do not overwrite manu
|
|||||||
const __default__ = defineComponent({
|
const __default__ = defineComponent({
|
||||||
name: 'Baz'
|
name: 'Baz'
|
||||||
})
|
})
|
||||||
|
|
||||||
export default /*#__PURE__*/Object.assign(__default__, {
|
export default /*#__PURE__*/Object.assign(__default__, {
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
@ -32,7 +32,7 @@ exports[`SFC analyze <script> bindings auto name inference do not overwrite manu
|
|||||||
"const __default__ = {
|
"const __default__ = {
|
||||||
name: 'Baz'
|
name: 'Baz'
|
||||||
}
|
}
|
||||||
|
|
||||||
export default /*#__PURE__*/Object.assign(__default__, {
|
export default /*#__PURE__*/Object.assign(__default__, {
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
@ -43,19 +43,34 @@ return { a }
|
|||||||
})"
|
})"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`SFC compile <script setup> <script> after <script setup> the script content not end with \`\\n\` 1`] = `
|
||||||
|
"const n = 1
|
||||||
|
import { x } from './x'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup(__props, { expose }) {
|
||||||
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
return { n, x }
|
||||||
|
}
|
||||||
|
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`SFC compile <script setup> <script> and <script setup> co-usage script first 1`] = `
|
exports[`SFC compile <script setup> <script> and <script setup> co-usage script first 1`] = `
|
||||||
"import { x } from './x'
|
"import { x } from './x'
|
||||||
|
|
||||||
export const n = 1
|
export const n = 1
|
||||||
|
|
||||||
const __default__ = {}
|
const __default__ = {}
|
||||||
|
|
||||||
export default /*#__PURE__*/Object.assign(__default__, {
|
export default /*#__PURE__*/Object.assign(__default__, {
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
x()
|
x()
|
||||||
|
|
||||||
return { n, x }
|
return { n, x }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,13 +81,13 @@ exports[`SFC compile <script setup> <script> and <script setup> co-usage script
|
|||||||
"export const n = 1
|
"export const n = 1
|
||||||
const __default__ = {}
|
const __default__ = {}
|
||||||
import { x } from './x'
|
import { x } from './x'
|
||||||
|
|
||||||
export default /*#__PURE__*/Object.assign(__default__, {
|
export default /*#__PURE__*/Object.assign(__default__, {
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
x()
|
x()
|
||||||
|
|
||||||
return { n, x }
|
return { n, x }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,14 +101,14 @@ exports[`SFC compile <script setup> <script> and <script setup> co-usage script
|
|||||||
name: \\"test\\"
|
name: \\"test\\"
|
||||||
}
|
}
|
||||||
import { x } from './x'
|
import { x } from './x'
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
...__default__,
|
...__default__,
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
x()
|
x()
|
||||||
|
|
||||||
return { x }
|
return { x }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,17 +118,17 @@ return { x }
|
|||||||
exports[`SFC compile <script setup> <script> and <script setup> co-usage script setup first, named default export 1`] = `
|
exports[`SFC compile <script setup> <script> and <script setup> co-usage script setup first, named default export 1`] = `
|
||||||
"export const n = 1
|
"export const n = 1
|
||||||
const def = {}
|
const def = {}
|
||||||
|
|
||||||
|
|
||||||
const __default__ = def
|
const __default__ = def
|
||||||
import { x } from './x'
|
import { x } from './x'
|
||||||
|
|
||||||
export default /*#__PURE__*/Object.assign(__default__, {
|
export default /*#__PURE__*/Object.assign(__default__, {
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
x()
|
x()
|
||||||
|
|
||||||
return { n, def, x }
|
return { n, def, x }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,18 +137,18 @@ return { n, def, x }
|
|||||||
|
|
||||||
exports[`SFC compile <script setup> <script> and <script setup> co-usage spaces in ExportDefaultDeclaration node with many spaces and newline 1`] = `
|
exports[`SFC compile <script setup> <script> and <script setup> co-usage spaces in ExportDefaultDeclaration node with many spaces and newline 1`] = `
|
||||||
"import { x } from './x'
|
"import { x } from './x'
|
||||||
|
|
||||||
export const n = 1
|
export const n = 1
|
||||||
const __default__ = {
|
const __default__ = {
|
||||||
some:'option'
|
some:'option'
|
||||||
}
|
}
|
||||||
|
|
||||||
export default /*#__PURE__*/Object.assign(__default__, {
|
export default /*#__PURE__*/Object.assign(__default__, {
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
x()
|
x()
|
||||||
|
|
||||||
return { n, x }
|
return { n, x }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,18 +157,18 @@ return { n, x }
|
|||||||
|
|
||||||
exports[`SFC compile <script setup> <script> and <script setup> co-usage spaces in ExportDefaultDeclaration node with minimal spaces 1`] = `
|
exports[`SFC compile <script setup> <script> and <script setup> co-usage spaces in ExportDefaultDeclaration node with minimal spaces 1`] = `
|
||||||
"import { x } from './x'
|
"import { x } from './x'
|
||||||
|
|
||||||
export const n = 1
|
export const n = 1
|
||||||
const __default__ = {
|
const __default__ = {
|
||||||
some:'option'
|
some:'option'
|
||||||
}
|
}
|
||||||
|
|
||||||
export default /*#__PURE__*/Object.assign(__default__, {
|
export default /*#__PURE__*/Object.assign(__default__, {
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
x()
|
x()
|
||||||
|
|
||||||
return { n, x }
|
return { n, x }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,7 +429,7 @@ exports[`SFC compile <script setup> binding analysis for destructure 1`] = `
|
|||||||
expose();
|
expose();
|
||||||
|
|
||||||
const { foo, b: bar, ['x' + 'y']: baz, x: { y, zz: { z }}} = {}
|
const { foo, b: bar, ['x' + 'y']: baz, x: { y, zz: { z }}} = {}
|
||||||
|
|
||||||
return { foo, bar, baz, y, z }
|
return { foo, bar, baz, y, z }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,7 +464,7 @@ return { }
|
|||||||
|
|
||||||
exports[`SFC compile <script setup> defineProps w/ external definition 1`] = `
|
exports[`SFC compile <script setup> defineProps w/ external definition 1`] = `
|
||||||
"import { propsModel } from './props'
|
"import { propsModel } from './props'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: propsModel,
|
props: propsModel,
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
@ -457,8 +472,8 @@ export default {
|
|||||||
|
|
||||||
const props = __props
|
const props = __props
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { props, propsModel }
|
return { props, propsModel }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,7 +482,7 @@ return { props, propsModel }
|
|||||||
|
|
||||||
exports[`SFC compile <script setup> defineProps w/ leading code 1`] = `
|
exports[`SFC compile <script setup> defineProps w/ leading code 1`] = `
|
||||||
"import { x } from './x'
|
"import { x } from './x'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {},
|
props: {},
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
@ -475,7 +490,7 @@ export default {
|
|||||||
|
|
||||||
const props = __props
|
const props = __props
|
||||||
|
|
||||||
|
|
||||||
return { props, x }
|
return { props, x }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,8 +525,8 @@ exports[`SFC compile <script setup> defineProps/defineEmits in multi-variable de
|
|||||||
|
|
||||||
const props = __props
|
const props = __props
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { props, emit }
|
return { props, emit }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,7 +543,7 @@ exports[`SFC compile <script setup> defineProps/defineEmits in multi-variable de
|
|||||||
const props = __props
|
const props = __props
|
||||||
|
|
||||||
const a = 1;
|
const a = 1;
|
||||||
|
|
||||||
return { props, a, emit }
|
return { props, a, emit }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,14 +553,14 @@ return { props, a, emit }
|
|||||||
exports[`SFC compile <script setup> dev mode import usage check TS annotations 1`] = `
|
exports[`SFC compile <script setup> dev mode import usage check TS annotations 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
import { Foo, Bar, Baz } from './x'
|
import { Foo, Bar, Baz } from './x'
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
const a = 1
|
const a = 1
|
||||||
function b() {}
|
function b() {}
|
||||||
|
|
||||||
return { a, b, Baz }
|
return { a, b, Baz }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,13 +570,13 @@ return { a, b, Baz }
|
|||||||
exports[`SFC compile <script setup> dev mode import usage check attribute expressions 1`] = `
|
exports[`SFC compile <script setup> dev mode import usage check attribute expressions 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
import { bar, baz } from './x'
|
import { bar, baz } from './x'
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
const cond = true
|
const cond = true
|
||||||
|
|
||||||
return { cond, bar, baz }
|
return { cond, bar, baz }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -571,13 +586,13 @@ return { cond, bar, baz }
|
|||||||
exports[`SFC compile <script setup> dev mode import usage check components 1`] = `
|
exports[`SFC compile <script setup> dev mode import usage check components 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
import { FooBar, FooBaz, FooQux, foo } from './x'
|
import { FooBar, FooBaz, FooQux, foo } from './x'
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
const fooBar: FooBar = 1
|
const fooBar: FooBar = 1
|
||||||
|
|
||||||
return { fooBar, FooBaz, FooQux, foo }
|
return { fooBar, FooBaz, FooQux, foo }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,12 +602,12 @@ return { fooBar, FooBaz, FooQux, foo }
|
|||||||
exports[`SFC compile <script setup> dev mode import usage check directive 1`] = `
|
exports[`SFC compile <script setup> dev mode import usage check directive 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
import { vMyDir } from './x'
|
import { vMyDir } from './x'
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
return { vMyDir }
|
return { vMyDir }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -602,12 +617,12 @@ return { vMyDir }
|
|||||||
exports[`SFC compile <script setup> dev mode import usage check js template string interpolations 1`] = `
|
exports[`SFC compile <script setup> dev mode import usage check js template string interpolations 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
import { VAR, VAR2, VAR3 } from './x'
|
import { VAR, VAR2, VAR3 } from './x'
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
return { VAR, VAR3 }
|
return { VAR, VAR3 }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,12 +632,12 @@ return { VAR, VAR3 }
|
|||||||
exports[`SFC compile <script setup> dev mode import usage check last tag 1`] = `
|
exports[`SFC compile <script setup> dev mode import usage check last tag 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
import { FooBaz, Last } from './x'
|
import { FooBaz, Last } from './x'
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
return { FooBaz, Last }
|
return { FooBaz, Last }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -632,12 +647,12 @@ return { FooBaz, Last }
|
|||||||
exports[`SFC compile <script setup> dev mode import usage check vue interpolations 1`] = `
|
exports[`SFC compile <script setup> dev mode import usage check vue interpolations 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
import { x, y, z, x$y } from './x'
|
import { x, y, z, x$y } from './x'
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
return { x, z, x$y }
|
return { x, z, x$y }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,7 +661,7 @@ return { x, z, x$y }
|
|||||||
|
|
||||||
exports[`SFC compile <script setup> errors should allow defineProps/Emit() referencing imported binding 1`] = `
|
exports[`SFC compile <script setup> errors should allow defineProps/Emit() referencing imported binding 1`] = `
|
||||||
"import { bar } from './bar'
|
"import { bar } from './bar'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
foo: {
|
foo: {
|
||||||
@ -659,9 +674,9 @@ export default {
|
|||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { bar }
|
return { bar }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -682,9 +697,9 @@ exports[`SFC compile <script setup> errors should allow defineProps/Emit() refer
|
|||||||
expose();
|
expose();
|
||||||
|
|
||||||
const bar = 1
|
const bar = 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { bar }
|
return { bar }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -694,13 +709,13 @@ return { bar }
|
|||||||
exports[`SFC compile <script setup> imports dedupe between user & helper 1`] = `
|
exports[`SFC compile <script setup> imports dedupe between user & helper 1`] = `
|
||||||
"import { ref as _ref } from 'vue'
|
"import { ref as _ref } from 'vue'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
let foo = _ref(1)
|
let foo = _ref(1)
|
||||||
|
|
||||||
return { foo, ref }
|
return { foo, ref }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -709,13 +724,13 @@ return { foo, ref }
|
|||||||
|
|
||||||
exports[`SFC compile <script setup> imports import dedupe between <script> and <script setup> 1`] = `
|
exports[`SFC compile <script setup> imports import dedupe between <script> and <script setup> 1`] = `
|
||||||
"import { x } from './x'
|
"import { x } from './x'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
x()
|
x()
|
||||||
|
|
||||||
return { x }
|
return { x }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,17 +739,17 @@ return { x }
|
|||||||
|
|
||||||
exports[`SFC compile <script setup> imports should allow defineProps/Emit at the start of imports 1`] = `
|
exports[`SFC compile <script setup> imports should allow defineProps/Emit at the start of imports 1`] = `
|
||||||
"import { ref } from 'vue'
|
"import { ref } from 'vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['foo'],
|
props: ['foo'],
|
||||||
emits: ['bar'],
|
emits: ['bar'],
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const r = ref(0)
|
const r = ref(0)
|
||||||
|
|
||||||
return { r, ref }
|
return { r, ref }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -744,12 +759,12 @@ return { r, ref }
|
|||||||
exports[`SFC compile <script setup> imports should extract comment for import or type declarations 1`] = `
|
exports[`SFC compile <script setup> imports should extract comment for import or type declarations 1`] = `
|
||||||
"import a from 'a' // comment
|
"import a from 'a' // comment
|
||||||
import b from 'b'
|
import b from 'b'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
return { a, b }
|
return { a, b }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -759,12 +774,12 @@ return { a, b }
|
|||||||
exports[`SFC compile <script setup> imports should hoist and expose imports 1`] = `
|
exports[`SFC compile <script setup> imports should hoist and expose imports 1`] = `
|
||||||
"import { ref } from 'vue'
|
"import { ref } from 'vue'
|
||||||
import 'foo/css'
|
import 'foo/css'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
return { ref }
|
return { ref }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -778,7 +793,7 @@ import { ref } from 'vue'
|
|||||||
import Foo, { bar } from './Foo.vue'
|
import Foo, { bar } from './Foo.vue'
|
||||||
import other from './util'
|
import other from './util'
|
||||||
import * as tree from './tree'
|
import * as tree from './tree'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup(__props) {
|
setup(__props) {
|
||||||
|
|
||||||
@ -787,7 +802,7 @@ export default {
|
|||||||
const maybe = foo()
|
const maybe = foo()
|
||||||
let lett = 1
|
let lett = 1
|
||||||
function fn() {}
|
function fn() {}
|
||||||
|
|
||||||
return (_ctx, _cache) => {
|
return (_ctx, _cache) => {
|
||||||
return (_openBlock(), _createElementBlock(_Fragment, null, [
|
return (_openBlock(), _createElementBlock(_Fragment, null, [
|
||||||
_createVNode(Foo, null, {
|
_createVNode(Foo, null, {
|
||||||
@ -811,11 +826,11 @@ exports[`SFC compile <script setup> inlineTemplate mode referencing scope compon
|
|||||||
import ChildComp from './Child.vue'
|
import ChildComp from './Child.vue'
|
||||||
import SomeOtherComp from './Other.vue'
|
import SomeOtherComp from './Other.vue'
|
||||||
import vMyDir from './my-dir'
|
import vMyDir from './my-dir'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup(__props) {
|
setup(__props) {
|
||||||
|
|
||||||
|
|
||||||
return (_ctx, _cache) => {
|
return (_ctx, _cache) => {
|
||||||
return (_openBlock(), _createElementBlock(_Fragment, null, [
|
return (_openBlock(), _createElementBlock(_Fragment, null, [
|
||||||
_withDirectives(_createElementVNode(\\"div\\", null, null, 512 /* NEED_PATCH */), [
|
_withDirectives(_createElementVNode(\\"div\\", null, null, 512 /* NEED_PATCH */), [
|
||||||
@ -836,12 +851,12 @@ exports[`SFC compile <script setup> inlineTemplate mode should work 1`] = `
|
|||||||
const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"div\\", null, \\"static\\", -1 /* HOISTED */)
|
const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"div\\", null, \\"static\\", -1 /* HOISTED */)
|
||||||
|
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup(__props) {
|
setup(__props) {
|
||||||
|
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
|
|
||||||
return (_ctx, _cache) => {
|
return (_ctx, _cache) => {
|
||||||
return (_openBlock(), _createElementBlock(_Fragment, null, [
|
return (_openBlock(), _createElementBlock(_Fragment, null, [
|
||||||
_createElementVNode(\\"div\\", null, _toDisplayString(count.value), 1 /* TEXT */),
|
_createElementVNode(\\"div\\", null, _toDisplayString(count.value), 1 /* TEXT */),
|
||||||
@ -858,7 +873,7 @@ exports[`SFC compile <script setup> inlineTemplate mode ssr codegen 1`] = `
|
|||||||
import { ssrRenderAttrs as _ssrRenderAttrs, ssrInterpolate as _ssrInterpolate } from \\"vue/server-renderer\\"
|
import { ssrRenderAttrs as _ssrRenderAttrs, ssrInterpolate as _ssrInterpolate } from \\"vue/server-renderer\\"
|
||||||
|
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
__ssrInlineRender: true,
|
__ssrInlineRender: true,
|
||||||
setup(__props) {
|
setup(__props) {
|
||||||
@ -868,7 +883,7 @@ _useCssVars(_ctx => ({
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
|
|
||||||
return (_ctx, _push, _parent, _attrs) => {
|
return (_ctx, _push, _parent, _attrs) => {
|
||||||
const _cssVars = { style: {
|
const _cssVars = { style: {
|
||||||
\\"xxxxxxxx-count\\": (count.value)
|
\\"xxxxxxxx-count\\": (count.value)
|
||||||
@ -890,7 +905,7 @@ exports[`SFC compile <script setup> inlineTemplate mode template assignment expr
|
|||||||
"import { createElementVNode as _createElementVNode, isRef as _isRef, unref as _unref, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
|
"import { createElementVNode as _createElementVNode, isRef as _isRef, unref as _unref, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
|
||||||
|
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup(__props) {
|
setup(__props) {
|
||||||
|
|
||||||
@ -898,7 +913,7 @@ export default {
|
|||||||
const maybe = foo()
|
const maybe = foo()
|
||||||
let lett = 1
|
let lett = 1
|
||||||
let v = ref(1)
|
let v = ref(1)
|
||||||
|
|
||||||
return (_ctx, _cache) => {
|
return (_ctx, _cache) => {
|
||||||
return (_openBlock(), _createElementBlock(_Fragment, null, [
|
return (_openBlock(), _createElementBlock(_Fragment, null, [
|
||||||
_createElementVNode(\\"div\\", {
|
_createElementVNode(\\"div\\", {
|
||||||
@ -947,7 +962,7 @@ exports[`SFC compile <script setup> inlineTemplate mode template destructure ass
|
|||||||
"import { createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
|
"import { createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
|
||||||
|
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup(__props) {
|
setup(__props) {
|
||||||
|
|
||||||
@ -955,7 +970,7 @@ export default {
|
|||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
const maybe = foo()
|
const maybe = foo()
|
||||||
let lett = 1
|
let lett = 1
|
||||||
|
|
||||||
return (_ctx, _cache) => {
|
return (_ctx, _cache) => {
|
||||||
return (_openBlock(), _createElementBlock(_Fragment, null, [
|
return (_openBlock(), _createElementBlock(_Fragment, null, [
|
||||||
_createElementVNode(\\"div\\", {
|
_createElementVNode(\\"div\\", {
|
||||||
@ -978,14 +993,14 @@ exports[`SFC compile <script setup> inlineTemplate mode template update expressi
|
|||||||
"import { createElementVNode as _createElementVNode, isRef as _isRef, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
|
"import { createElementVNode as _createElementVNode, isRef as _isRef, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
|
||||||
|
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup(__props) {
|
setup(__props) {
|
||||||
|
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
const maybe = foo()
|
const maybe = foo()
|
||||||
let lett = 1
|
let lett = 1
|
||||||
|
|
||||||
return (_ctx, _cache) => {
|
return (_ctx, _cache) => {
|
||||||
return (_openBlock(), _createElementBlock(_Fragment, null, [
|
return (_openBlock(), _createElementBlock(_Fragment, null, [
|
||||||
_createElementVNode(\\"div\\", {
|
_createElementVNode(\\"div\\", {
|
||||||
@ -1017,14 +1032,14 @@ exports[`SFC compile <script setup> inlineTemplate mode v-model codegen 1`] = `
|
|||||||
"import { vModelText as _vModelText, createElementVNode as _createElementVNode, withDirectives as _withDirectives, unref as _unref, isRef as _isRef, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
|
"import { vModelText as _vModelText, createElementVNode as _createElementVNode, withDirectives as _withDirectives, unref as _unref, isRef as _isRef, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
|
||||||
|
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup(__props) {
|
setup(__props) {
|
||||||
|
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
const maybe = foo()
|
const maybe = foo()
|
||||||
let lett = 1
|
let lett = 1
|
||||||
|
|
||||||
return (_ctx, _cache) => {
|
return (_ctx, _cache) => {
|
||||||
return (_openBlock(), _createElementBlock(_Fragment, null, [
|
return (_openBlock(), _createElementBlock(_Fragment, null, [
|
||||||
_withDirectives(_createElementVNode(\\"input\\", {
|
_withDirectives(_createElementVNode(\\"input\\", {
|
||||||
@ -1055,7 +1070,7 @@ exports[`SFC compile <script setup> inlineTemplate mode with defineExpose() 1`]
|
|||||||
|
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
expose({ count })
|
expose({ count })
|
||||||
|
|
||||||
return () => {}
|
return () => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1069,7 +1084,7 @@ exports[`SFC compile <script setup> should expose top level declarations 1`] = `
|
|||||||
function cc() {}
|
function cc() {}
|
||||||
class dd {}
|
class dd {}
|
||||||
import { x } from './x'
|
import { x } from './x'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
@ -1078,7 +1093,7 @@ export default {
|
|||||||
const b = 2
|
const b = 2
|
||||||
function c() {}
|
function c() {}
|
||||||
class d {}
|
class d {}
|
||||||
|
|
||||||
return { aa, bb, cc, dd, a, b, c, d, xx, x }
|
return { aa, bb, cc, dd, a, b, c, d, xx, x }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1088,12 +1103,12 @@ return { aa, bb, cc, dd, a, b, c, d, xx, x }
|
|||||||
exports[`SFC compile <script setup> with TypeScript const Enum 1`] = `
|
exports[`SFC compile <script setup> with TypeScript const Enum 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
const enum Foo { A = 123 }
|
const enum Foo { A = 123 }
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
return { Foo }
|
return { Foo }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1103,14 +1118,14 @@ return { Foo }
|
|||||||
exports[`SFC compile <script setup> with TypeScript defineEmits w/ type (exported interface) 1`] = `
|
exports[`SFC compile <script setup> with TypeScript defineEmits w/ type (exported interface) 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
export interface Emits { (e: 'foo' | 'bar'): void }
|
export interface Emits { (e: 'foo' | 'bar'): void }
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
emits: [\\"foo\\", \\"bar\\"],
|
emits: [\\"foo\\", \\"bar\\"],
|
||||||
setup(__props, { expose, emit }: { emit: ({ (e: 'foo' | 'bar'): void }), expose: any, slots: any, attrs: any }) {
|
setup(__props, { expose, emit }: { emit: ({ (e: 'foo' | 'bar'): void }), expose: any, slots: any, attrs: any }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { emit }
|
return { emit }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1120,14 +1135,14 @@ return { emit }
|
|||||||
exports[`SFC compile <script setup> with TypeScript defineEmits w/ type (exported type alias) 1`] = `
|
exports[`SFC compile <script setup> with TypeScript defineEmits w/ type (exported type alias) 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
export type Emits = { (e: 'foo' | 'bar'): void }
|
export type Emits = { (e: 'foo' | 'bar'): void }
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
emits: [\\"foo\\", \\"bar\\"],
|
emits: [\\"foo\\", \\"bar\\"],
|
||||||
setup(__props, { expose, emit }: { emit: ({ (e: 'foo' | 'bar'): void }), expose: any, slots: any, attrs: any }) {
|
setup(__props, { expose, emit }: { emit: ({ (e: 'foo' | 'bar'): void }), expose: any, slots: any, attrs: any }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { emit }
|
return { emit }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1137,14 +1152,14 @@ return { emit }
|
|||||||
exports[`SFC compile <script setup> with TypeScript defineEmits w/ type (interface) 1`] = `
|
exports[`SFC compile <script setup> with TypeScript defineEmits w/ type (interface) 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
interface Emits { (e: 'foo' | 'bar'): void }
|
interface Emits { (e: 'foo' | 'bar'): void }
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
emits: [\\"foo\\", \\"bar\\"],
|
emits: [\\"foo\\", \\"bar\\"],
|
||||||
setup(__props, { expose, emit }: { emit: ({ (e: 'foo' | 'bar'): void }), expose: any, slots: any, attrs: any }) {
|
setup(__props, { expose, emit }: { emit: ({ (e: 'foo' | 'bar'): void }), expose: any, slots: any, attrs: any }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { emit }
|
return { emit }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1154,14 +1169,14 @@ return { emit }
|
|||||||
exports[`SFC compile <script setup> with TypeScript defineEmits w/ type (referenced exported function type) 1`] = `
|
exports[`SFC compile <script setup> with TypeScript defineEmits w/ type (referenced exported function type) 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
export type Emits = (e: 'foo' | 'bar') => void
|
export type Emits = (e: 'foo' | 'bar') => void
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
emits: [\\"foo\\", \\"bar\\"],
|
emits: [\\"foo\\", \\"bar\\"],
|
||||||
setup(__props, { expose, emit }: { emit: ((e: 'foo' | 'bar') => void), expose: any, slots: any, attrs: any }) {
|
setup(__props, { expose, emit }: { emit: ((e: 'foo' | 'bar') => void), expose: any, slots: any, attrs: any }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { emit }
|
return { emit }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1171,14 +1186,14 @@ return { emit }
|
|||||||
exports[`SFC compile <script setup> with TypeScript defineEmits w/ type (referenced function type) 1`] = `
|
exports[`SFC compile <script setup> with TypeScript defineEmits w/ type (referenced function type) 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
type Emits = (e: 'foo' | 'bar') => void
|
type Emits = (e: 'foo' | 'bar') => void
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
emits: [\\"foo\\", \\"bar\\"],
|
emits: [\\"foo\\", \\"bar\\"],
|
||||||
setup(__props, { expose, emit }: { emit: ((e: 'foo' | 'bar') => void), expose: any, slots: any, attrs: any }) {
|
setup(__props, { expose, emit }: { emit: ((e: 'foo' | 'bar') => void), expose: any, slots: any, attrs: any }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { emit }
|
return { emit }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1188,14 +1203,14 @@ return { emit }
|
|||||||
exports[`SFC compile <script setup> with TypeScript defineEmits w/ type (type alias) 1`] = `
|
exports[`SFC compile <script setup> with TypeScript defineEmits w/ type (type alias) 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
type Emits = { (e: 'foo' | 'bar'): void }
|
type Emits = { (e: 'foo' | 'bar'): void }
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
emits: [\\"foo\\", \\"bar\\"],
|
emits: [\\"foo\\", \\"bar\\"],
|
||||||
setup(__props, { expose, emit }: { emit: ({ (e: 'foo' | 'bar'): void }), expose: any, slots: any, attrs: any }) {
|
setup(__props, { expose, emit }: { emit: ({ (e: 'foo' | 'bar'): void }), expose: any, slots: any, attrs: any }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { emit }
|
return { emit }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1210,8 +1225,8 @@ export default /*#__PURE__*/_defineComponent({
|
|||||||
setup(__props, { expose, emit }: { emit: ({(e: 'foo' | 'bar'): void; (e: 'baz', id: number): void;}), expose: any, slots: any, attrs: any }) {
|
setup(__props, { expose, emit }: { emit: ({(e: 'foo' | 'bar'): void; (e: 'baz', id: number): void;}), expose: any, slots: any, attrs: any }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { emit }
|
return { emit }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1226,8 +1241,8 @@ export default /*#__PURE__*/_defineComponent({
|
|||||||
setup(__props, { expose, emit }: { emit: ((e: 'foo' | 'bar') => void), expose: any, slots: any, attrs: any }) {
|
setup(__props, { expose, emit }: { emit: ((e: 'foo' | 'bar') => void), expose: any, slots: any, attrs: any }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { emit }
|
return { emit }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1237,7 +1252,7 @@ return { emit }
|
|||||||
exports[`SFC compile <script setup> with TypeScript defineProps w/ exported interface 1`] = `
|
exports[`SFC compile <script setup> with TypeScript defineProps w/ exported interface 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
export interface Props { x?: number }
|
export interface Props { x?: number }
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
props: {
|
props: {
|
||||||
x: { type: Number, required: false }
|
x: { type: Number, required: false }
|
||||||
@ -1245,8 +1260,8 @@ export default /*#__PURE__*/_defineComponent({
|
|||||||
setup(__props: any, { expose }) {
|
setup(__props: any, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { }
|
return { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1257,7 +1272,7 @@ exports[`SFC compile <script setup> with TypeScript defineProps w/ exported inte
|
|||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
|
|
||||||
export interface Props { x?: number }
|
export interface Props { x?: number }
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
props: {
|
props: {
|
||||||
x: { type: Number, required: false }
|
x: { type: Number, required: false }
|
||||||
@ -1265,8 +1280,8 @@ export default /*#__PURE__*/_defineComponent({
|
|||||||
setup(__props: any, { expose }) {
|
setup(__props: any, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { }
|
return { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1276,7 +1291,7 @@ return { }
|
|||||||
exports[`SFC compile <script setup> with TypeScript defineProps w/ exported type alias 1`] = `
|
exports[`SFC compile <script setup> with TypeScript defineProps w/ exported type alias 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
export type Props = { x?: number }
|
export type Props = { x?: number }
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
props: {
|
props: {
|
||||||
x: { type: Number, required: false }
|
x: { type: Number, required: false }
|
||||||
@ -1284,8 +1299,8 @@ export default /*#__PURE__*/_defineComponent({
|
|||||||
setup(__props: any, { expose }) {
|
setup(__props: any, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { }
|
return { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1295,7 +1310,7 @@ return { }
|
|||||||
exports[`SFC compile <script setup> with TypeScript defineProps w/ interface 1`] = `
|
exports[`SFC compile <script setup> with TypeScript defineProps w/ interface 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
interface Props { x?: number }
|
interface Props { x?: number }
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
props: {
|
props: {
|
||||||
x: { type: Number, required: false }
|
x: { type: Number, required: false }
|
||||||
@ -1303,8 +1318,8 @@ export default /*#__PURE__*/_defineComponent({
|
|||||||
setup(__props: any, { expose }) {
|
setup(__props: any, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { }
|
return { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1317,7 +1332,7 @@ interface Test {}
|
|||||||
|
|
||||||
type Alias = number[]
|
type Alias = number[]
|
||||||
|
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
props: {
|
props: {
|
||||||
string: { type: String, required: true },
|
string: { type: String, required: true },
|
||||||
@ -1350,8 +1365,8 @@ export default /*#__PURE__*/_defineComponent({
|
|||||||
setup(__props: any, { expose }) {
|
setup(__props: any, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { }
|
return { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1361,7 +1376,7 @@ return { }
|
|||||||
exports[`SFC compile <script setup> with TypeScript defineProps w/ type alias 1`] = `
|
exports[`SFC compile <script setup> with TypeScript defineProps w/ type alias 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
type Props = { x?: number }
|
type Props = { x?: number }
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
props: {
|
props: {
|
||||||
x: { type: Number, required: false }
|
x: { type: Number, required: false }
|
||||||
@ -1369,8 +1384,8 @@ export default /*#__PURE__*/_defineComponent({
|
|||||||
setup(__props: any, { expose }) {
|
setup(__props: any, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { }
|
return { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1401,12 +1416,12 @@ exports[`SFC compile <script setup> with TypeScript hoist type declarations 1`]
|
|||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
export interface Foo {}
|
export interface Foo {}
|
||||||
type Bar = {}
|
type Bar = {}
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
return { }
|
return { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1417,12 +1432,12 @@ exports[`SFC compile <script setup> with TypeScript import type 1`] = `
|
|||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
import type { Foo } from './main.ts'
|
import type { Foo } from './main.ts'
|
||||||
import { type Bar, Baz } from './main.ts'
|
import { type Bar, Baz } from './main.ts'
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
return { Baz }
|
return { Baz }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1432,12 +1447,12 @@ return { Baz }
|
|||||||
exports[`SFC compile <script setup> with TypeScript runtime Enum 1`] = `
|
exports[`SFC compile <script setup> with TypeScript runtime Enum 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
enum Foo { A = 123 }
|
enum Foo { A = 123 }
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
return { Foo }
|
return { Foo }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1447,16 +1462,16 @@ return { Foo }
|
|||||||
exports[`SFC compile <script setup> with TypeScript runtime Enum in normal script 1`] = `
|
exports[`SFC compile <script setup> with TypeScript runtime Enum in normal script 1`] = `
|
||||||
"import { defineComponent as _defineComponent } from 'vue'
|
"import { defineComponent as _defineComponent } from 'vue'
|
||||||
enum Foo { A = 123 }
|
enum Foo { A = 123 }
|
||||||
|
|
||||||
export enum D { D = \\"D\\" }
|
export enum D { D = \\"D\\" }
|
||||||
const enum C { C = \\"C\\" }
|
const enum C { C = \\"C\\" }
|
||||||
enum B { B = \\"B\\" }
|
enum B { B = \\"B\\" }
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
setup(__props, { expose }) {
|
setup(__props, { expose }) {
|
||||||
expose();
|
expose();
|
||||||
|
|
||||||
|
|
||||||
return { D, C, B, Foo }
|
return { D, C, B, Foo }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1466,7 +1481,7 @@ return { D, C, B, Foo }
|
|||||||
exports[`SFC compile <script setup> with TypeScript withDefaults (dynamic) 1`] = `
|
exports[`SFC compile <script setup> with TypeScript withDefaults (dynamic) 1`] = `
|
||||||
"import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from 'vue'
|
"import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from 'vue'
|
||||||
import { defaults } from './foo'
|
import { defaults } from './foo'
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
props: _mergeDefaults({
|
props: _mergeDefaults({
|
||||||
foo: { type: String, required: false },
|
foo: { type: String, required: false },
|
||||||
@ -1482,8 +1497,8 @@ const props = __props as {
|
|||||||
baz: boolean
|
baz: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { props, defaults }
|
return { props, defaults }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1505,8 +1520,8 @@ export default /*#__PURE__*/_defineComponent({
|
|||||||
|
|
||||||
const props = __props as { foo: string, bar?: number, baz: boolean, qux(): number }
|
const props = __props as { foo: string, bar?: number, baz: boolean, qux(): number }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { props }
|
return { props }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,6 +168,16 @@ defineExpose({ foo: 123 })
|
|||||||
expect(content).toMatch(/\bexpose\(\{ foo: 123 \}\)/)
|
expect(content).toMatch(/\bexpose\(\{ foo: 123 \}\)/)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('<script> after <script setup> the script content not end with `\\n`',() => {
|
||||||
|
const { content } = compile(`
|
||||||
|
<script setup>
|
||||||
|
import { x } from './x'
|
||||||
|
</script>
|
||||||
|
<script>const n = 1</script>
|
||||||
|
`)
|
||||||
|
assertCode(content)
|
||||||
|
})
|
||||||
|
|
||||||
describe('<script> and <script setup> co-usage', () => {
|
describe('<script> and <script setup> co-usage', () => {
|
||||||
test('script first', () => {
|
test('script first', () => {
|
||||||
const { content } = compile(`
|
const { content } = compile(`
|
||||||
|
@ -943,6 +943,11 @@ export function compileScript(
|
|||||||
// declared before being used in the actual component definition
|
// declared before being used in the actual component definition
|
||||||
if (scriptStartOffset! > startOffset) {
|
if (scriptStartOffset! > startOffset) {
|
||||||
s.move(scriptStartOffset!, scriptEndOffset!, 0)
|
s.move(scriptStartOffset!, scriptEndOffset!, 0)
|
||||||
|
const content = s.slice(scriptStartOffset!, scriptEndOffset!)
|
||||||
|
// when the script content not end with `\n` we add `\n` for the script content
|
||||||
|
if(!/(\n *$)/.test(content)) {
|
||||||
|
s.overwrite(scriptStartOffset!,scriptEndOffset!,`${content}\n`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user