From 4cf110e0d8fa7bcd479d138c9cb0abc033bb9873 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 13 Dec 2022 09:39:14 +0000 Subject: [PATCH] fix(nuxt): make dev-only regexp less greedy (#9679) --- packages/nuxt/src/core/plugins/dev-only.ts | 2 +- test/fixtures/basic/pages/index.vue | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/nuxt/src/core/plugins/dev-only.ts b/packages/nuxt/src/core/plugins/dev-only.ts index 8887035b41..53e2476e9c 100644 --- a/packages/nuxt/src/core/plugins/dev-only.ts +++ b/packages/nuxt/src/core/plugins/dev-only.ts @@ -9,7 +9,7 @@ interface DevOnlyPluginOptions { } export const DevOnlyPlugin = createUnplugin((options: DevOnlyPluginOptions) => { - const DEVONLY_COMP_RE = /(:?[\s\S]*)<\/dev-?only>/gmi + const DEVONLY_COMP_RE = /<(dev-only|DevOnly)>[\s\S]*?<\/(dev-only|DevOnly)>/g return { name: 'nuxt:server-devonly:transform', diff --git a/test/fixtures/basic/pages/index.vue b/test/fixtures/basic/pages/index.vue index 7935e551b0..a524f966f1 100644 --- a/test/fixtures/basic/pages/index.vue +++ b/test/fixtures/basic/pages/index.vue @@ -7,6 +7,8 @@
RuntimeConfig | testConfig: {{ config.testConfig }}
Composable | foo: {{ foo }}
Composable | bar: {{ bar }}
+ Some dev-only info +
Some dev-only info
Composable | template: {{ templateAutoImport }}
Path: {{ $route.fullPath }}