mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-25 12:52:47 -07:00
feat(packages/vite-plugins): use named export and consistent names across plugins (#260)
This commit is contained in:
committed by
GitHub
parent
d12d8404ec
commit
7b7447f9a0
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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<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 () => {
|
||||
|
||||
@@ -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 }),
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user