vite-node 0.12.7 → 0.12.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -3,13 +3,13 @@
3
3
  var events = require('events');
4
4
  var kolorist = require('kolorist');
5
5
  var vite = require('vite');
6
- var server = require('./server-c98deede.js');
7
- var client = require('./client-d42a1094.js');
6
+ var server = require('./server-f6511dc4.js');
7
+ var client = require('./client-f221b9b5.js');
8
8
  require('pathe');
9
9
  require('debug');
10
10
  require('fs');
11
11
  require('mlly');
12
- require('./utils-5d86aff6.js');
12
+ require('./utils-c2e3d5fd.js');
13
13
  require('url');
14
14
  require('module');
15
15
  require('vm');
@@ -627,7 +627,7 @@ class CAC extends events.EventEmitter {
627
627
 
628
628
  const cac = (name = "") => new CAC(name);
629
629
 
630
- var version = "0.12.7";
630
+ var version = "0.12.10";
631
631
 
632
632
  const cli = cac("vite-node");
633
633
  cli.version(version).option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').help();
package/dist/cli.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import { red, cyan, dim } from 'kolorist';
3
3
  import { createServer } from 'vite';
4
- import { V as ViteNodeServer } from './server-e4d25388.js';
5
- import { V as ViteNodeRunner } from './client-aa28334b.js';
4
+ import { V as ViteNodeServer } from './server-013a4491.js';
5
+ import { V as ViteNodeRunner } from './client-3270fd45.js';
6
6
  import 'pathe';
7
7
  import 'debug';
8
8
  import 'fs';
9
9
  import 'mlly';
10
- import './utils-0290448b.js';
10
+ import './utils-b4f03380.js';
11
11
  import 'url';
12
12
  import 'module';
13
13
  import 'vm';
@@ -625,7 +625,7 @@ class CAC extends EventEmitter {
625
625
 
626
626
  const cac = (name = "") => new CAC(name);
627
627
 
628
- var version = "0.12.7";
628
+ var version = "0.12.10";
629
629
 
630
630
  const cli = cac("vite-node");
631
631
  cli.version(version).option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').help();
@@ -4,7 +4,7 @@ import vm from 'vm';
4
4
  import { resolve, dirname, isAbsolute, extname } from 'pathe';
5
5
  import { isNodeBuiltin } from 'mlly';
6
6
  import createDebug from 'debug';
7
- import { n as normalizeModuleId, s as slash, a as normalizeRequestId, t as toFilePath, i as isPrimitive } from './utils-0290448b.js';
7
+ import { n as normalizeModuleId, s as slash, a as normalizeRequestId, t as toFilePath, i as isPrimitive, m as mergeSlashes } from './utils-b4f03380.js';
8
8
 
9
9
  const debugExecute = createDebug("vite-node:client:execute");
10
10
  const debugNative = createDebug("vite-node:client:native");
@@ -109,7 +109,7 @@ ${getStack()}`), 2e3);
109
109
  if (importer && importer.startsWith("mock:"))
110
110
  importer = importer.slice(5);
111
111
  const { id: id2 } = await this.options.resolveId(dep, importer) || {};
112
- dep = id2 && isAbsolute(id2) ? `/@fs/${id2}` : id2 || dep;
112
+ dep = id2 && isAbsolute(id2) ? mergeSlashes(`/@fs/${id2}`) : id2 || dep;
113
113
  }
114
114
  return dep;
115
115
  };
@@ -6,7 +6,7 @@ var vm = require('vm');
6
6
  var pathe = require('pathe');
7
7
  var mlly = require('mlly');
8
8
  var createDebug = require('debug');
9
- var utils = require('./utils-5d86aff6.js');
9
+ var utils = require('./utils-c2e3d5fd.js');
10
10
 
11
11
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
12
 
@@ -134,7 +134,7 @@ ${getStack()}`), 2e3);
134
134
  if (importer && importer.startsWith("mock:"))
135
135
  importer = importer.slice(5);
136
136
  const { id: id2 } = await this.options.resolveId(dep, importer) || {};
137
- dep = id2 && pathe.isAbsolute(id2) ? `/@fs/${id2}` : id2 || dep;
137
+ dep = id2 && pathe.isAbsolute(id2) ? utils.mergeSlashes(`/@fs/${id2}`) : id2 || dep;
138
138
  }
139
139
  return dep;
140
140
  };
package/dist/client.cjs CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var client = require('./client-d42a1094.js');
5
+ var client = require('./client-f221b9b5.js');
6
6
  require('module');
7
7
  require('url');
8
8
  require('vm');
9
9
  require('pathe');
10
10
  require('mlly');
11
11
  require('debug');
12
- require('./utils-5d86aff6.js');
12
+ require('./utils-c2e3d5fd.js');
13
13
 
14
14
 
15
15
 
package/dist/client.js CHANGED
@@ -1,8 +1,8 @@
1
- export { D as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, V as ViteNodeRunner } from './client-aa28334b.js';
1
+ export { D as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, V as ViteNodeRunner } from './client-3270fd45.js';
2
2
  import 'module';
3
3
  import 'url';
4
4
  import 'vm';
5
5
  import 'pathe';
6
6
  import 'mlly';
7
7
  import 'debug';
8
- import './utils-0290448b.js';
8
+ import './utils-b4f03380.js';
@@ -2,7 +2,7 @@ import { join } from 'pathe';
2
2
  import createDebug from 'debug';
3
3
  import { existsSync } from 'fs';
4
4
  import { isNodeBuiltin, isValidNodeImport } from 'mlly';
5
- import { s as slash, t as toFilePath, w as withInlineSourcemap } from './utils-0290448b.js';
5
+ import { s as slash, t as toFilePath, w as withInlineSourcemap } from './utils-b4f03380.js';
6
6
 
7
7
  const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
8
8
  const ESM_FOLDER_RE = /\/esm\/(.*\.js)$/;
@@ -4,7 +4,7 @@ var pathe = require('pathe');
4
4
  var createDebug = require('debug');
5
5
  var fs = require('fs');
6
6
  var mlly = require('mlly');
7
- var utils = require('./utils-5d86aff6.js');
7
+ var utils = require('./utils-c2e3d5fd.js');
8
8
 
9
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
10
 
package/dist/server.cjs CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var server = require('./server-c98deede.js');
5
+ var server = require('./server-f6511dc4.js');
6
6
  require('pathe');
7
7
  require('debug');
8
8
  require('fs');
9
9
  require('mlly');
10
- require('./utils-5d86aff6.js');
10
+ require('./utils-c2e3d5fd.js');
11
11
  require('url');
12
12
 
13
13
 
package/dist/server.js CHANGED
@@ -1,7 +1,7 @@
1
- export { V as ViteNodeServer, g as guessCJSversion, s as shouldExternalize } from './server-e4d25388.js';
1
+ export { V as ViteNodeServer, g as guessCJSversion, s as shouldExternalize } from './server-013a4491.js';
2
2
  import 'pathe';
3
3
  import 'debug';
4
4
  import 'fs';
5
5
  import 'mlly';
6
- import './utils-0290448b.js';
6
+ import './utils-b4f03380.js';
7
7
  import 'url';
@@ -5,6 +5,9 @@ const isWindows = process.platform === "win32";
5
5
  function slash(str) {
6
6
  return str.replace(/\\/g, "/");
7
7
  }
8
+ function mergeSlashes(str) {
9
+ return str.replace(/\/\//g, "/");
10
+ }
8
11
  function normalizeRequestId(id, base) {
9
12
  if (base && id.startsWith(base))
10
13
  id = `/${id.slice(base.length)}`;
@@ -36,4 +39,4 @@ async function withInlineSourcemap(result) {
36
39
  return result;
37
40
  }
38
41
 
39
- export { normalizeRequestId as a, isWindows as b, isPrimitive as i, normalizeModuleId as n, slash as s, toFilePath as t, withInlineSourcemap as w };
42
+ export { normalizeRequestId as a, isWindows as b, isPrimitive as i, mergeSlashes as m, normalizeModuleId as n, slash as s, toFilePath as t, withInlineSourcemap as w };
@@ -7,6 +7,9 @@ const isWindows = process.platform === "win32";
7
7
  function slash(str) {
8
8
  return str.replace(/\\/g, "/");
9
9
  }
10
+ function mergeSlashes(str) {
11
+ return str.replace(/\/\//g, "/");
12
+ }
10
13
  function normalizeRequestId(id, base) {
11
14
  if (base && id.startsWith(base))
12
15
  id = `/${id.slice(base.length)}`;
@@ -40,6 +43,7 @@ async function withInlineSourcemap(result) {
40
43
 
41
44
  exports.isPrimitive = isPrimitive;
42
45
  exports.isWindows = isWindows;
46
+ exports.mergeSlashes = mergeSlashes;
43
47
  exports.normalizeModuleId = normalizeModuleId;
44
48
  exports.normalizeRequestId = normalizeRequestId;
45
49
  exports.slash = slash;
package/dist/utils.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var utils = require('./utils-5d86aff6.js');
5
+ var utils = require('./utils-c2e3d5fd.js');
6
6
  require('url');
7
7
  require('pathe');
8
8
 
@@ -10,6 +10,7 @@ require('pathe');
10
10
 
11
11
  exports.isPrimitive = utils.isPrimitive;
12
12
  exports.isWindows = utils.isWindows;
13
+ exports.mergeSlashes = utils.mergeSlashes;
13
14
  exports.normalizeModuleId = utils.normalizeModuleId;
14
15
  exports.normalizeRequestId = utils.normalizeRequestId;
15
16
  exports.slash = utils.slash;
package/dist/utils.d.ts CHANGED
@@ -2,10 +2,11 @@ import { TransformResult } from 'vite';
2
2
 
3
3
  declare const isWindows: boolean;
4
4
  declare function slash(str: string): string;
5
+ declare function mergeSlashes(str: string): string;
5
6
  declare function normalizeRequestId(id: string, base?: string): string;
6
7
  declare function normalizeModuleId(id: string): string;
7
8
  declare function isPrimitive(v: any): boolean;
8
9
  declare function toFilePath(id: string, root: string): string;
9
10
  declare function withInlineSourcemap(result: TransformResult): Promise<TransformResult>;
10
11
 
11
- export { isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, slash, toFilePath, withInlineSourcemap };
12
+ export { isPrimitive, isWindows, mergeSlashes, normalizeModuleId, normalizeRequestId, slash, toFilePath, withInlineSourcemap };
package/dist/utils.js CHANGED
@@ -1,3 +1,3 @@
1
- export { i as isPrimitive, b as isWindows, n as normalizeModuleId, a as normalizeRequestId, s as slash, t as toFilePath, w as withInlineSourcemap } from './utils-0290448b.js';
1
+ export { i as isPrimitive, b as isWindows, m as mergeSlashes, n as normalizeModuleId, a as normalizeRequestId, s as slash, t as toFilePath, w as withInlineSourcemap } from './utils-b4f03380.js';
2
2
  import 'url';
3
3
  import 'pathe';
package/package.json CHANGED
@@ -1,53 +1,45 @@
1
1
  {
2
2
  "name": "vite-node",
3
3
  "type": "module",
4
- "version": "0.12.7",
4
+ "version": "0.12.10",
5
5
  "description": "Vite as Node.js runtime",
6
- "homepage": "https://github.com/vitest-dev/vitest/blob/main/packages/vite-node#readme",
7
- "bugs": {
8
- "url": "https://github.com/vitest-dev/vitest/issues"
9
- },
10
- "license": "MIT",
11
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
+ "license": "MIT",
8
+ "funding": "https://github.com/sponsors/antfu",
9
+ "homepage": "https://github.com/vitest-dev/vitest/blob/main/packages/vite-node#readme",
12
10
  "repository": {
13
11
  "type": "git",
14
12
  "url": "git+https://github.com/vitest-dev/vitest.git",
15
13
  "directory": "packages/vite-node"
16
14
  },
17
- "funding": "https://github.com/sponsors/antfu",
18
- "main": "./dist/index.js",
19
- "module": "./dist/index.js",
20
- "types": "./dist/index.d.ts",
15
+ "bugs": {
16
+ "url": "https://github.com/vitest-dev/vitest/issues"
17
+ },
21
18
  "exports": {
22
19
  ".": {
20
+ "types": "./dist/index.d.ts",
23
21
  "import": "./dist/index.js",
24
- "require": "./dist/index.cjs",
25
- "types": "./dist/index.d.ts"
22
+ "require": "./dist/index.cjs"
26
23
  },
27
24
  "./client": {
25
+ "types": "./dist/client.d.ts",
28
26
  "import": "./dist/client.js",
29
- "require": "./dist/client.cjs",
30
- "types": "./dist/client.d.ts"
27
+ "require": "./dist/client.cjs"
31
28
  },
32
29
  "./server": {
30
+ "types": "./dist/server.d.ts",
33
31
  "import": "./dist/server.js",
34
- "require": "./dist/server.cjs",
35
- "types": "./dist/server.d.ts"
32
+ "require": "./dist/server.cjs"
36
33
  },
37
34
  "./utils": {
35
+ "types": "./dist/utils.d.ts",
38
36
  "import": "./dist/utils.js",
39
- "require": "./dist/utils.cjs",
40
- "types": "./dist/utils.d.ts"
37
+ "require": "./dist/utils.cjs"
41
38
  }
42
39
  },
43
- "files": [
44
- "dist",
45
- "*.d.ts",
46
- "*.mjs"
47
- ],
48
- "bin": {
49
- "vite-node": "./vite-node.mjs"
50
- },
40
+ "main": "./dist/index.js",
41
+ "module": "./dist/index.js",
42
+ "types": "./dist/index.d.ts",
51
43
  "typesVersions": {
52
44
  "*": {
53
45
  "*": [
@@ -56,20 +48,28 @@
56
48
  ]
57
49
  }
58
50
  },
51
+ "bin": {
52
+ "vite-node": "./vite-node.mjs"
53
+ },
54
+ "files": [
55
+ "dist",
56
+ "*.d.ts",
57
+ "*.mjs"
58
+ ],
59
+ "engines": {
60
+ "node": ">=v14.16.0"
61
+ },
59
62
  "dependencies": {
60
63
  "debug": "^4.3.4",
61
64
  "kolorist": "^1.5.1",
62
65
  "mlly": "^0.5.2",
63
66
  "pathe": "^0.2.0",
64
- "vite": "^2.9.8"
67
+ "vite": "^2.9.9"
65
68
  },
66
69
  "devDependencies": {
67
70
  "@types/debug": "^4.1.7",
68
71
  "cac": "^6.7.12",
69
- "rollup": "^2.73.0"
70
- },
71
- "engines": {
72
- "node": ">=v14.16.0"
72
+ "rollup": "^2.74.1"
73
73
  },
74
74
  "scripts": {
75
75
  "build": "rimraf dist && rollup -c",
package/cli.d.ts DELETED
@@ -1,8 +0,0 @@
1
- interface CliOptions {
2
- files?: string[];
3
- _?: string[];
4
- root?: string;
5
- config?: string;
6
- }
7
-
8
- export { CliOptions };
package/client.d.ts DELETED
@@ -1,37 +0,0 @@
1
- import { ViteNodeRunnerOptions, ModuleCache } from './types.js';
2
-
3
- declare const DEFAULT_REQUEST_STUBS: {
4
- '/@vite/client': {
5
- injectQuery: (id: string) => string;
6
- createHotContext(): {
7
- accept: () => void;
8
- prune: () => void;
9
- };
10
- updateStyle(): void;
11
- };
12
- };
13
- declare class ViteNodeRunner {
14
- options: ViteNodeRunnerOptions;
15
- root: string;
16
- moduleCache: Map<string, ModuleCache>;
17
- constructor(options: ViteNodeRunnerOptions);
18
- executeFile(file: string): Promise<any>;
19
- executeId(id: string): Promise<any>;
20
- cachedRequest(rawId: string, callstack: string[]): Promise<any>;
21
- directRequest(id: string, fsPath: string, callstack: string[]): Promise<any>;
22
- prepareContext(context: Record<string, any>): Record<string, any>;
23
- setCache(id: string, mod: Partial<ModuleCache>): void;
24
- shouldResolveId(dep: string): boolean;
25
- /**
26
- * Define if a module should be interop-ed
27
- * This function mostly for the ability to override by subclass
28
- */
29
- shouldInterop(path: string, mod: any): boolean;
30
- /**
31
- * Import a module and interop it
32
- */
33
- interopedImport(path: string): Promise<any>;
34
- hasNestedDefault(target: any): any;
35
- }
36
-
37
- export { DEFAULT_REQUEST_STUBS, ViteNodeRunner };
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export { DepsHandlingOptions, FetchFunction, FetchResult, ModuleCache, RawSourceMap, ResolveIdFunction, StartOfSourceMap, ViteNodeResolveId, ViteNodeRunnerOptions, ViteNodeServerOptions } from './types.js';
package/server.d.ts DELETED
@@ -1,26 +0,0 @@
1
- import { ViteDevServer, TransformResult } from 'vite';
2
- import { DepsHandlingOptions, ViteNodeServerOptions, FetchResult, ViteNodeResolveId } from './types.js';
3
-
4
- declare function guessCJSversion(id: string): string | undefined;
5
- declare function shouldExternalize(id: string, options?: DepsHandlingOptions, cache?: Map<string, Promise<string | false>>): Promise<string | false>;
6
-
7
- declare class ViteNodeServer {
8
- server: ViteDevServer;
9
- options: ViteNodeServerOptions;
10
- private fetchPromiseMap;
11
- private transformPromiseMap;
12
- fetchCache: Map<string, {
13
- timestamp: number;
14
- result: FetchResult;
15
- }>;
16
- constructor(server: ViteDevServer, options?: ViteNodeServerOptions);
17
- shouldExternalize(id: string): Promise<string | false>;
18
- resolveId(id: string, importer?: string): Promise<ViteNodeResolveId | null>;
19
- fetchModule(id: string): Promise<FetchResult>;
20
- transformRequest(id: string): Promise<TransformResult | null | undefined>;
21
- getTransformMode(id: string): "web" | "ssr";
22
- private _fetchModule;
23
- private _transformRequest;
24
- }
25
-
26
- export { ViteNodeServer, guessCJSversion, shouldExternalize };
package/types.d.ts DELETED
@@ -1,68 +0,0 @@
1
- interface DepsHandlingOptions {
2
- external?: (string | RegExp)[];
3
- inline?: (string | RegExp)[];
4
- /**
5
- * Try to guess the CJS version of a package when it's invalid ESM
6
- * @default true
7
- */
8
- fallbackCJS?: boolean;
9
- }
10
- interface StartOfSourceMap {
11
- file?: string;
12
- sourceRoot?: string;
13
- }
14
- interface RawSourceMap extends StartOfSourceMap {
15
- version: string;
16
- sources: string[];
17
- names: string[];
18
- sourcesContent?: string[];
19
- mappings: string;
20
- }
21
- interface FetchResult {
22
- code?: string;
23
- externalize?: string;
24
- map?: RawSourceMap;
25
- }
26
- declare type FetchFunction = (id: string) => Promise<FetchResult>;
27
- declare type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
28
- interface ModuleCache {
29
- promise?: Promise<any>;
30
- exports?: any;
31
- code?: string;
32
- }
33
- interface ViteNodeRunnerOptions {
34
- fetchModule: FetchFunction;
35
- resolveId: ResolveIdFunction;
36
- root: string;
37
- base?: string;
38
- moduleCache?: Map<string, ModuleCache>;
39
- interopDefault?: boolean;
40
- requestStubs?: Record<string, any>;
41
- }
42
- interface ViteNodeResolveId {
43
- external?: boolean | 'absolute' | 'relative';
44
- id: string;
45
- meta?: Record<string, any> | null;
46
- moduleSideEffects?: boolean | 'no-treeshake' | null;
47
- syntheticNamedExports?: boolean | string | null;
48
- }
49
- interface ViteNodeServerOptions {
50
- /**
51
- * Inject inline sourcemap to modules
52
- * @default 'inline'
53
- */
54
- sourcemap?: 'inline' | boolean;
55
- /**
56
- * Deps handling
57
- */
58
- deps?: DepsHandlingOptions;
59
- /**
60
- * Transform method for modules
61
- */
62
- transformMode?: {
63
- ssr?: RegExp[];
64
- web?: RegExp[];
65
- };
66
- }
67
-
68
- export { DepsHandlingOptions, FetchFunction, FetchResult, ModuleCache, RawSourceMap, ResolveIdFunction, StartOfSourceMap, ViteNodeResolveId, ViteNodeRunnerOptions, ViteNodeServerOptions };
package/utils.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import { TransformResult } from 'vite';
2
-
3
- declare const isWindows: boolean;
4
- declare function slash(str: string): string;
5
- declare function normalizeId(id: string, base?: string): string;
6
- declare function isPrimitive(v: any): boolean;
7
- declare function toFilePath(id: string, root: string): string;
8
- declare function withInlineSourcemap(result: TransformResult): Promise<TransformResult>;
9
-
10
- export { isPrimitive, isWindows, normalizeId, slash, toFilePath, withInlineSourcemap };