Skip to content

Commit

Permalink
feat(packages/vite-plugins): use named export and consistent names ac…
Browse files Browse the repository at this point in the history
…ross plugins (#260)
  • Loading branch information
marcalexiei authored Dec 24, 2024
1 parent d12d840 commit 7b7447f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/tuono-fs-router-vite-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> => {
if (lock) return
lock = true
Expand Down
6 changes: 3 additions & 3 deletions packages/tuono-lazy-fn-vite-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -17,7 +17,7 @@ function getTransform(): (...args: Parameters<ViteTransformHandler>) => 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 () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/tuono/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -66,8 +66,8 @@ function createBaseViteConfigFromTuonoConfig(
// @ts-expect-error see above comment
react({ include: pluginFilesInclude }),

ViteFsRouter(),
LazyLoadingPlugin({ include: pluginFilesInclude }),
TuonoFsRouterPlugin(),
TuonoLazyFnPlugin({ include: pluginFilesInclude }),
],
}

Expand Down

0 comments on commit 7b7447f

Please sign in to comment.