diff --git a/src/js_parser/parse/parse_import_export.rs b/src/js_parser/parse/parse_import_export.rs index dc87c4546025..548abe6411ca 100644 --- a/src/js_parser/parse/parse_import_export.rs +++ b/src/js_parser/parse/parse_import_export.rs @@ -72,7 +72,7 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O // Reshaped for borrowck — EString::slice takes &mut self (rope flatten), // so capture the slice (arena-lifetime) before re-using `value` by-value below. let slice_opt: Option<&'a [u8]> = if let ExprData::EString(e_string) = &mut value.data { - if e_string.is_utf8() && e_string.is_present() { + if e_string.is_present() { Some(e_string.slice(p.arena)) } else { None diff --git a/test/bundler/transpiler/transpiler.test.js b/test/bundler/transpiler/transpiler.test.js index bf2b3db6485c..d4956d4f2245 100644 --- a/test/bundler/transpiler/transpiler.test.js +++ b/test/bundler/transpiler/transpiler.test.js @@ -2074,6 +2074,26 @@ console.log(
);`), expect(imports.filter(({ path }) => path === "react")).toHaveLength(1); expect(imports).toHaveLength(2); }); + + it("reports dynamic import() with non-ASCII specifiers", () => { + const t = new Bun.Transpiler({ loader: "ts" }); + for (const src of [ + `import("./café");`, + `import("./caf\\u00e9");`, + `import("./caf\\u{e9}");`, + `import("./中文");`, + `import("./🍣");`, + `import("./plain");`, + ]) { + const fast = t.scanImports(src); + const full = t.scan(src).imports; + expect({ src, fast }).toEqual({ + src, + fast: [{ kind: "dynamic-import", path: expect.any(String) }], + }); + expect({ src, fast }).toEqual({ src, fast: full }); + } + }); }); const parsed = (code, trim = true, autoExport = false, transpiler_ = transpiler) => {