Skip to content

Commit

Permalink
feat: add $fetch to client
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 20, 2020
1 parent c8b1346 commit 48cf97c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import nuxt2 from './module/nuxt2'

export default function () {
const { nuxt } = this
return nuxt2(nuxt)
return nuxt2(nuxt, this)
}
8 changes: 7 additions & 1 deletion src/module/nuxt2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getsigmaContext, SigmaContext } from '../context'
import { createDevServer } from '../server'
import wpfs from '../utils/wpfs'

export default function (nuxt) {
export default function (nuxt, moduleContainer) {
// Build in node_modules/.cache/nuxt
const oldBuildDir = nuxt.options.buildDir
nuxt.options.buildDir = resolve(nuxt.options.rootDir, 'node_modules/.cache/nuxt')
Expand Down Expand Up @@ -33,6 +33,12 @@ export default function (nuxt) {
nuxt.server = createNuxt2DevServer(sigmaDevContext)
}

// $fetch support in client
moduleContainer.addPlugin({
fileName: 'fetch.client.js',
src: resolve(sigmaContext._internal.runtimeDir, 'app/fetch.client.js')
})

// serverMiddleware bridge
// TODO: render:setupMiddleware hook
// TODO: support m.prefix and m.route
Expand Down

0 comments on commit 48cf97c

Please sign in to comment.