Skip to content

Commit

Permalink
feat: compatible with Vite6
Browse files Browse the repository at this point in the history
  • Loading branch information
condorheroblog committed Nov 7, 2024
1 parent 7ae65f7 commit 2aae5a5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/vite-plugin-fake-server/src/FakeFileLoader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DependenciesType } from "bundle-import";
import type { FSWatcher } from "node:fs";
import type { FSWatcher } from "chokidar";
import type { FakeRoute } from "./node";

import type { ResolvePluginOptionsType } from "./resolvePluginOptions";
Expand Down
8 changes: 4 additions & 4 deletions packages/vite-plugin-fake-server/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { HtmlTagDescriptor, Plugin, ResolvedConfig, WatchOptions } from "vite";

import type { ResolvePluginOptionsType } from "./resolvePluginOptions";
import type { VitePluginFakeServerOptions } from "./types";

import type { VitePluginFakeServerOptions } from "./types";
import { STATUS_CODES } from "node:http";

import { isAbsolute, join, relative } from "node:path";

import process from "node:process";
import pkg from "../package.json";
import { generateFakeServer } from "./build";
Expand Down Expand Up @@ -153,7 +152,8 @@ export async function vitePluginFakeServer(options: VitePluginFakeServerOptions
scriptTagList.push({
...scriptTagOptions,
children: `const fakeModuleList = window.__VITE__PLUGIN__FAKE__SERVER__.fakeModuleList;
const { match } = window.__VITE__PLUGIN__FAKE__SERVER__.pathToRegexp;
const pathToRegexp = window.__VITE__PLUGIN__FAKE__SERVER__.pathToRegexp;
const match = pathToRegexp.match ?? pathToRegexp.default.match;
window.__VITE__PLUGIN__FAKE__SERVER__.xhook.before(async function(req, callback) {
${sleep.toString()}
${tryToJSON.toString()}
Expand Down
4 changes: 4 additions & 0 deletions packages/vite-plugin-fake-server/src/utils/buildPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export async function buildPackage(packageName: string) {
// Do not use a configuration file
configFile: false,
build: {
commonjsOptions: {
// Vite6 changes the default behavior of strictRequires from "auto" to "true".
strictRequires: "auto",
},
// Do not output files
write: false,
lib: {
Expand Down

0 comments on commit 2aae5a5

Please sign in to comment.