Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: bad output when chunk_loading_global containing quotation mark
Browse files Browse the repository at this point in the history
xusd320 committed Sep 11, 2024

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
1 parent 4897e32 commit 23ed602
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions crates/mako/src/generate/chunk_pot/str_impl.rs
Original file line number Diff line number Diff line change
@@ -112,12 +112,16 @@ pub(super) fn render_normal_js_chunk(
) -> Result<ChunkFile> {
let (content_buf, source_map_buf) = {
let pot = chunk_pot;

// to avoid ' or " been included in chunk_loading_global
let safe_prop =
serde_json::from_str::<serde_json::Value>(&context.config.output.chunk_loading_global)

Check warning on line 118 in crates/mako/src/generate/chunk_pot/str_impl.rs

Codecov / codecov/patch

crates/mako/src/generate/chunk_pot/str_impl.rs#L118

Added line #L118 was not covered by tests
.unwrap();

let chunk_prefix_code = format!(
r#"((typeof globalThis !== 'undefined' ? globalThis : self)['{}'] = (typeof globalThis !== 'undefined' ? globalThis : self)['{}'] || []).push([
['{}'],"#,
context.config.output.chunk_loading_global,
context.config.output.chunk_loading_global,
pot.chunk_id,
r#"((typeof globalThis !== 'undefined' ? globalThis : self)[{}] = (typeof globalThis !== 'undefined' ? globalThis : self)[{}] || []).push([
['{}'],"#,
safe_prop, safe_prop, pot.chunk_id,
);

let (chunk_content, chunk_raw_sourcemap) = pot_to_chunk_module_object_string(

0 comments on commit 23ed602

Please sign in to comment.