alangpierce/sucrase

Transpilation bug, changes `;` to `,`

renhiyama opened this issue · 2 comments

My code:

import Surreal from "surrealdb.js";

const db = new Surreal(Deno.env.get("DB_URL"));

await db.signin({
  user: Deno.env.get("DB_USER"),
  pass: Deno.env.get("DB_PASSWORD"),
});

await db.use("test", "test");

export default db;

The code it compiles into:

import e from"https://deno.land/x/surrealdb/mod.ts";const t=new e(Deno.env.get("DB_URL"));await t.signin({user:Deno.env.get("DB_USER"),pass:Deno.env.get("DB_PASSWORD")}),await t.use("test","test");export default t;

(Do note that my code searches and replaces module names and replaces them with their urls. And I do use terser to minify the code.)

The bug is after "DB_PASSWORD" in the compiled code. it shows , instead of ;

Hi @renhiyama , thanks for the report. I suspect that this might be an issue in terser or some other part of your build process; running your code through Sucrase in the playground doesn't have the issue you described:

https://sucrase.io/#transforms=jsx%2Ctypescript&compressedCode=H4sIAH2AO2QAA22PQQrCMBBF9znFkFUKJQewuFDqTqg0iEtJ7bRE2qRkUiuId7exuBBdfYZ578M3%2FeB8ADV6j7qDxrseOC1XXckr8Yyxi7MUoK5gDRanDyxytE6ivckWg%2BD59nws9zxJZkFP2kRBkmmtseLBAEZCv4JfR%2B1KnqQzMGiiP8Bho9SpKPMIPb%2FK50bBA1LgKSwZ33h%2FL6qx0WMXuYy9AKgQRF3lAAAA

If it does still seem like a bug in Sucrase, could you provide the exact config and input/output code? Thanks!

Ah, it is definitely terser's problem. I have made an issue over theirs. Sorry for disturbing you.