diff --git a/README.md b/README.md index 18cdb44..c6d927a 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ await fs.rm('path/to/somewhere', { recursive: true }); This is a more direct way to interact with the relay server, however, it is inconvenient, error-prone and does not have a stable API. Breaking changes to this method are not documented. **This method is documented purely for educational reasons.** Only use this method if you want to play around with the plugin and better understand what it does in the background. ```ts -import { activePort } from '@vite-plugin-fs-runtime'; +import { activePort } from 'virtual:fs'; const url = `http://localhost:${activePort}`; diff --git a/__tests__/src/abstraction/index.test.ts b/__tests__/src/abstraction/index.test.ts index ec5cf13..f6ee4ba 100644 --- a/__tests__/src/abstraction/index.test.ts +++ b/__tests__/src/abstraction/index.test.ts @@ -7,7 +7,7 @@ global.fetch = jest.fn((url: RequestInfo, init?: RequestInit) => { }) as jest.Mock; const testPort = 7070; -jest.mock('@vite-plugin-fs-runtime', () => ({ activePort: 7070 }), { virtual: true }); +jest.mock('virtual:fs', () => ({ activePort: 7070 }), { virtual: true }); describe('abstraction', () => { it('should build correct readdir queries', async () => { diff --git a/src/abstraction/index.ts b/src/abstraction/index.ts index a77a40b..2a25980 100644 --- a/src/abstraction/index.ts +++ b/src/abstraction/index.ts @@ -1,4 +1,4 @@ -import { activePort } from '@vite-plugin-fs-runtime'; +import { activePort } from 'virtual:fs'; import type { SimpleDirent, SimpleStats } from 'src/common/ApiResponses'; const url = `http://localhost:${activePort}`; diff --git a/src/plugin/index.ts b/src/plugin/index.ts index fd608ae..061aed8 100644 --- a/src/plugin/index.ts +++ b/src/plugin/index.ts @@ -5,7 +5,7 @@ import { UserOptions, resolveOptions } from './Options'; function VitePluginFs(userOptiuons: UserOptions = {}): Plugin { const options = resolveOptions(userOptiuons); - const virtualModuleId = '@vite-plugin-fs-runtime'; + const virtualModuleId = 'virtual:fs'; const resolvedVirtualModuleId = `\0${virtualModuleId}`; let server: null | FsServer = null; @@ -21,6 +21,12 @@ function VitePluginFs(userOptiuons: UserOptions = {}): Plugin { if (env.mode === 'development') { isProd = false; } + + return { + optimizeDeps: { + exclude: [virtualModuleId], + }, + }; }, async buildStart() { diff --git a/src/runtime.d.ts b/src/runtime.d.ts index 205323a..8492bec 100644 --- a/src/runtime.d.ts +++ b/src/runtime.d.ts @@ -1,3 +1,3 @@ -declare module '@vite-plugin-fs-runtime' { +declare module 'virtual:fs' { const activePort: number; } diff --git a/tsup.config.ts b/tsup.config.ts index 352db6c..4fbd897 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -9,5 +9,5 @@ export default defineConfig({ format: ['cjs', 'esm'], target: 'node14', outDir: 'lib', - external: ['@vite-plugin-fs-runtime'], + external: ['virtual:fs'], });