Skip to content

Commit

Permalink
chore: fix bundling
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Dec 5, 2023
1 parent 1c26058 commit c074839
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 6 additions & 4 deletions stores/playground.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Raw } from 'vue'
import type { WebContainer, WebContainerProcess } from '@webcontainer/api'
import type { VirtualFile } from '../structures/VirtualFile'
import { templates } from '~/templates'

export const PlaygroundStatusOrder = [
'init',
Expand Down Expand Up @@ -31,9 +30,10 @@ export const usePlaygroundStore = defineStore('playground', () => {
let processInstall: WebContainerProcess | undefined
let processDev: WebContainerProcess | undefined

// Mount the playground
// Mount the playground on client side
if (import.meta.client) {
;(async () => {
async function mount() {
const { templates } = await import('../templates')
const { files: _files, tree } = await templates.basic({
nuxtrc: [
// Have color mode on initial load
Expand Down Expand Up @@ -80,7 +80,9 @@ export const usePlaygroundStore = defineStore('playground', () => {
killPreviousProcess()
})
}
})()
}

/* #__PURE__ */ mount()
}

function killPreviousProcess() {
Expand Down
3 changes: 3 additions & 0 deletions templates/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import type { TemplateOptions } from './types'
import { filesToWebContainerFs } from './utils'

export default function load(options: TemplateOptions = {}) {
if (import.meta.server)
throw new Error('This template can only be used on the client')

const rawInput = import.meta.glob([
'./basic/**/*.*',
'./basic/**/.layer-playground/**/*.*',
Expand Down

0 comments on commit c074839

Please sign in to comment.