@voidzero-dev/vite-plus-core 0.1.15-alpha.4 → 0.1.15-alpha.6

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.
@@ -1,14 +1,14 @@
1
1
  import { builtinModules } from "node:module";
2
- import { fileURLToPath, pathToFileURL } from "node:url";
3
2
  import process from "node:process";
4
3
  import "node:child_process";
5
4
  import path from "node:path";
6
5
  import { rolldown } from "@voidzero-dev/vite-plus-core/rolldown";
6
+ import re, { existsSync } from "node:fs";
7
7
  import { tmpdir } from "node:os";
8
- import fs, { existsSync } from "node:fs";
8
+ import { fileURLToPath, pathToFileURL } from "node:url";
9
9
  import { Buffer } from "node:buffer";
10
10
  import crypto from "node:crypto";
11
- //#region ../../node_modules/.pnpm/unrun@0.2.33/node_modules/unrun/dist/src-GU5PtktT.mjs
11
+ //#region ../../node_modules/.pnpm/unrun@0.2.34/node_modules/unrun/dist/src-GU5PtktT.mjs
12
12
  /**
13
13
  * Applies preset-specific handling to the loaded module.
14
14
  */
@@ -54,7 +54,7 @@ function resolveOptions(options = {}) {
54
54
  inputOptions: options.inputOptions,
55
55
  outputOptions: options.outputOptions
56
56
  };
57
- if (!fs.existsSync(resolvedOptions.path)) throw new Error(`[unrun] File not found: ${resolvedOptions.path}`);
57
+ if (!re.existsSync(resolvedOptions.path)) throw new Error(`[unrun] File not found: ${resolvedOptions.path}`);
58
58
  if (!new Set([
59
59
  "none",
60
60
  "jiti",
@@ -268,7 +268,7 @@ function createJsonLoader() {
268
268
  let isRequire = false;
269
269
  try {
270
270
  if (importer) {
271
- const src = fs.readFileSync(importer, "utf8");
271
+ const src = re.readFileSync(importer, "utf8");
272
272
  const escaped = source.replaceAll(/[.*+?^${}()|[\]\\]/g, (m) => `\\${m}`);
273
273
  const pattern = String.raw`\brequire\s*\(\s*['"]${escaped}['"]\s*\)`;
274
274
  isRequire = new RegExp(pattern).test(src);
@@ -281,7 +281,7 @@ function createJsonLoader() {
281
281
  handler(id) {
282
282
  try {
283
283
  const realId = id.replace(/\?unrun-json\.(?:mjs|cjs)$/, "");
284
- const src = fs.readFileSync(realId, "utf8");
284
+ const src = re.readFileSync(realId, "utf8");
285
285
  const data = JSON.parse(src);
286
286
  const jsonLiteral = JSON.stringify(data);
287
287
  if (id.endsWith("?unrun-json.cjs")) return { code: `const __data = ${jsonLiteral}\ntry { Object.defineProperty(__data, 'default', { value: __data, enumerable: false, configurable: true }) } catch {}\nmodule.exports = __data\n` };
@@ -375,7 +375,7 @@ function createRequireResolveFix(options) {
375
375
  ".cjs"
376
376
  ]) {
377
377
  const testPath = path.resolve(baseDir, id + ext);
378
- if (fs.existsSync(testPath)) return JSON.stringify(testPath);
378
+ if (re.existsSync(testPath)) return JSON.stringify(testPath);
379
379
  }
380
380
  const resolvedPath = path.resolve(baseDir, id);
381
381
  return JSON.stringify(resolvedPath);
@@ -416,7 +416,7 @@ function createSourceContextShimsPlugin() {
416
416
  const normalizedPhysicalId = path.normalize(physicalId);
417
417
  let code;
418
418
  try {
419
- code = fs.readFileSync(normalizedPhysicalId, "utf8");
419
+ code = re.readFileSync(normalizedPhysicalId, "utf8");
420
420
  } catch {
421
421
  return null;
422
422
  }
@@ -658,7 +658,7 @@ function cleanModule(moduleUrl, options) {
658
658
  try {
659
659
  if (moduleUrl.startsWith("file://")) {
660
660
  const filePath = new URL(moduleUrl);
661
- fs.unlinkSync(filePath);
661
+ re.unlinkSync(filePath);
662
662
  }
663
663
  } catch (error) {
664
664
  if (error.code !== "ENOENT") throw error;
@@ -682,14 +682,14 @@ function writeModule(code, options) {
682
682
  const projectNodeModules = path.join(process.cwd(), "node_modules");
683
683
  const outDir = path.join(projectNodeModules, ".unrun");
684
684
  const outFile = path.join(outDir, fname);
685
- if (!fs.existsSync(outFile)) try {
686
- fs.mkdirSync(outDir, { recursive: true });
687
- fs.writeFileSync(outFile, code, "utf8");
685
+ if (!re.existsSync(outFile)) try {
686
+ re.mkdirSync(outDir, { recursive: true });
687
+ re.writeFileSync(outFile, code, "utf8");
688
688
  } catch {
689
689
  const fallbackDir = path.join(tmpdir(), "unrun-cache");
690
690
  const fallbackFile = path.join(fallbackDir, fname);
691
- fs.mkdirSync(fallbackDir, { recursive: true });
692
- fs.writeFileSync(fallbackFile, code, "utf8");
691
+ re.mkdirSync(fallbackDir, { recursive: true });
692
+ re.writeFileSync(fallbackFile, code, "utf8");
693
693
  moduleUrl = pathToFileURL(fallbackFile).href;
694
694
  }
695
695
  moduleUrl = moduleUrl || pathToFileURL(outFile).href;