vite-node 0.26.3 → 0.27.1

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/server.cjs CHANGED
@@ -8,21 +8,49 @@ var createDebug = require('debug');
8
8
  var fs = require('fs');
9
9
  var mlly = require('mlly');
10
10
  var utils = require('./utils.cjs');
11
- var picocolors = require('./chunk-picocolors.cjs');
11
+ var c = require('picocolors');
12
12
  var sourceMap = require('./source-map.cjs');
13
13
  require('node:url');
14
- require('tty');
15
14
  require('source-map-support');
16
15
 
17
16
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
17
 
19
18
  var createDebug__default = /*#__PURE__*/_interopDefaultLegacy(createDebug);
19
+ var c__default = /*#__PURE__*/_interopDefaultLegacy(c);
20
20
 
21
+ const KNOWN_ASSET_TYPES = [
22
+ "png",
23
+ "jpe?g",
24
+ "jfif",
25
+ "pjpeg",
26
+ "pjp",
27
+ "gif",
28
+ "svg",
29
+ "ico",
30
+ "webp",
31
+ "avif",
32
+ "mp4",
33
+ "webm",
34
+ "ogg",
35
+ "mp3",
36
+ "wav",
37
+ "flac",
38
+ "aac",
39
+ "woff2?",
40
+ "eot",
41
+ "ttf",
42
+ "otf",
43
+ "webmanifest",
44
+ "pdf",
45
+ "txt"
46
+ ];
21
47
  const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
22
48
  const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
23
49
  const defaultInline = [
24
50
  /virtual:/,
25
- /\.[mc]?ts$/
51
+ /\.[mc]?ts$/,
52
+ /[?&](init|raw|url|inline)\b/,
53
+ new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`)
26
54
  ];
27
55
  const depsExternal = [
28
56
  /\.cjs\.js$/,
@@ -119,9 +147,9 @@ class Debugger {
119
147
  this.dumpDir = pathe.resolve(root, options.dumpModules === true ? ".vite-node/dump" : options.dumpModules);
120
148
  if (this.dumpDir) {
121
149
  if (options.loadDumppedModules)
122
- console.info(picocolors.picocolors.exports.gray(`[vite-node] [debug] load modules from ${this.dumpDir}`));
150
+ console.info(c__default["default"].gray(`[vite-node] [debug] load modules from ${this.dumpDir}`));
123
151
  else
124
- console.info(picocolors.picocolors.exports.gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`));
152
+ console.info(c__default["default"].gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`));
125
153
  }
126
154
  this.initPromise = this.clearDump();
127
155
  }
package/dist/server.mjs CHANGED
@@ -4,17 +4,44 @@ import createDebug from 'debug';
4
4
  import { existsSync, promises } from 'node:fs';
5
5
  import { isNodeBuiltin, isValidNodeImport } from 'mlly';
6
6
  import { slash, toArray, normalizeModuleId, toFilePath } from './utils.mjs';
7
- import { p as picocolors } from './chunk-picocolors.mjs';
7
+ import c from 'picocolors';
8
8
  import { withInlineSourcemap } from './source-map.mjs';
9
9
  import 'node:url';
10
- import 'tty';
11
10
  import 'source-map-support';
12
11
 
12
+ const KNOWN_ASSET_TYPES = [
13
+ "png",
14
+ "jpe?g",
15
+ "jfif",
16
+ "pjpeg",
17
+ "pjp",
18
+ "gif",
19
+ "svg",
20
+ "ico",
21
+ "webp",
22
+ "avif",
23
+ "mp4",
24
+ "webm",
25
+ "ogg",
26
+ "mp3",
27
+ "wav",
28
+ "flac",
29
+ "aac",
30
+ "woff2?",
31
+ "eot",
32
+ "ttf",
33
+ "otf",
34
+ "webmanifest",
35
+ "pdf",
36
+ "txt"
37
+ ];
13
38
  const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
14
39
  const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
15
40
  const defaultInline = [
16
41
  /virtual:/,
17
- /\.[mc]?ts$/
42
+ /\.[mc]?ts$/,
43
+ /[?&](init|raw|url|inline)\b/,
44
+ new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`)
18
45
  ];
19
46
  const depsExternal = [
20
47
  /\.cjs\.js$/,
@@ -111,9 +138,9 @@ class Debugger {
111
138
  this.dumpDir = resolve(root, options.dumpModules === true ? ".vite-node/dump" : options.dumpModules);
112
139
  if (this.dumpDir) {
113
140
  if (options.loadDumppedModules)
114
- console.info(picocolors.exports.gray(`[vite-node] [debug] load modules from ${this.dumpDir}`));
141
+ console.info(c.gray(`[vite-node] [debug] load modules from ${this.dumpDir}`));
115
142
  else
116
- console.info(picocolors.exports.gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`));
143
+ console.info(c.gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`));
117
144
  }
118
145
  this.initPromise = this.clearDump();
119
146
  }
package/dist/utils.cjs CHANGED
@@ -10,9 +10,6 @@ const isWindows = process.platform === "win32";
10
10
  function slash(str) {
11
11
  return str.replace(/\\/g, "/");
12
12
  }
13
- function mergeSlashes(str) {
14
- return str.replace(/\/\//g, "/");
15
- }
16
13
  const VALID_ID_PREFIX = "/@id/";
17
14
  function normalizeRequestId(id, base) {
18
15
  if (base && id.startsWith(base))
@@ -65,7 +62,6 @@ exports.hashRE = hashRE;
65
62
  exports.isInternalRequest = isInternalRequest;
66
63
  exports.isPrimitive = isPrimitive;
67
64
  exports.isWindows = isWindows;
68
- exports.mergeSlashes = mergeSlashes;
69
65
  exports.normalizeModuleId = normalizeModuleId;
70
66
  exports.normalizeRequestId = normalizeRequestId;
71
67
  exports.queryRE = queryRE;
package/dist/utils.d.ts CHANGED
@@ -2,7 +2,6 @@ import { N as Nullable, A as Arrayable } from './types-63205a44.js';
2
2
 
3
3
  declare const isWindows: boolean;
4
4
  declare function slash(str: string): string;
5
- declare function mergeSlashes(str: string): string;
6
5
  declare const VALID_ID_PREFIX = "/@id/";
7
6
  declare function normalizeRequestId(id: string, base?: string): string;
8
7
  declare const queryRE: RegExp;
@@ -19,4 +18,4 @@ declare function toFilePath(id: string, root: string): string;
19
18
  */
20
19
  declare function toArray<T>(array?: Nullable<Arrayable<T>>): Array<T>;
21
20
 
22
- export { VALID_ID_PREFIX, cleanUrl, hashRE, isInternalRequest, isPrimitive, isWindows, mergeSlashes, normalizeModuleId, normalizeRequestId, queryRE, slash, toArray, toFilePath };
21
+ export { VALID_ID_PREFIX, cleanUrl, hashRE, isInternalRequest, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, slash, toArray, toFilePath };
package/dist/utils.mjs CHANGED
@@ -6,9 +6,6 @@ const isWindows = process.platform === "win32";
6
6
  function slash(str) {
7
7
  return str.replace(/\\/g, "/");
8
8
  }
9
- function mergeSlashes(str) {
10
- return str.replace(/\/\//g, "/");
11
- }
12
9
  const VALID_ID_PREFIX = "/@id/";
13
10
  function normalizeRequestId(id, base) {
14
11
  if (base && id.startsWith(base))
@@ -55,4 +52,4 @@ function toArray(array) {
55
52
  return [array];
56
53
  }
57
54
 
58
- export { VALID_ID_PREFIX, cleanUrl, hashRE, isInternalRequest, isPrimitive, isWindows, mergeSlashes, normalizeModuleId, normalizeRequestId, queryRE, slash, toArray, toFilePath };
55
+ export { VALID_ID_PREFIX, cleanUrl, hashRE, isInternalRequest, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, slash, toArray, toFilePath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-node",
3
- "version": "0.26.3",
3
+ "version": "0.27.1",
4
4
  "description": "Vite as Node.js runtime",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -14,6 +14,7 @@
14
14
  "bugs": {
15
15
  "url": "https://github.com/vitest-dev/vitest/issues"
16
16
  },
17
+ "sideEffects": false,
17
18
  "exports": {
18
19
  ".": {
19
20
  "types": "./dist/index.d.ts",
@@ -69,9 +70,11 @@
69
70
  "node": ">=v14.16.0"
70
71
  },
71
72
  "dependencies": {
73
+ "cac": "^6.7.14",
72
74
  "debug": "^4.3.4",
73
- "mlly": "^1.0.0",
75
+ "mlly": "^1.1.0",
74
76
  "pathe": "^0.2.0",
77
+ "picocolors": "^1.0.0",
75
78
  "source-map": "^0.6.1",
76
79
  "source-map-support": "^0.5.21",
77
80
  "vite": "^3.0.0 || ^4.0.0"
@@ -80,8 +83,6 @@
80
83
  "@types/debug": "^4.1.7",
81
84
  "@types/source-map": "^0.5.7",
82
85
  "@types/source-map-support": "^0.5.6",
83
- "cac": "^6.7.14",
84
- "picocolors": "^1.0.0",
85
86
  "rollup": "^2.79.1"
86
87
  },
87
88
  "scripts": {
@@ -1,70 +0,0 @@
1
- 'use strict';
2
-
3
- var require$$0 = require('tty');
4
-
5
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
6
-
7
- var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
8
-
9
- var picocolors = {exports: {}};
10
-
11
- let tty = require$$0__default["default"];
12
-
13
- let isColorSupported =
14
- !("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
15
- ("FORCE_COLOR" in process.env ||
16
- process.argv.includes("--color") ||
17
- process.platform === "win32" ||
18
- (tty.isatty(1) && process.env.TERM !== "dumb") ||
19
- "CI" in process.env);
20
-
21
- let formatter =
22
- (open, close, replace = open) =>
23
- input => {
24
- let string = "" + input;
25
- let index = string.indexOf(close, open.length);
26
- return ~index
27
- ? open + replaceClose(string, close, replace, index) + close
28
- : open + string + close
29
- };
30
-
31
- let replaceClose = (string, close, replace, index) => {
32
- let start = string.substring(0, index) + replace;
33
- let end = string.substring(index + close.length);
34
- let nextIndex = end.indexOf(close);
35
- return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
36
- };
37
-
38
- let createColors = (enabled = isColorSupported) => ({
39
- isColorSupported: enabled,
40
- reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
41
- bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
42
- dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
43
- italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
44
- underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
45
- inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
46
- hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
47
- strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
48
- black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
49
- red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
50
- green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
51
- yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
52
- blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
53
- magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
54
- cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
55
- white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
56
- gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
57
- bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
58
- bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
59
- bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
60
- bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
61
- bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
62
- bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
63
- bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
64
- bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
65
- });
66
-
67
- picocolors.exports = createColors();
68
- picocolors.exports.createColors = createColors;
69
-
70
- exports.picocolors = picocolors;
@@ -1,64 +0,0 @@
1
- import require$$0 from 'tty';
2
-
3
- var picocolors = {exports: {}};
4
-
5
- let tty = require$$0;
6
-
7
- let isColorSupported =
8
- !("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
9
- ("FORCE_COLOR" in process.env ||
10
- process.argv.includes("--color") ||
11
- process.platform === "win32" ||
12
- (tty.isatty(1) && process.env.TERM !== "dumb") ||
13
- "CI" in process.env);
14
-
15
- let formatter =
16
- (open, close, replace = open) =>
17
- input => {
18
- let string = "" + input;
19
- let index = string.indexOf(close, open.length);
20
- return ~index
21
- ? open + replaceClose(string, close, replace, index) + close
22
- : open + string + close
23
- };
24
-
25
- let replaceClose = (string, close, replace, index) => {
26
- let start = string.substring(0, index) + replace;
27
- let end = string.substring(index + close.length);
28
- let nextIndex = end.indexOf(close);
29
- return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
30
- };
31
-
32
- let createColors = (enabled = isColorSupported) => ({
33
- isColorSupported: enabled,
34
- reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
35
- bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
36
- dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
37
- italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
38
- underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
39
- inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
40
- hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
41
- strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
42
- black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
43
- red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
44
- green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
45
- yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
46
- blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
47
- magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
48
- cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
49
- white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
50
- gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
51
- bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
52
- bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
53
- bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
54
- bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
55
- bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
56
- bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
57
- bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
58
- bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
59
- });
60
-
61
- picocolors.exports = createColors();
62
- picocolors.exports.createColors = createColors;
63
-
64
- export { picocolors as p };