Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-mock-server

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-mock-server - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

39

dist/index.js

@@ -1,15 +0,10 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ant_path_matcher_1 = __importDefault(require("@howiefh/ant-path-matcher"));
const chokidar_1 = __importDefault(require("chokidar"));
const path_1 = __importDefault(require("path"));
const fs_1 = __importDefault(require("fs"));
const esbuild_1 = require("esbuild");
import AntPathMatcher from '@howiefh/ant-path-matcher';
import chokidar from 'chokidar';
import path from 'path';
import fs from 'fs';
import { build } from 'esbuild';
const PLUGIN_NAME = 'vite-plugin-mock-server';
const TEMPORARY_FILE_SUFFIX = '.tmp.js';
let LOG_LEVEL = 'error';
exports.default = (options) => {
export default (options) => {
return {

@@ -19,3 +14,3 @@ name: PLUGIN_NAME,

// build url matcher
const matcher = new ant_path_matcher_1.default();
const matcher = new AntPathMatcher();
// init options

@@ -98,6 +93,6 @@ options = options || {};

const watchMockFiles = async (options) => {
const watchDir = path_1.default.resolve(process.cwd(), options.mockRootDir);
const watchDir = path.resolve(process.cwd(), options.mockRootDir);
logInfo('watched root dir is', watchDir);
await loadMockModules(options, watchDir);
chokidar_1.default.watch(watchDir, {
chokidar.watch(watchDir, {
ignoreInitial: true,

@@ -131,5 +126,5 @@ }).on('all', async (event, path) => {

logInfo('recursive loading mock modules', watchDir);
for (const [, name] of fs_1.default.readdirSync(watchDir).entries()) {
const modName = path_1.default.join(watchDir, name);
const stat = fs_1.default.statSync(modName);
for (const [, name] of fs.readdirSync(watchDir).entries()) {
const modName = path.join(watchDir, name);
const stat = fs.statSync(modName);
if (stat.isDirectory()) {

@@ -157,3 +152,3 @@ loadMockModules(options, modName);

return;
if (!fs_1.default.statSync(moduleName).isFile())
if (!fs.statSync(moduleName).isFile())
return;

@@ -178,6 +173,6 @@ }

return;
if (!fs_1.default.statSync(moduleName).isFile())
if (!fs.statSync(moduleName).isFile())
return;
logInfo('loading ts mock module', moduleName);
const result = await esbuild_1.build({
const result = await build({
entryPoints: [moduleName],

@@ -194,5 +189,5 @@ outfile: 'out.js',

const modName = moduleName + TEMPORARY_FILE_SUFFIX;
fs_1.default.writeFileSync(modName, text);
fs.writeFileSync(modName, text);
await loadJsMockModule(options, modName, true);
fs_1.default.unlink(modName, (err) => {
fs.unlink(modName, (err) => {
if (err)

@@ -199,0 +194,0 @@ logErr('delete file ' + modName + ' error', err);

{
"name": "vite-plugin-mock-server",
"version": "1.1.0",
"version": "1.1.1",
"description": "Vite mock server plugin",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -42,3 +42,3 @@ # vite-plugin-mock-server

import cookieParser from 'cookie-parser'
import mockServer from '../src'
import mockServer from 'vite-plugin-mock-server'

@@ -45,0 +45,0 @@ export default defineConfig({

{
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"module": "esnext",
"moduleResolution": "node",

@@ -6,0 +6,0 @@ "strict": true,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc