Skip to content

Commit

Permalink
chore: try
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Mar 3, 2022
1 parent 2d953dd commit f9f5c64
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/playground/ssr-deps/__tests__/ssr-deps.spec.ts
Expand Up @@ -15,6 +15,11 @@ test('msg should be encrypted', async () => {
)
})

test("importing missing dynamic dep shouldn't fail", async () => {
await page.goto(url)
expect(await page.textContent('.missing-dep')).toEqual('not-exist')
})

test('msg read by fs/promises', async () => {
await page.goto(url)
expect(await page.textContent('.file-message')).toMatch('File Content!')
Expand Down
18 changes: 17 additions & 1 deletion packages/playground/ssr-vue/src/pages/Home.vue
Expand Up @@ -15,15 +15,20 @@
encrypted message:
<p class="encrypted-msg"></p>
</div>
<div>
missing-dep
<p class="missing-dep">{{ missingDep }}</p>
</div>

<ImportType />
</template>

<script setup>
<script setup async>
import foo from '@foo'
import { msg as virtualMsg } from '@virtual-file'
import { reactive, defineAsyncComponent } from 'vue'
import Button from '../components/button'
const ImportType = load('ImportType')
const Foo = defineAsyncComponent(() =>
import('../components/Foo').then((mod) => mod.Foo)
Expand All @@ -36,6 +41,17 @@ const url = import.meta.env.SSR
: document.querySelector('.import-meta-url').textContent
const protocol = new URL(url).protocol
async function tryMissingDynamicLoad() {
try {
await import('some-missing-patch')
return 'imported'
} catch (e) {
return 'not-exist'
}
}
const missingDep = await tryMissingDynamicLoad()
const state = reactive({
count: 0,
protocol,
Expand Down

0 comments on commit f9f5c64

Please sign in to comment.