From 980ebb0fbe56f3b1fb99c14339e1027d32914005 Mon Sep 17 00:00:00 2001 From: tbitw2549 Date: Thu, 24 Oct 2024 20:42:48 +0300 Subject: [PATCH] Revert "perf: more regex (and related areas) deallocation" This reverts commit 0a0ec349a1ccfb15987802e672bd67cd2a6ae225. --- packages/nuxt/src/components/module.ts | 5 +- .../components/plugins/islands-transform.ts | 24 +- .../nuxt/src/components/plugins/tree-shake.ts | 370 +++++++++--------- packages/nuxt/src/components/scan.ts | 9 +- packages/nuxt/src/components/templates.ts | 2 +- packages/nuxt/src/core/builder.ts | 2 +- packages/nuxt/src/core/nitro.ts | 4 +- packages/nuxt/src/core/nuxt.ts | 5 +- packages/nuxt/src/core/plugins/dev-only.ts | 5 +- .../nuxt/src/core/plugins/layer-aliasing.ts | 5 +- packages/nuxt/src/core/templates.ts | 19 +- packages/nuxt/src/imports/transform.ts | 5 +- packages/nuxt/src/pages/module.ts | 3 +- packages/nuxt/src/pages/plugins/page-meta.ts | 51 +-- .../nuxt/src/pages/plugins/route-injection.ts | 9 +- packages/vite/src/plugins/composable-keys.ts | 9 +- packages/vite/src/plugins/public-dirs.ts | 10 +- playground/components/C.vue | 3 - playground/components/nested/NestedD.vue | 5 - .../components/super/nested/SuperNestedE.vue | 5 - playground/pages/index.vue | 7 - playground/pages/second.vue | 3 - playground/pages/third.vue | 1 - 23 files changed, 274 insertions(+), 287 deletions(-) delete mode 100644 playground/components/C.vue delete mode 100644 playground/components/nested/NestedD.vue delete mode 100644 playground/components/super/nested/SuperNestedE.vue delete mode 100644 playground/pages/index.vue delete mode 100644 playground/pages/second.vue delete mode 100644 playground/pages/third.vue diff --git a/packages/nuxt/src/components/module.ts b/packages/nuxt/src/components/module.ts index 4c5dc50c77..a2a1d8ca7d 100644 --- a/packages/nuxt/src/components/module.ts +++ b/packages/nuxt/src/components/module.ts @@ -21,6 +21,9 @@ function compareDirByPathLength ({ path: pathA }: { path: string }, { path: path return pathB.split(SLASH_SEPARATOR_RE).filter(Boolean).length - pathA.split(SLASH_SEPARATOR_RE).filter(Boolean).length } +const DEFAULT_COMPONENTS_DIRS_RE = /\/components(?:\/(?:global|islands))?$/ +const STARTER_DOT_RE = /^\./g + export type getComponentsT = (mode?: 'client' | 'server' | 'all') => Component[] export default defineNuxtModule({ @@ -75,8 +78,6 @@ export default defineNuxtModule({ })) } - const DEFAULT_COMPONENTS_DIRS_RE = /\/components(?:\/(?:global|islands))?$/ - const STARTER_DOT_RE = /^\./g // Resolve dirs nuxt.hook('app:resolve', async () => { // components/ dirs from all layers diff --git a/packages/nuxt/src/components/plugins/islands-transform.ts b/packages/nuxt/src/components/plugins/islands-transform.ts index 2b854b9bbc..a3e2aba41a 100644 --- a/packages/nuxt/src/components/plugins/islands-transform.ts +++ b/packages/nuxt/src/components/plugins/islands-transform.ts @@ -24,20 +24,20 @@ interface ComponentChunkOptions { buildDir: string } +const SCRIPT_RE = /]*>/gi +const HAS_SLOT_OR_CLIENT_RE = /]*>|nuxt-client/ +const TEMPLATE_RE = /