Skip to content

Commit

Permalink
fix: ensure meta plugin is loaded last
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Nov 25, 2020
1 parent 10ac9d9 commit c5c7299
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 0 additions & 2 deletions docs/content/en/getting-started/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ version: 0.161

Note that [using `buildModules`](https://nuxtjs.org/api/configuration-modules#-code-buildmodules-code-) requires Nuxt >= 2.9. Just add it to your `modules` if you're on a lower version.

<alert type="warning">If you are using `@nuxtjs/pwa` (or any other module that modifies your global `head` properties), make sure to add this module after it in the `buildModules` list.</alert>

3. **Optional**. Currently [there's an issue with static site generation and async functions](https://github.com/nuxt-community/composition-api/issues/44) which means that you'll need to add time between pages being generated to allow for any async functions to resolve, if you are pre-generating any of your pages:

```js[nuxt.config.js]
Expand Down
15 changes: 10 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ const utils = loadUtils()
const compositionApiModule: Module<any> = function () {
const libRoot = resolve(__dirname, '..')

let corejsPolyfill
let corejsPolyfill = this.nuxt.options.build.corejs
? String(this.nuxt.options.build.corejs)
: undefined
try {
// eslint-disable-next-line
const corejsPkg = require('core-js/package.json')
corejsPolyfill = corejsPkg.version.slice(0, 1)
if (!corejsPolyfill) {
// eslint-disable-next-line
const corejsPkg = require('core-js/package.json')
corejsPolyfill = corejsPkg.version.slice(0, 1)
}
} catch {
corejsPolyfill = undefined
}
Expand All @@ -36,7 +40,7 @@ const compositionApiModule: Module<any> = function () {
},
})

this.addPlugin({
const { dst: metaPluginDst } = this.addTemplate({
src: resolve(libRoot, 'templates', 'meta.js'),
fileName: join('composition-api', 'meta.js'),
})
Expand Down Expand Up @@ -102,6 +106,7 @@ const compositionApiModule: Module<any> = function () {

this.options.plugins = this.options.plugins || []
this.options.plugins.unshift(resolve(this.options.buildDir || '', pluginDst))
this.options.plugins.push(resolve(this.options.buildDir || '', metaPluginDst))
}

export default compositionApiModule
Expand Down

0 comments on commit c5c7299

Please sign in to comment.