Skip to content

Commit

Permalink
Fix error when importing very large JS files (#4146)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda authored Oct 8, 2024
1 parent 8a8f65c commit 9725988
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
* Fixed `experimental-nodejs-module` target when used with `#[wasm_bindgen(start)]`.
[#4093](https://github.com/rustwasm/wasm-bindgen/pull/4093)

* Fixed error when importing very large JS files.
[#4146](https://github.com/rustwasm/wasm-bindgen/pull/4146)

--------------------------------------------------------------------------------

## [0.2.93](https://github.com/rustwasm/wasm-bindgen/compare/0.2.92...0.2.93)
Expand Down
4 changes: 4 additions & 0 deletions crates/backend/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,14 @@ impl TryToTokens for ast::Program {
const _CHUNK_SLICES: [&[u8]; #chunk_len] = [
#(#encoded_chunks,)*
];
#[allow(long_running_const_eval)]
const _CHUNK_LEN: usize = flat_len(_CHUNK_SLICES);
#[allow(long_running_const_eval)]
const _CHUNKS: [u8; _CHUNK_LEN] = flat_byte_slices(_CHUNK_SLICES);

const _LEN_BYTES: [u8; 4] = (_CHUNK_LEN as u32).to_le_bytes();
const _ENCODED_BYTES_LEN: usize = _CHUNK_LEN + 4;
#[allow(long_running_const_eval)]
const _ENCODED_BYTES: [u8; _ENCODED_BYTES_LEN] = flat_byte_slices([&_LEN_BYTES, &_CHUNKS]);
&_ENCODED_BYTES
});
Expand Down Expand Up @@ -174,6 +177,7 @@ impl TryToTokens for ast::Program {
const _LEN: usize = _PREFIX_JSON_BYTES_LEN + _ENCODED_BYTES_LEN;

#[link_section = "__wasm_bindgen_unstable"]
#[allow(long_running_const_eval)]
static _GENERATED: [u8; _LEN] = flat_byte_slices([_PREFIX_JSON_BYTES, _ENCODED_BYTES]);
};
})
Expand Down

0 comments on commit 9725988

Please sign in to comment.