Skip to content

Commit 80b616e

Browse files
Fix TextEncoder stub name (#3357)
1 parent 8994cb9 commit 80b616e

File tree

1 file changed

+4
-2
lines changed
  • crates/cli-support/src/js

1 file changed

+4
-2
lines changed

crates/cli-support/src/js/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ impl<'a> Context<'a> {
14401440
if !self.should_write_global("text_encoder") {
14411441
return Ok(());
14421442
}
1443-
self.expose_text_processor("TextEncoder", "('utf-8')", None)
1443+
self.expose_text_processor("TextEncoder", "encode", "('utf-8')", None)
14441444
}
14451445

14461446
fn expose_text_decoder(&mut self) -> Result<(), Error> {
@@ -1456,6 +1456,7 @@ impl<'a> Context<'a> {
14561456
// `fatal` is needed to catch any weird encoding bugs when sending a string from Rust to JS
14571457
self.expose_text_processor(
14581458
"TextDecoder",
1459+
"decode",
14591460
"('utf-8', { ignoreBOM: true, fatal: true })",
14601461
init,
14611462
)?;
@@ -1466,6 +1467,7 @@ impl<'a> Context<'a> {
14661467
fn expose_text_processor(
14671468
&mut self,
14681469
s: &str,
1470+
op: &str,
14691471
args: &str,
14701472
init: Option<&str>,
14711473
) -> Result<(), Error> {
@@ -1496,7 +1498,7 @@ impl<'a> Context<'a> {
14961498
| OutputMode::Web
14971499
| OutputMode::NoModules { .. }
14981500
| OutputMode::Bundler { browser_only: true } => {
1499-
self.global(&format!("const cached{0} = (typeof {0} !== 'undefined' ? new {0}{1} : {{ decode: () => {{ throw Error('{0} not available') }} }} );", s, args))
1501+
self.global(&format!("const cached{0} = (typeof {0} !== 'undefined' ? new {0}{1} : {{ {2}: () => {{ throw Error('{0} not available') }} }} );", s, args, op))
15001502
}
15011503
};
15021504

0 commit comments

Comments
 (0)