From 7b7447f9a0d1e601ae7c70c9c19e3579875b523c Mon Sep 17 00:00:00 2001 From: Marco Pasqualetti <24919330+marcalexiei@users.noreply.github.com> Date: Tue, 24 Dec 2024 11:41:58 +0100 Subject: [PATCH] feat(packages/vite-plugins): use named export and consistent names across plugins (#260) --- packages/tuono-fs-router-vite-plugin/src/index.ts | 2 +- packages/tuono-lazy-fn-vite-plugin/src/index.ts | 6 +++--- .../tests/transpileSource.test.ts | 4 ++-- packages/tuono/src/build/index.ts | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/tuono-fs-router-vite-plugin/src/index.ts b/packages/tuono-fs-router-vite-plugin/src/index.ts index c1ae2402..8a36aba1 100644 --- a/packages/tuono-fs-router-vite-plugin/src/index.ts +++ b/packages/tuono-fs-router-vite-plugin/src/index.ts @@ -8,7 +8,7 @@ const ROUTES_DIRECTORY_PATH = './src/routes' let lock = false -export default function RouterGenerator(): Plugin { +export function TuonoFsRouterPlugin(): Plugin { const generate = async (): Promise => { if (lock) return lock = true diff --git a/packages/tuono-lazy-fn-vite-plugin/src/index.ts b/packages/tuono-lazy-fn-vite-plugin/src/index.ts index 61f71c5b..b34eb6ae 100644 --- a/packages/tuono-lazy-fn-vite-plugin/src/index.ts +++ b/packages/tuono-lazy-fn-vite-plugin/src/index.ts @@ -119,12 +119,12 @@ const TurnLazyIntoStaticImport: BabelPluginItem = { }, } -interface LazyLoadingPluginOptions { +interface TuonoLazyFnPluginOptions { include: FilterPattern } -export function LazyLoadingPlugin( - options: LazyLoadingPluginOptions, +export function TuonoLazyFnPlugin( + options: TuonoLazyFnPluginOptions, ): VitePlugin { const { include } = options diff --git a/packages/tuono-lazy-fn-vite-plugin/tests/transpileSource.test.ts b/packages/tuono-lazy-fn-vite-plugin/tests/transpileSource.test.ts index 8f9dbb7c..ffdbc177 100644 --- a/packages/tuono-lazy-fn-vite-plugin/tests/transpileSource.test.ts +++ b/packages/tuono-lazy-fn-vite-plugin/tests/transpileSource.test.ts @@ -4,7 +4,7 @@ import os from 'node:os' import { it, expect, describe } from 'vitest' import type { Plugin } from 'vite' -import { LazyLoadingPlugin } from '../src' +import { TuonoLazyFnPlugin } from '../src' type ViteTransformHandler = Exclude< Plugin['transform'], @@ -17,7 +17,7 @@ function getTransform(): (...args: Parameters) => string { /** @warning Keep in sync with {@link createBaseViteConfigFromTuonoConfig} */ const pluginFilesInclude = /\.(jsx|js|mdx|md|tsx|ts)$/ - return LazyLoadingPlugin({ include: pluginFilesInclude }).transform as never + return TuonoLazyFnPlugin({ include: pluginFilesInclude }).transform as never } describe('"dynamic" sources', async () => { diff --git a/packages/tuono/src/build/index.ts b/packages/tuono/src/build/index.ts index 3703068d..72345d4a 100644 --- a/packages/tuono/src/build/index.ts +++ b/packages/tuono/src/build/index.ts @@ -2,8 +2,8 @@ import type { InlineConfig, Plugin } from 'vite' import { build, createServer, mergeConfig } from 'vite' import react from '@vitejs/plugin-react-swc' import inject from '@rollup/plugin-inject' -import ViteFsRouter from 'tuono-fs-router-vite-plugin' -import { LazyLoadingPlugin } from 'tuono-lazy-fn-vite-plugin' +import { TuonoFsRouterPlugin } from 'tuono-fs-router-vite-plugin' +import { TuonoLazyFnPlugin } from 'tuono-lazy-fn-vite-plugin' import type { TuonoConfig } from '../config' @@ -66,8 +66,8 @@ function createBaseViteConfigFromTuonoConfig( // @ts-expect-error see above comment react({ include: pluginFilesInclude }), - ViteFsRouter(), - LazyLoadingPlugin({ include: pluginFilesInclude }), + TuonoFsRouterPlugin(), + TuonoLazyFnPlugin({ include: pluginFilesInclude }), ], }