vite-plugin-mock-dev-server
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -627,2 +627,4 @@ import { Connect, Plugin, ResolvedConfig } from 'vite'; | ||
} | ||
declare const logLevels: Record<LogLevel, number>; | ||
declare function createLogger(prefix: string, defaultLevel?: LogLevel): Logger; | ||
@@ -696,2 +698,2 @@ interface MockLoaderOptions { | ||
export { type BaseMiddlewareOptions, type FormidableFile, type MockData, type MockHttpItem, type MockOptions, type MockRequest, type MockServerPluginOptions, type MockSocketOptions, type MockWebsocketItem, baseMiddleware, createDefineMock, mockDevServerPlugin as default, defineMock, defineMockData, mockDevServerPlugin, mockWebSocket, sortByValidator, transformMockData }; | ||
export { type BaseMiddlewareOptions, type FormidableFile, type Logger, type MockData, type MockHttpItem, type MockOptions, type MockRequest, type MockServerPluginOptions, type MockSocketOptions, type MockWebsocketItem, baseMiddleware, createDefineMock, createLogger, mockDevServerPlugin as default, defineMock, defineMockData, logLevels, mockDevServerPlugin, mockWebSocket, sortByValidator, transformMockData }; |
@@ -16,3 +16,3 @@ // src/plugin.ts | ||
var name = "vite-plugin-mock-dev-server"; | ||
var version = "1.4.0"; | ||
var version = "1.4.1"; | ||
@@ -125,3 +125,3 @@ // src/compiler.ts | ||
build2.onResolve({ filter: /.*/ }, async ({ path: id }) => { | ||
const matchedEntry = alias.find(({ find: find2 }) => matches(find2, id)); | ||
const matchedEntry = alias.find(({ find: find2 }) => aliasMatches(find2, id)); | ||
if (!matchedEntry) | ||
@@ -143,3 +143,3 @@ return null; | ||
} | ||
function matches(pattern, importee) { | ||
function aliasMatches(pattern, importee) { | ||
if (pattern instanceof RegExp) | ||
@@ -343,3 +343,3 @@ return pattern.test(importee); | ||
}); | ||
const mockDeps = getMockDependencies(deps); | ||
const mockDeps = getMockDependencies(deps, config.resolve.alias); | ||
await fsp2.unlink(mockEntry); | ||
@@ -384,7 +384,8 @@ const outputList = [ | ||
} | ||
function getMockDependencies(deps) { | ||
function getMockDependencies(deps, alias) { | ||
const list = /* @__PURE__ */ new Set(); | ||
const excludeDeps = [name, "connect", "cors"]; | ||
const isAlias = (p) => alias.find(({ find }) => aliasMatches(find, p)); | ||
Object.keys(deps).forEach((mPath) => { | ||
const imports = deps[mPath].imports.filter((_) => _.external && !_.path.startsWith("<define:")).map((_) => _.path); | ||
const imports = deps[mPath].imports.filter((_) => _.external && !_.path.startsWith("<define:") && !isAlias(_.path)).map((_) => _.path); | ||
imports.forEach((dep) => { | ||
@@ -422,3 +423,3 @@ if (!excludeDeps.includes(dep) && !isCore(dep)) | ||
import corsMiddleware from 'cors'; | ||
import { baseMiddleware, mockWebSocket } from 'vite-plugin-mock-dev-server'; | ||
import { baseMiddleware, mockWebSocket, createLogger } from 'vite-plugin-mock-dev-server'; | ||
import mockData from './mock-data.js'; | ||
@@ -428,2 +429,3 @@ | ||
const server = createServer(app); | ||
const logger = createLogger('mock-server', 'error'); | ||
const httpProxies = ${JSON.stringify(httpProxies)}; | ||
@@ -434,3 +436,9 @@ const wsProxies = ${JSON.stringify(wsProxies)}; | ||
mockWebSocket({ mockData }, server, wsProxies, cookiesOptions); | ||
mockWebSocket({ | ||
loader: { mockData }, | ||
httpServer: server, | ||
proxies: wsProxies, | ||
cookiesOptions, | ||
logger, | ||
}); | ||
@@ -443,2 +451,3 @@ app.use(corsMiddleware()); | ||
cookiesOptions, | ||
logger, | ||
})); | ||
@@ -475,3 +484,3 @@ | ||
Object.keys(raw || {}).forEach((key) => { | ||
isArray(raw[key]) | ||
Array.isArray(raw[key]) | ||
? mockConfig.push(...raw[key]) | ||
@@ -1680,5 +1689,7 @@ : mockConfig.push(raw[key]) | ||
createDefineMock, | ||
createLogger, | ||
src_default as default, | ||
defineMock, | ||
defineMockData, | ||
logLevels, | ||
mockDevServerPlugin, | ||
@@ -1685,0 +1696,0 @@ mockWebSocket, |
{ | ||
"name": "vite-plugin-mock-dev-server", | ||
"type": "module", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"packageManager": "pnpm@8.11.0", | ||
@@ -52,3 +52,3 @@ "author": "pengzhanbo <q942450674@outlook.com> (https://github.com/pengzhanbo)", | ||
"debug": "^4.3.4", | ||
"esbuild": "^0.19.8", | ||
"esbuild": "^0.19.9", | ||
"fast-glob": "^3.3.2", | ||
@@ -62,6 +62,6 @@ "formidable": "2.1.1", | ||
"picocolors": "^1.0.0", | ||
"ws": "^8.14.2" | ||
"ws": "^8.15.1" | ||
}, | ||
"devDependencies": { | ||
"@pengzhanbo/eslint-config": "^1.2.5", | ||
"@pengzhanbo/eslint-config": "^1.3.1", | ||
"@types/co-body": "^6.1.3", | ||
@@ -74,5 +74,5 @@ "@types/cookies": "^0.7.10", | ||
"@types/mime-types": "^2.1.4", | ||
"@types/node": "^20.10.2", | ||
"@types/node": "^20.10.3", | ||
"@types/ws": "^8.5.10", | ||
"bumpp": "^9.2.0", | ||
"bumpp": "^9.2.1", | ||
"conventional-changelog-cli": "^4.1.0", | ||
@@ -82,9 +82,9 @@ "eslint": "^8.55.0", | ||
"tsup": "^8.0.1", | ||
"typescript": "^5.3.2", | ||
"vite": "^5.0.4", | ||
"typescript": "^5.3.3", | ||
"vite": "^5.0.8", | ||
"vitepress": "^1.0.0-rc.31", | ||
"vitest": "^0.34.6" | ||
"vitest": "^1.0.4" | ||
}, | ||
"scripts": { | ||
"build": "tsup", | ||
"build": "tsup && node ./deprecate.mjs", | ||
"dev": "DEBUG=vite:mock-dev-server vite example --config ./example/vite.config.ts", | ||
@@ -91,0 +91,0 @@ "example:build": "DEBUG=vite:mock-dev-server vite build example --config ./example/vite.config.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
215943
4045
2
8
Updatedesbuild@^0.19.9
Updatedws@^8.15.1