From 37e5152af75f215fcb117476a7f0df4c67f4ac63 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 15 Jan 2024 21:16:48 +0000 Subject: [PATCH] refactor: move to `import.meta.*` flags (#1349) --- nuxt.config.ts | 19 ------------- src/app.vue | 2 +- src/components/StaticMarkdownRender.server.ts | 2 +- src/components/TheGithubRepos.server.vue | 4 +-- src/components/TheHome.server.vue | 2 +- src/components/TheTalks.server.vue | 4 +-- src/components/layout/TheSiteHeader.vue | 4 +-- src/content/blog/nuxt-server-components.md | 2 +- src/modules/playwright-inline.ts | 28 +++++++++++++++++++ src/modules/runtime/NuxtPage.vue | 2 +- src/modules/runtime/nuxt-link.ts | 10 +++---- src/pages/blog/[article].vue | 4 +-- src/server/routes/og/[slug].get.ts | 6 ++-- src/server/routes/rss.xml.get.ts | 2 +- src/server/routes/thumbnail/[slug].get.ts | 6 ++-- 15 files changed, 51 insertions(+), 46 deletions(-) create mode 100644 src/modules/playwright-inline.ts diff --git a/nuxt.config.ts b/nuxt.config.ts index 4e4d99b93..38b243d30 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -1,5 +1,4 @@ import { useNuxt } from 'nuxt/kit' -import type { InputPluginOption } from 'rollup' export default defineNuxtConfig({ $production: { @@ -57,24 +56,6 @@ export default defineNuxtConfig({ config.prerender ||= {} config.prerender.crawlLinks = false } - ;(config.rollupConfig!.plugins as InputPluginOption[]).push({ - name: 'purge-the-handler', - transform(_code, id) { - if (id.includes('og/[slug]') || id.includes('thumbnail/[slug]')) { - return 'export default defineEventHandler(() => {})' - } - }, - }) - }, - 'nitro:init'(nitro) { - nitro.options._config.rollupConfig!.plugins = ( - nitro.options._config.rollupConfig!.plugins as InputPluginOption[] - ).filter(p => !p || !('name' in p) || p.name !== 'purge-the-handler') - }, - 'vite:extendConfig'(config, { isClient }) { - if (isClient) { - config.define!['process.env.prerender'] = 'false' - } }, }, diff --git a/src/app.vue b/src/app.vue index ab482b378..ab474abab 100644 --- a/src/app.vue +++ b/src/app.vue @@ -31,7 +31,7 @@ useHead({ }, }) -if (process.server) { +if (import.meta.server) { const PATH_RE = createRegExp( exactly(char.times.any().and(charNotIn('/'))) .as('path') diff --git a/src/components/StaticMarkdownRender.server.ts b/src/components/StaticMarkdownRender.server.ts index 7cb8e728e..eb6b52a8b 100644 --- a/src/components/StaticMarkdownRender.server.ts +++ b/src/components/StaticMarkdownRender.server.ts @@ -6,7 +6,7 @@ export default defineComponent({ path: String, }, async setup(props) { - if (process.dev) { + if (import.meta.dev) { const { data } = await useAsyncData(() => queryContent(props.path!).findOne() ) diff --git a/src/components/TheGithubRepos.server.vue b/src/components/TheGithubRepos.server.vue index a2e3638ae..1201c2ea1 100644 --- a/src/components/TheGithubRepos.server.vue +++ b/src/components/TheGithubRepos.server.vue @@ -40,7 +40,7 @@