diff --git a/docs/content/en/getting-started/setup.md b/docs/content/en/getting-started/setup.md index e5653345..205b60a4 100644 --- a/docs/content/en/getting-started/setup.md +++ b/docs/content/en/getting-started/setup.md @@ -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. - 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. - 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] diff --git a/src/index.ts b/src/index.ts index dbf017c7..0fe74a7f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,11 +19,15 @@ const utils = loadUtils() const compositionApiModule: Module = 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 } @@ -36,7 +40,7 @@ const compositionApiModule: Module = function () { }, }) - this.addPlugin({ + const { dst: metaPluginDst } = this.addTemplate({ src: resolve(libRoot, 'templates', 'meta.js'), fileName: join('composition-api', 'meta.js'), }) @@ -102,6 +106,7 @@ const compositionApiModule: Module = 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