Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vite-node 0.25.5 prevents code from running, blocking test:playground #14

Closed
Tanimodori opened this issue Jan 30, 2023 · 2 comments
Closed
Assignees
Labels
enhancement New feature or request upstream

Comments

@Tanimodori
Copy link
Owner

The deployment build was successful and it will only affect testing while developing. I suggest to change the whole repo structure using pnpm workspace like vite-plugin-dts.

@Tanimodori Tanimodori self-assigned this Jan 30, 2023
@Tanimodori Tanimodori added the enhancement New feature or request label Jan 30, 2023
@Tanimodori
Copy link
Owner Author

Ok I found the smoking gun:

D:\Tanimodori\Project\__3RD__\@@bitburner\viteburner>set VITE_NODE_DEBUG_DUMP=true && npx vite-node ./src/utils.ts 
[vite-node] [debug] dump modules to D:/Tanimodori/Project/__3RD__/@@bitburner/viteburner/.vite-node/dump
D:\Tanimodori\Project\__3RD__\@@bitburner\viteburner\src\utils.ts:58
}}


SyntaxError: Unexpected end of input
    at new Script (node:vm:100:7)
    at createScript (node:vm:265:10)
    at Object.runInThisContext (node:vm:313:10)
    at ViteNodeRunner.directRequest (file:///D:/Tanimodori/Project/__3RD__/@@bitburner/viteburner/node_modules/vite-node/dist/client.mjs:307:19)
    at ViteNodeRunner.cachedRequest (file:///D:/Tanimodori/Project/__3RD__/@@bitburner/viteburner/node_modules/vite-node/dist/client.mjs:156:14)
    at ViteNodeRunner.executeFile (file:///D:/Tanimodori/Project/__3RD__/@@bitburner/viteburner/node_modules/vite-node/dist/client.mjs:133:12)
    at CAC.run (file:///D:/Tanimodori/Project/__3RD__/@@bitburner/viteburner/node_modules/vite-node/dist/cli.mjs:70:5)

Which is transforming from

import { SourceMap } from 'rollup';
import fs from 'fs';
import path from 'path';

export function getSourceMapString(map?: SourceMap | null): string {
  if (!map) return '';
  const mapDataString = JSON.stringify(map);
  return `//# sourceMappingURL=data:application/json;base64,${Buffer.from(mapDataString).toString('base64')}`;
}

export async function writeFile(file: string, content: string) {
  const dir = path.dirname(file);
  if (!fs.existsSync(dir)) {
    await fs.promises.mkdir(dir, { recursive: true });
  }
  return fs.promises.writeFile(file, content, {
    flag: 'w',
    encoding: 'utf8',
  });
}

export function isScriptFile(filename: string) {
  return filename.endsWith('.js') || filename.endsWith('.script');
}

/** Enforce starting slash */
export const forceStartingSlash = (s: string) => {
  return s.startsWith('/') ? s : '/' + s;
};

/** Enforce starting slash if file is not in root dir */
export const fixStartingSlash = (s: string) => {
  const index = s.lastIndexOf('/');
  if (index === 0) {
    // if file is in root dir with starting slash, remove it
    return s.substring(1);
  } else if (index !== -1) {
    // if file is not in root dir, add starting slash
    return forceStartingSlash(s);
  } else {
    // if file is in root dir without starting slash, keep it as-is
    return s;
  }
};

/** Remove starting slash on download */
export const removeStartingSlash = (s: string) => {
  return s.startsWith('/') ? s.substring(1) : s;
};

export const defaultUploadLocation = (file: string) => {
  return file.replace(/^src\//, '').replace(/\.ts$/, '.js');
};

// from vite packages\vite\src\node\utils.ts
export const externalRE = /^(https?:)?\/\//;
export const isExternalUrl = (url: string): boolean => externalRE.test(url);

to

// D:/Tanimodori/Project/__3RD__/@@bitburner/viteburner/src/utils.ts
const __vite_ssr_import_0__ = await __vite_ssr_import__("fs");

const __vite_ssr_import_1__ = await __vite_ssr_import__("path");

function getSourceMapString(map) {
  if (!map)
    return "";
  const mapDataString = JSON.stringify(map);
  return `
}
Object.defineProperty(__vite_ssr_exports__, "getSourceMapString", { enumerable: true, configurable: true, get(){ return getSourceMapString }});
async function writeFile(file, content) {
  const dir = __vite_ssr_import_1__.default.dirname(file);
  if (!__vite_ssr_import_0__.default.existsSync(dir)) {
    await __vite_ssr_import_0__.default.promises.mkdir(dir, { recursive: true });
  }
  return __vite_ssr_import_0__.default.promises.writeFile(file, content, {
    flag: "w",
    encoding: "utf8"
  });
}
Object.defineProperty(__vite_ssr_exports__, "writeFile", { enumerable: true, configurable: true, get(){ return writeFile }});
function isScriptFile(filename) {
  return filename.endsWith(".js") || filename.endsWith(".script");
}
Object.defineProperty(__vite_ssr_exports__, "isScriptFile", { enumerable: true, configurable: true, get(){ return isScriptFile }});
const forceStartingSlash = (s) => {
  return s.startsWith("/") ? s : "/" + s;
};
Object.defineProperty(__vite_ssr_exports__, "forceStartingSlash", { enumerable: true, configurable: true, get(){ return forceStartingSlash }});
const fixStartingSlash = (s) => {
  const index = s.lastIndexOf("/");
  if (index === 0) {
    return s.substring(1);
  } else if (index !== -1) {
    return forceStartingSlash(s);
  } else {
    return s;
  }
};
Object.defineProperty(__vite_ssr_exports__, "fixStartingSlash", { enumerable: true, configurable: true, get(){ return fixStartingSlash }});
const removeStartingSlash = (s) => {
  return s.startsWith("/") ? s.substring(1) : s;
};
Object.defineProperty(__vite_ssr_exports__, "removeStartingSlash", { enumerable: true, configurable: true, get(){ return removeStartingSlash }});
const defaultUploadLocation = (file) => {
  return file.replace(/^src\//, "").replace(/\.ts$/, ".js");
};
Object.defineProperty(__vite_ssr_exports__, "defaultUploadLocation", { enumerable: true, configurable: true, get(){ return defaultUploadLocation }});
const externalRE = /^(https?:)?\/\//;
Object.defineProperty(__vite_ssr_exports__, "externalRE", { enumerable: true, configurable: true, get(){ return externalRE }});
const isExternalUrl = (url) => externalRE.test(url);
Object.defineProperty(__vite_ssr_exports__, "isExternalUrl", { enumerable: true, configurable: true, get(){ return isExternalUrl }});

//# sourceMappingSource=vite-node
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJtYXBwaW5ncyI6IjtBQUNlOztBQUNFO0FBRVYsU0FBUyxtQkFBbUIsS0FBZ0M7QUFDakUsTUFBSSxDQUFDO0FBQUssV0FBTztBQUNqQixRQUFNLGdCQUFnQixLQUFLLFVBQVUsR0FBRztBQUN4QyxTQUFPLHFEQUFxRCxPQUFPLEtBQUssYUFBYSxFQUFFLFNBQVMsUUFBUTtBQUMxRzsrSUFBQTtBQUVBLGVBQXNCLFVB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HJcbn07XHJcblxyXG4vKiogUmVtb3ZlIHN0YXJ0aW5nIHNsYXNoIG9uIGRvd25sb2FkICovXHJcbmV4cG9ydCBjb25zdCByZW1vdmVTdGFydGluZ1NsYXNoID0gKHM6IHN0cmluZykgPT4ge1xyXG4gIHJldHVybiBzLnN0YXJ0c1dpdGgoJy8nKSA/IHMuc3Vic3RyaW5nKDEpIDogcztcclxufTtcclxuXHJcbmV4cG9ydCBjb25zdCBkZWZhdWx0VXBsb2FkTG9jYXRpb24gPSAoZmlsZTogc3RyaW5nKSA9PiB7XHJcbiAgcmV0dXJuIGZpbGUucmVwbGFjZSgvXnNyY1xcLy8sICcnKS5yZXBsYWNlKC9cXC50cyQvLCAnLmpzJyk7XHJcbn07XHJcblxyXG4vLyBmcm9tIHZpdGUgcGFja2FnZXNcXHZpdGVcXHNyY1xcbm9kZVxcdXRpbHMudHNcclxuZXhwb3J0IGNvbnN0IGV4dGVybmFsUkUgPSAvXihodHRwcz86KT9cXC9cXC8vO1xyXG5leHBvcnQgY29uc3QgaXNFeHRlcm5hbFVybCA9ICh1cmw6IHN0cmluZyk6IGJvb2xlYW4gPT4gZXh0ZXJuYWxSRS50ZXN0KHVybCk7XHJcbiJdLCJmaWxlIjoiRDovVGFuaW1vZG9yaS9Qcm9qZWN0L19fM1JEX18vQEBiaXRidXJuZXIvdml0ZWJ1cm5lci9zcmMvdXRpbHMudHMifQ==

So there's a missing backtick here.

@Tanimodori
Copy link
Owner Author

Upstream issue vitest-dev/vitest#2918

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request upstream
Projects
None yet
Development

No branches or pull requests

1 participant