Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/js_parser/parse/parse_import_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions test/bundler/transpiler/transpiler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2074,6 +2074,26 @@ console.log(<div {...obj} key="after" />);`),
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) => {
Expand Down
Loading