vite-node 2.1.0 → 2.1.2

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
@@ -7,8 +7,8 @@ var vite = require('vite');
7
7
  var server = require('./server.cjs');
8
8
  var client = require('./client.cjs');
9
9
  var utils = require('./utils.cjs');
10
- var hmr = require('./chunk-hmr.cjs');
11
10
  var sourceMap = require('./source-map.cjs');
11
+ var hmr = require('./chunk-hmr.cjs');
12
12
  require('node:perf_hooks');
13
13
  require('node:fs');
14
14
  require('node:assert');
@@ -20,7 +20,7 @@ require('node:url');
20
20
  require('node:vm');
21
21
  require('node:events');
22
22
 
23
- var version = "2.1.0";
23
+ var version = "2.1.2";
24
24
 
25
25
  const cli = cac("vite-node");
26
26
  cli.option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-m, --mode <mode>", "Set env mode").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').option("--script", "Use vite-node as a script runner").option("--options <options>", "Use specified Vite server options").option("-v, --version", "Output the version number").option("-h, --help", "Display help for command");
package/dist/cli.mjs CHANGED
@@ -18,7 +18,7 @@ import 'node:url';
18
18
  import 'node:vm';
19
19
  import 'node:events';
20
20
 
21
- var version = "2.1.0";
21
+ var version = "2.1.2";
22
22
 
23
23
  const cli = cac("vite-node");
24
24
  cli.option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-m, --mode <mode>", "Set env mode").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').option("--script", "Use vite-node as a script runner").option("--options <options>", "Use specified Vite server options").option("-v, --version", "Output the version number").option("-h, --help", "Display help for command");
package/dist/server.cjs CHANGED
@@ -17,6 +17,7 @@ const BUILTIN_EXTENSIONS = /* @__PURE__ */ new Set([".mjs", ".cjs", ".node", ".w
17
17
  const ESM_SYNTAX_RE = /(?:[\s;]|^)(?:import[\s\w*,{}]*from|import\s*["'*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m;
18
18
  const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
19
19
  const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
20
+ const COMMENT_RE = /\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm;
20
21
  const defaultInline = [
21
22
  /virtual:/,
22
23
  /\.[mc]?ts$/,
@@ -72,7 +73,7 @@ async function isValidNodeImport(id) {
72
73
  return false;
73
74
  }
74
75
  const code = await fs.promises.readFile(id, "utf8").catch(() => "");
75
- return !ESM_SYNTAX_RE.test(code);
76
+ return !ESM_SYNTAX_RE.test(code.replace(COMMENT_RE, ""));
76
77
  }
77
78
  const _defaultExternalizeCache = /* @__PURE__ */ new Map();
78
79
  async function shouldExternalize(id, options, cache = _defaultExternalizeCache) {
package/dist/server.mjs CHANGED
@@ -15,6 +15,7 @@ const BUILTIN_EXTENSIONS = /* @__PURE__ */ new Set([".mjs", ".cjs", ".node", ".w
15
15
  const ESM_SYNTAX_RE = /(?:[\s;]|^)(?:import[\s\w*,{}]*from|import\s*["'*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m;
16
16
  const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
17
17
  const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
18
+ const COMMENT_RE = /\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm;
18
19
  const defaultInline = [
19
20
  /virtual:/,
20
21
  /\.[mc]?ts$/,
@@ -70,7 +71,7 @@ async function isValidNodeImport(id) {
70
71
  return false;
71
72
  }
72
73
  const code = await promises.readFile(id, "utf8").catch(() => "");
73
- return !ESM_SYNTAX_RE.test(code);
74
+ return !ESM_SYNTAX_RE.test(code.replace(COMMENT_RE, ""));
74
75
  }
75
76
  const _defaultExternalizeCache = /* @__PURE__ */ new Map();
76
77
  async function shouldExternalize(id, options, cache = _defaultExternalizeCache) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vite-node",
3
3
  "type": "module",
4
- "version": "2.1.0",
4
+ "version": "2.1.2",
5
5
  "description": "Vite as Node.js runtime",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",