Nuxt/packages/nuxt/test/__snapshots__/treeshake-client.test.ts.snap

218 lines
7.0 KiB
Plaintext
Raw Permalink Normal View History

2023-03-06 00:26:09 +00:00
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`treeshake client only in ssr > should treeshake ClientOnly correctly in dev 1`] = `
"
import DontRemoveThisSinceItIsUsedInSetup from './ComponentWithProps.vue'
import { Glob, } from '#components'
const _sfc_main = {
__name: 'SomeComponent1',
setup(__props, { expose }) {
expose();
const hello = 'world'
const NotDotClientComponent = defineAsyncComponent(() => import('./../some.island.vue'))
const NotToBeTreeShaken = defineAsyncComponent(async () => {
if (process.client) {
return (await import('./../HelloWorld.vue'))
}
return {}
})
const { ButShouldNotBeTreeShaken } = defineAsyncComponent(async () => {
if (process.client) {
return (await import('./../HelloWorld.vue'))
}
return {}
})
const isThis = {}
const { woooooo, } = defineAsyncComponent(async () => {
if (process.client) {
return (await import('./../HelloWorld.vue'))
}
return {}
})
console.log(woooooo)
const [ { Dont, }, That] = defineAsyncComponent(async () => {
if (process.client) {
return (await import('./../HelloWorld.vue'))
}
return {}
})
console.log(DontRemoveThisSinceItIsUsedInSetup.props)
const __returned__ = { hello, NotDotClientComponent, NotToBeTreeShaken, ButShouldNotBeTreeShaken, isThis, woooooo, Dont, That, DontRemoveThisSinceItIsUsedInSetup, get Glob() { return Glob }, }
Object.defineProperty(__returned__, '__isScriptSetup', { enumerable: false, value: true })
return __returned__
}
}
import { withCtx as _withCtx, createVNode as _createVNode, resolveComponent as _resolveComponent } from \\"vue\\"
import { ssrRenderComponent as _ssrRenderComponent, ssrRenderAttrs as _ssrRenderAttrs, ssrInterpolate as _ssrInterpolate } from \\"vue/server-renderer\\"
function _sfc_ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
const _component_DotClientComponent = _resolveComponent(\\"DotClientComponent\\")
const _component_AutoImportedNotTreeShakenComponent = _resolveComponent(\\"AutoImportedNotTreeShakenComponent\\")
const _component_ClientOnly = _resolveComponent(\\"ClientOnly\\")
_push(\`<div\${_ssrRenderAttrs(_attrs)} data-v-one-hash>\`)
_push(_ssrRenderComponent($setup[\\"NotDotClientComponent\\"], null, {
/* STABLE */
}, _parent))
_push(\`<div data-v-one-hash>\`)
_push(_ssrRenderComponent($setup[\\"Glob\\"], null, null, _parent))
_push(\`</div> \${_ssrInterpolate($setup.hello)} <div class=\\"not-client\\" data-v-one-hash> Hello </div>\`)
_push(_ssrRenderComponent(_component_DotClientComponent, null, {
/* STABLE */
}, _parent))
_push(_ssrRenderComponent(_component_ClientOnly, null, {
/* STABLE */
}, _parent))
_push(_ssrRenderComponent($setup[\\"ButShouldNotBeTreeShaken\\"], null, null, _parent))
_push(_ssrRenderComponent($setup[\\"Dont\\"], null, null, _parent))
_push(_ssrRenderComponent($setup[\\"That\\"], null, null, _parent))
_push(_ssrRenderComponent($setup[\\"NotToBeTreeShaken\\"], null, null, _parent))
_push(_ssrRenderComponent(_component_AutoImportedNotTreeShakenComponent, null, null, _parent))
_push(\`</div>\`)
}
import \\"SomeComponent1.vue?vue&type=style&index=0&scoped=one-hash&lang.css\\"
import { useSSRContext as __vite_useSSRContext } from 'vue'
const _sfc_setup = _sfc_main.setup
_sfc_main.setup = (props, ctx) => {
const ssrContext = __vite_useSSRContext()
;(ssrContext.modules || (ssrContext.modules = new Set())).add(\\"SomeComponent1.vue\\")
return _sfc_setup ? _sfc_setup(props, ctx) : undefined
}
import _export_sfc from 'plugin-vue:export-helper'
export default /*#__PURE__*/_export_sfc(_sfc_main, [['ssrRender',_sfc_ssrRender],['__scopeId',\\"data-v-one-hash\\"],['__file',\\"SomeComponent1.vue\\"]])"
`;
exports[`treeshake client only in ssr > should treeshake ClientOnly correctly in prod 1`] = `
"import { unref as _unref, withCtx as _withCtx, createVNode as _createVNode, resolveComponent as _resolveComponent } from \\"vue\\"
import { ssrRenderComponent as _ssrRenderComponent, ssrRenderAttrs as _ssrRenderAttrs, ssrInterpolate as _ssrInterpolate } from \\"vue/server-renderer\\"
import DontRemoveThisSinceItIsUsedInSetup from './ComponentWithProps.vue'
import { Glob, } from '#components'
const _sfc_main = {
__name: 'SomeComponent0',
__ssrInlineRender: true,
setup(__props) {
const hello = 'world'
const NotDotClientComponent = defineAsyncComponent(() => import('./../some.island.vue'))
const NotToBeTreeShaken = defineAsyncComponent(async () => {
if (process.client) {
return (await import('./../HelloWorld.vue'))
}
return {}
})
const { ButShouldNotBeTreeShaken } = defineAsyncComponent(async () => {
if (process.client) {
return (await import('./../HelloWorld.vue'))
}
return {}
})
const isThis = {}
const { woooooo, } = defineAsyncComponent(async () => {
if (process.client) {
return (await import('./../HelloWorld.vue'))
}
return {}
})
console.log(woooooo)
const [ { Dont, }, That] = defineAsyncComponent(async () => {
if (process.client) {
return (await import('./../HelloWorld.vue'))
}
return {}
})
console.log(DontRemoveThisSinceItIsUsedInSetup.props)
return (_ctx, _push, _parent, _attrs) => {
const _component_DotClientComponent = _resolveComponent(\\"DotClientComponent\\")
const _component_AutoImportedNotTreeShakenComponent = _resolveComponent(\\"AutoImportedNotTreeShakenComponent\\")
const _component_ClientOnly = _resolveComponent(\\"ClientOnly\\")
_push(\`<div\${_ssrRenderAttrs(_attrs)} data-v-one-hash>\`)
_push(_ssrRenderComponent(_unref(NotDotClientComponent), null, {
/* STABLE */
}, _parent))
_push(\`<div data-v-one-hash>\`)
_push(_ssrRenderComponent(_unref(Glob), null, null, _parent))
_push(\`</div> \${_ssrInterpolate(hello)} <div class=\\"not-client\\" data-v-one-hash> Hello </div>\`)
_push(_ssrRenderComponent(_component_DotClientComponent, null, {
/* STABLE */
}, _parent))
_push(_ssrRenderComponent(_component_ClientOnly, null, {
/* STABLE */
}, _parent))
_push(_ssrRenderComponent(_unref(ButShouldNotBeTreeShaken), null, null, _parent))
_push(_ssrRenderComponent(_unref(Dont), null, null, _parent))
_push(_ssrRenderComponent(_unref(That), null, null, _parent))
_push(_ssrRenderComponent(_unref(NotToBeTreeShaken), null, null, _parent))
_push(_ssrRenderComponent(_component_AutoImportedNotTreeShakenComponent, null, null, _parent))
_push(\`</div>\`)
}
}
}
import \\"SomeComponent0.vue?vue&type=style&index=0&scoped=one-hash&lang.css\\"
import { useSSRContext as __vite_useSSRContext } from 'vue'
const _sfc_setup = _sfc_main.setup
_sfc_main.setup = (props, ctx) => {
const ssrContext = __vite_useSSRContext()
;(ssrContext.modules || (ssrContext.modules = new Set())).add(\\"SomeComponent0.vue\\")
return _sfc_setup ? _sfc_setup(props, ctx) : undefined
}
import _export_sfc from 'plugin-vue:export-helper'
export default /*#__PURE__*/_export_sfc(_sfc_main, [['__scopeId',\\"data-v-one-hash\\"],['__file',\\"SomeComponent0.vue\\"]])"
`;