Skip to content

Commit

Permalink
fix: register composition api before layouts
Browse files Browse the repository at this point in the history
closes #64, #65
  • Loading branch information
danielroe committed May 19, 2020
1 parent ebd4881 commit 93024a8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"lib/index.d.ts",
"!**/*.map"
],
"sideEffects": false,
"scripts": {
"build": "yarn clean && yarn compile",
"watch": "yarn compile -w",
Expand Down
12 changes: 7 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { resolve, join } from 'path'
import Vue from 'vue'
import CompositionApi from '@vue/composition-api'
import type { Module } from '@nuxt/types'

Vue.use(CompositionApi)

const compositionApiModule: Module<any> = function () {
const libRoot = resolve(__dirname, '..')

let corejsPolyfill
try {
if (!this.options.modern) {
// eslint-disable-next-line
const corejsPkg = require('core-js/package.json')
corejsPolyfill = corejsPkg.version.slice(0, 1)
}
// eslint-disable-next-line
const corejsPkg = require('core-js/package.json')
corejsPolyfill = corejsPkg.version.slice(0, 1)
} catch {
corejsPolyfill = undefined
}
Expand Down
5 changes: 0 additions & 5 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ import 'core-js/features/reflect/own-keys'
import 'core-js/modules/es6.reflect.own-keys'
<% } %>

import Vue from 'vue'
import CompositionApi from '@vue/composition-api'

import { setSSRContext } from 'nuxt-composition-api'

Vue.use(CompositionApi)

/**
*
* @type {Plugin} plugin
Expand Down
12 changes: 11 additions & 1 deletion test/fixture/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
<h1>Test fixture</h1>
<Nuxt />
<footer>
<h2>Layout</h2>
<p>
<code>route: {{ route.path }}</code>
</p>
<p>
<nuxt-link to="/">
Link back home
Expand All @@ -13,11 +17,17 @@
</template>

<script>
import { defineComponent, useContext } from 'nuxt-composition-api'
import { defineComponent, useContext, useMeta } from 'nuxt-composition-api'
export default defineComponent({
head: {},
setup() {
const { route } = useContext()
const { title } = useMeta()
title.value = 'My fixture'
return { route, title }
},
})
</script>
1 change: 0 additions & 1 deletion test/fixture/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = {
buildDir: resolve(__dirname, '.nuxt'),
srcDir: __dirname,
head: {
title: 'My fixture',
link: [
{
rel: "stylesheet", href: "https://newcss.net/lite.css"
Expand Down

1 comment on commit 93024a8

@vercel
Copy link

@vercel vercel bot commented on 93024a8 May 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.