helloadhavan/github_issues huggingface dataset:
Repository: denoland/deno
Pull request: fix: retry writing lockfile on failure

Ran into this running the deno_graph ecosystem tests where many processes writing to the same path at the same time would cause an error.

Changed files:
filename: cli/args/lockfile.rs
patch: @@ -8,7 +8,7 @@ use deno_runtime::deno_node::PackageJson;
 
 use crate::args::ConfigFile;
 use crate::cache;
-use crate::util::fs::atomic_write_file;
+use crate::util::fs::atomic_write_file_with_retries;
 use crate::Flags;
 
 use super::DenoSubcommand;
@@ -84,7 +84,7 @@ pub fn write_lockfile_if_has_changes(
   };
   // do an atomic write to reduce the chance of multiple deno
   // processes corrupting the file
-  atomic_write_file(&lockfile.filename, bytes, cache::CACHE_PERM)
+  atomic_write_file_with_retries(&lockfile.filename, bytes, cache::CACHE_PERM)
     .context("Failed writing lockfile.")?;
   lockfile.has_content_changed = false;
   Ok(())

filename: cli/util/fs.rs
patch: @@ -32,6 +32,28 @@ use crate::util::progress_bar::ProgressBar;
 use crate::util::progress_bar::ProgressBarStyle;
 use crate::util::progress_bar::ProgressMessagePrompt;
 
+pub fn atomic_write_file_with_retries<T: AsRef<[u8]>>(
+  file_path: &Path,
+  data: T,
+  mode: u32,
+) -> std::io::Result<()> {
+  let mut count = 0;
+  loop {
+    match atomic_write_file(file_path, data.as_ref(), mode) {
+      Ok(()) => return Ok(()),
+      Err(err) => {
+        if count >= 5 {
+          // too many retries, return the error
+          return Err(err);
+        }
+        count += 1;
+        let sleep_ms = std::cmp::min(50, 10 * count);
+        std::thread::sleep(std::time::Duration::from_millis(sleep_ms));
+      }
+    }
+  }
+}
+
 /// Writes the file to the file system at a temporary path, then
 /// renames it to the destination in a single sys call in order
 /// to never leave the file system in a corrupted state.
@@ -50,8 +72,11 @@ pub fn atomic_write_file<T: AsRef<[u8]>>(
     mode: u32,
   ) -> std::io::Result<()> {
     write_file(temp_file_path, data, mode)?;
-    std::fs::rename(temp_file_path, file_path)?;
-    Ok(())
+    std::fs::rename(temp_file_path, file_path).map_err(|err| {
+      // clean up the created temp file on error
+      let _ = std::fs::remove_file(temp_file_path);
+      err
+    })
   }
 
   fn inner(file_path: &Path, data: &[u8], mode: u32) -> std::io::Result<()> {
Repository: nodejs/node
Pull request: doc: add more details for localStorage and sessionStorage

doc: add more details for localStorage and sessionStorage

Releated #53871

Changed files:
filename: doc/api/globals.md
patch: @@ -592,8 +592,11 @@ added: v22.4.0
 
 A browser-compatible implementation of [`localStorage`][]. Data is stored
 unencrypted in the file specified by the [`--localstorage-file`][] CLI flag.
+The maximum amount of data that can be stored is 10 MB.
 Any modification of this data outside of the Web Storage API is not supported.
 Enable this API with the [`--experimental-webstorage`][] CLI flag.
+`localStorage` data is not stored per user or per request when used in the context
+of a server, it is shared across all users and requests.
 
 ## `MessageChannel`
 
@@ -972,9 +975,8 @@ added: v22.4.0
 > Stability: 1.0 - Early development.
 
 A browser-compatible implementation of [`sessionStorage`][]. Data is stored in
-memory, with a storage quota of 10 MB. Any modification of this data outside of
-the Web Storage API is not supported. Enable this API with the
-[`--experimental-webstorage`][] CLI flag.
+memory, with a storage quota of 10 MB. `sessionStorage` data persists only within
+the currently running process, and is not shared between workers.
 
 ## `setImmediate(callback[, ...args])`
Repository: facebook/react
Pull request: Fix a string interpolation typo in ReactHooks test

<!--
  Thanks for submitting a pull request!
  We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory.

  Before submitting a pull request, please make sure the following is done:

  1. Fork [the repository](https://github.com/facebook/react) and create your branch from `main`.
  2. Run `yarn` in the repository root.
  3. If you've fixed a bug or added code that should be tested, add tests!
  4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development.
  5. Run `yarn test --prod` to test in the production environment. It supports the same options as `yarn test`.
  6. If you need a debugger, run `yarn debug-test --watch TestName`, open `chrome://inspect`, and press "Inspect".
  7. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`).
  8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files.
  9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`).
  10. If you haven't already, complete the CLA.

  Learn more about contributing: https://reactjs.org/docs/how-to-contribute.html
-->

## Summary

While doing some React porting work, I had to debug a test failure in ReactHooks-test.internal.js, and got confused by the name. There's a typo in two places that caused the string interpolation in ~20 test names to be incorrect. This caused some relevant information to be missing when the test is failing. Fix the typo to align it with the same correct pattern elsewhere in the file. (Searched for other instances of the typo across other test files and didn't find any others.)

<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->

## Test Plan

<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. -->
* yarn test (now shows correct names)
* yarn prettier
* yarn linc


Changed files:
filename: packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js
patch: @@ -1591,8 +1591,7 @@ describe('ReactHooks', () => {
         }
       });
 
-      it(`warns when more hooks (${(hookNameA,
-      hookNameB)}) are used during update than mount`, () => {
+      it(`warns when more hooks (${hookNameA}, ${hookNameB}) are used during update than mount`, () => {
         function App(props) {
           /* eslint-disable no-unused-vars */
           if (props.update) {
@@ -1646,8 +1645,7 @@ describe('ReactHooks', () => {
         .replace('use', '')
         .replace('Helper', '');
 
-      it(`warns when fewer hooks (${(hookNameA,
-      hookNameB)}) are used during update than mount`, () => {
+      it(`warns when fewer hooks (${hookNameA}, ${hookNameB}) are used during update than mount`, () => {
         function App(props) {
           /* eslint-disable no-unused-vars */
           if (props.update) {
Repository: ggml-org/llama.cpp
Pull request: llava : fix clip loading GGUFs with missing description

Some GGUFs may not have description.

Fixes #12658

Changed files:
filename: examples/llava/clip.cpp
patch: @@ -1396,14 +1396,16 @@ struct clip_ctx * clip_init(const char * fname, struct clip_context_params ctx_p
         const int n_kv = gguf_get_n_kv(ctx);
         const int ftype = get_u32(ctx, KEY_FTYPE);
         const std::string ftype_str = get_ftype(ftype);
-        const int idx_desc = get_key_idx(ctx, KEY_DESCRIPTION);
-        const std::string description = gguf_get_val_str(ctx, idx_desc);
         const int idx_name = gguf_find_key(ctx, KEY_NAME);
         if (idx_name != -1) { // make name optional temporarily as some of the uploaded models missing it due to a bug
             const std::string name = gguf_get_val_str(ctx, idx_name);
             LOG_INF("%s: model name:   %s\n", __func__, name.c_str());
         }
-        LOG_INF("%s: description:  %s\n", __func__, description.c_str());
+        const int idx_desc = get_key_idx(ctx, KEY_DESCRIPTION);
+        if (idx_desc != -1) { // ditto
+            const std::string description = gguf_get_val_str(ctx, idx_desc);
+            LOG_INF("%s: description:  %s\n", __func__, description.c_str());
+        }
         LOG_INF("%s: GGUF version: %d\n", __func__, gguf_get_version(ctx));
         LOG_INF("%s: alignment:    %zu\n", __func__, gguf_get_alignment(ctx));
         LOG_INF("%s: n_tensors:    %d\n", __func__, n_tensors);
Repository: denoland/deno
Pull request: fix(cron): enable chrono `now` feature


Changed files:
filename: ext/cron/Cargo.toml
patch: @@ -16,7 +16,7 @@ path = "lib.rs"
 [dependencies]
 anyhow.workspace = true
 async-trait.workspace = true
-chrono.workspace = true
+chrono = { workspace = true, features = ["now"] }
 deno_core.workspace = true
 saffron.workspace = true
 tokio.workspace = true
Repository: nodejs/node
Pull request: v8: out of bounds copy

Fixes: https://github.com/nodejs/node/issues/54573

<!--
Before submitting a pull request, please read:

- the CONTRIBUTING guide at https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md
- the commit message formatting guidelines at
  https://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md#commit-message-guidelines

For code changes:
1. Include tests for any bug fixes or new features.
2. Update documentation if relevant.
3. Ensure that `make -j4 test` (UNIX), or `vcbuild test` (Windows) passes.

If you believe this PR should be highlighted in the Node.js CHANGELOG
please add the `notable-change` label.

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.
-->


Changed files:
filename: lib/v8.js
patch: @@ -49,7 +49,6 @@ if (internalBinding('config').hasInspector) {
 }
 
 const assert = require('internal/assert');
-const { copy } = internalBinding('buffer');
 const { inspect } = require('internal/util/inspect');
 const { FastBuffer } = require('internal/buffer');
 const { getValidatedPath } = require('internal/fs/utils');
@@ -368,7 +367,7 @@ class DefaultDeserializer extends Deserializer {
     }
     // Copy to an aligned buffer first.
     const buffer_copy = Buffer.allocUnsafe(byteLength);
-    copy(this.buffer, buffer_copy, 0, byteOffset, byteOffset + byteLength);
+    buffer_copy.set(new Uint8Array(this.buffer.buffer, this.buffer.byteOffset + byteOffset, byteLength));
     return new ctor(buffer_copy.buffer,
                     buffer_copy.byteOffset,
                     byteLength / BYTES_PER_ELEMENT);

filename: test/parallel/test-v8-deserialize-buffer.js
patch: @@ -5,3 +5,7 @@ const v8 = require('v8');
 
 process.on('warning', common.mustNotCall());
 v8.deserialize(v8.serialize(Buffer.alloc(0)));
+v8.deserialize(v8.serialize({ a: new Int32Array(1024) }));
+v8.deserialize(v8.serialize({ b: new Int16Array(8192) }));
+v8.deserialize(v8.serialize({ c: new Uint32Array(1024) }));
+v8.deserialize(v8.serialize({ d: new Uint16Array(8192) }));
Repository: facebook/react
Pull request: [DevTools] Add performance marks for individual fetch() requests


Changed files:
filename: packages/react-devtools-extensions/src/parseHookNames/parseHookNames.js
patch: @@ -451,32 +451,48 @@ function extractAndLoadSourceMaps(
 }
 
 function fetchFile(url: string): Promise<string> {
+  if (__PERFORMANCE_PROFILE__) {
+    mark('fetchFile("' + url + '")');
+  }
+
   return new Promise((resolve, reject) => {
     fetch(url).then(
       response => {
         if (response.ok) {
           response
             .text()
             .then(text => {
+              if (__PERFORMANCE_PROFILE__) {
+                measure('fetchFile("' + url + '")');
+              }
               resolve(text);
             })
             .catch(error => {
               if (__DEBUG__) {
                 console.log(`fetchFile() Could not read text for url "${url}"`);
               }
+              if (__PERFORMANCE_PROFILE__) {
+                measure('fetchFile("' + url + '")');
+              }
               reject(null);
             });
         } else {
           if (__DEBUG__) {
             console.log(`fetchFile() Got bad response for url "${url}"`);
           }
+          if (__PERFORMANCE_PROFILE__) {
+            measure('fetchFile("' + url + '")');
+          }
           reject(null);
         }
       },
       error => {
         if (__DEBUG__) {
           console.log(`fetchFile() Could not fetch file: ${error.message}`);
         }
+        if (__PERFORMANCE_PROFILE__) {
+          measure('fetchFile("' + url + '")');
+        }
         reject(null);
       },
     );
Repository: ggml-org/llama.cpp
Pull request: metal : use constexpr in FA kernels + fix typedef

fix https://github.com/ggml-org/llama.cpp/pull/12612#issuecomment-2764254875

Changed files:
filename: ggml/src/ggml-metal/ggml-metal.metal
patch: @@ -3128,14 +3128,15 @@ kernel void kernel_flash_attn_ext(
     const int iq2 = tgpig[1];
     const int iq1 = tgpig[0]*Q;
 
-    const short DK4  = DK/4;
-    const short DK8  = DK/8;
-    const short DK16 = DK/16;
-    const short DV4  = DV/4;
-    const short DV8  = DV/8;
-    const short DV16 = DV/16;
-    const short NW  = N_SIMDWIDTH;
-    const short SH  = (2*C + Q); // shared memory per simdgroup (s_t == float)
+    constexpr short DK4  = DK/4;
+    constexpr short DK8  = DK/8;
+    constexpr short DK16 = DK/16;
+    constexpr short DV4  = DV/4;
+    constexpr short DV8  = DV/8;
+    constexpr short DV16 = DV/16;
+
+    constexpr short NW  = N_SIMDWIDTH;
+    constexpr short SH  = (2*C + Q); // shared memory per simdgroup (s_t == float)
 
     const short TS = nsg*SH;   // shared memory size per query in (s_t == float)
     const short T  = DK + 2*TS; // shared memory size per query in (half)
@@ -3641,11 +3642,11 @@ kernel void kernel_flash_attn_ext_vec(
     const int iq2 = tgpig[1];
     const int iq1 = tgpig[0];
 
-    const short DK4 = DK/4;
-    const short DV4 = DV/4;
-    const short NW  = N_SIMDWIDTH;
-    const short NL  = NW/NE; // note: this can be adjusted to support different head sizes and simdgroup work loads
-    const short SH  = 2*C;   // shared memory per simdgroup
+    constexpr short DK4 = DK/4;
+    constexpr short DV4 = DV/4;
+    constexpr short NW  = N_SIMDWIDTH;
+    constexpr short NL  = NW/NE; // note: this can be adjusted to support different head sizes and simdgroup work loads
+    constexpr short SH  = 2*C;   // shared memory per simdgroup
 
     const short T = DK + nsg*SH; // shared memory size per query in (half)
 
@@ -3956,7 +3957,7 @@ kernel void kernel_flash_attn_ext_vec(
     half,  half4, \
            half4
 
-typedef decltype(kernel_flash_attn_ext_vec<FA_TYPES, half4, 1, dequantize_f16_t4, half4, 1, dequantize_f16_t4, 128, 128, 128>) flash_attn_ext_vec_t;
+typedef decltype(kernel_flash_attn_ext_vec<FA_TYPES, half4, 1, dequantize_f16_t4, half4, 1, dequantize_f16_t4, 128, 128, 4>) flash_attn_ext_vec_t;
 
 template [[host_name("kernel_flash_attn_ext_vec_f16_h128")]]  kernel flash_attn_ext_vec_t kernel_flash_attn_ext_vec<FA_TYPES, half4,             1, dequantize_f16_t4,  half4,       1, dequantize_f16_t4,  128, 128, 4>;
 #if defined(GGML_METAL_USE_BF16)
Repository: huggingface/transformers
Pull request: Fixup for distill_any_depth conversion script

# What does this PR do?

It looks like ruff was updated before the last run of tests for https://github.com/huggingface/transformers/pull/36614

Changed files:
filename: src/transformers/models/depth_anything/convert_distill_any_depth_to_hf.py
patch: @@ -45,12 +45,12 @@
     r"(backbone|pretrained)(\.blocks(\.\d+)?)?\.(\d+)\.norm(1|2)\.(weight|bias)": r"backbone.encoder.layer.\4.norm\5.\6",
     r"depth_head\.projects\.(\d+)\.(weight|bias)": r"neck.reassemble_stage.layers.\1.projection.\2",
     r"depth_head\.resize_layers\.(?!2)(\d+)\.(weight|bias)": r"neck.reassemble_stage.layers.\1.resize.\2",
-    r"depth_head\.scratch\.layer(\d+)_rn\.weight": lambda m: f"neck.convs.{int(m[1])-1}.weight",
+    r"depth_head\.scratch\.layer(\d+)_rn\.weight": lambda m: f"neck.convs.{int(m[1]) - 1}.weight",
     r"depth_head\.scratch\.output_conv(\d+)(?:\.(\d+))?\.(weight|bias)": lambda m: (
-        f"head.conv{int(m[1]) + (int(m[2])//2 if m[2] else 0)}.{m[3]}" if m[1] == "2" else f"head.conv{m[1]}.{m[3]}"
+        f"head.conv{int(m[1]) + (int(m[2]) // 2 if m[2] else 0)}.{m[3]}" if m[1] == "2" else f"head.conv{m[1]}.{m[3]}"
     ),
-    r"depth_head\.scratch\.refinenet(\d+)\.out_conv\.(weight|bias)": lambda m: f"neck.fusion_stage.layers.{3 - (int(m[1])-1)}.projection.{m[2]}",
-    r"depth_head\.scratch\.refinenet(\d+)\.resConfUnit(\d+)\.conv(\d+)\.(weight|bias)": lambda m: f"neck.fusion_stage.layers.{3 - (int(m[1])-1)}.residual_layer{m[2]}.convolution{m[3]}.{m[4]}",
+    r"depth_head\.scratch\.refinenet(\d+)\.out_conv\.(weight|bias)": lambda m: f"neck.fusion_stage.layers.{3 - (int(m[1]) - 1)}.projection.{m[2]}",
+    r"depth_head\.scratch\.refinenet(\d+)\.resConfUnit(\d+)\.conv(\d+)\.(weight|bias)": lambda m: f"neck.fusion_stage.layers.{3 - (int(m[1]) - 1)}.residual_layer{m[2]}.convolution{m[3]}.{m[4]}",
 }
Repository: electron/electron
Pull request: fix: handle failing to enter fullscreen on macOS

Backport of #43112

See that PR for details.


Notes: Fix behavior when entering/exiting fullscreen fails on macOS.

Changed files:
filename: shell/browser/native_window_mac.h
patch: @@ -168,6 +168,7 @@ class NativeWindowMac : public NativeWindow,
   void DetachChildren() override;
 
   void NotifyWindowWillEnterFullScreen();
+  void NotifyWindowDidFailToEnterFullScreen();
   void NotifyWindowWillLeaveFullScreen();
 
   // Cleanup observers when window is getting closed. Note that the destructor

filename: shell/browser/native_window_mac.mm
patch: @@ -1783,6 +1783,13 @@ void ReorderChildWindowAbove(NSWindow* child_window, NSWindow* other_window) {
   UpdateVibrancyRadii(true);
 }
 
+void NativeWindowMac::NotifyWindowDidFailToEnterFullScreen() {
+  UpdateVibrancyRadii(false);
+
+  if (buttons_proxy_)
+    [buttons_proxy_ redraw];
+}
+
 void NativeWindowMac::NotifyWindowWillLeaveFullScreen() {
   if (buttons_proxy_) {
     // Hide window title when leaving fullscreen.

filename: shell/browser/ui/cocoa/electron_ns_window_delegate.mm
patch: @@ -311,6 +311,18 @@ - (void)windowDidEnterFullScreen:(NSNotification*)notification {
   shell_->HandlePendingFullscreenTransitions();
 }
 
+- (void)windowDidFailToEnterFullScreen:(NSWindow*)window {
+  shell_->set_fullscreen_transition_state(FullScreenTransitionState::kNone);
+
+  shell_->SetResizable(is_resizable_);
+  shell_->NotifyWindowDidFailToEnterFullScreen();
+
+  if (shell_->HandleDeferredClose())
+    return;
+
+  shell_->HandlePendingFullscreenTransitions();
+}
+
 - (void)windowWillExitFullScreen:(NSNotification*)notification {
   shell_->set_fullscreen_transition_state(FullScreenTransitionState::kExiting);
Repository: denoland/deno
Pull request: fix(task): always use `npm` for `npm run` with flags

We forward any arguments passed to `npm run` to `deno task` which errored because arguments are not compatible. Since most arguments to `npm run` are mostly for enhancing output, we can simply skip them for now.

Fixes https://github.com/denoland/deno/issues/24026


Changed files:
filename: cli/tools/task.rs
patch: @@ -344,24 +344,27 @@ impl ShellCommand for NpmCommand {
     mut context: ShellCommandContext,
   ) -> LocalBoxFuture<'static, ExecuteResult> {
     if context.args.first().map(|s| s.as_str()) == Some("run")
-      && !context.args.iter().any(|s| s == "--")
+      && context.args.len() > 2
+      // for now, don't run any npm scripts that have a flag because
+      // we don't handle stuff like `--workspaces` properly
+      && !context.args.iter().any(|s| s.starts_with('-'))
     {
-      if let Some(task_name) = context.args.get(1) {
-        // run with deno task instead
-        let mut args = vec!["task".to_string(), task_name.to_string()];
-        args.extend(context.args.iter().skip(2).cloned());
-        let mut state = context.state;
-        state.apply_env_var(USE_PKG_JSON_HIDDEN_ENV_VAR_NAME, "1");
-        return ExecutableCommand::new(
-          "deno".to_string(),
-          std::env::current_exe().unwrap(),
-        )
-        .execute(ShellCommandContext {
-          args,
-          state,
-          ..context
-        });
-      }
+      // run with deno task instead
+      let mut args = Vec::with_capacity(context.args.len());
+      args.push("task".to_string());
+      args.extend(context.args.iter().skip(1).cloned());
+
+      let mut state = context.state;
+      state.apply_env_var(USE_PKG_JSON_HIDDEN_ENV_VAR_NAME, "1");
+      return ExecutableCommand::new(
+        "deno".to_string(),
+        std::env::current_exe().unwrap(),
+      )
+      .execute(ShellCommandContext {
+        args,
+        state,
+        ..context
+      });
     }
 
     // fallback to running the real npm command
@@ -647,7 +650,7 @@ esac
 
 if [ -x "$basedir/node" ]; then
   exec "$basedir/node"  "$basedir/../example/bin/example" "$@"
-else 
+else
   exec node  "$basedir/../example/bin/example" "$@"
 fi"#;
     assert_eq!(

filename: tests/specs/task/npm_run/__test__.jsonc
patch: @@ -12,6 +12,10 @@
     "npm_run": {
       "args": "task npm_run",
       "output": "task_npm_run.out"
+    },
+    "npm_run_args": {
+      "args": "task npm_run_args",
+      "output": "task_npm_run_args.out"
     }
   }
 }

filename: tests/specs/task/npm_run/deno.jsonc
patch: @@ -6,6 +6,7 @@
     // currently this will execute using the actual `npm run` because we
     // haven't implemented the flags for `npm run` yet
     "test_using_npm": "npm run non_existent -- --ignore-scripts",
-    "npm_run": "npm run"
+    "npm_run": "npm run",
+    "npm_run_args": "npm run -d echo"
   }
 }

filename: tests/specs/task/npm_run/task_npm_run_args.out
patch: @@ -0,0 +1,5 @@
+Task npm_run_args npm run -d echo
+npm info using[WILDCARD]
+
+> echo
+[WILDCARD]
Repository: vercel/next.js
Pull request: fix(turbopack): Apply `hygiene` if mangling is disabled

### What?

Apply the normal variable renamer when we are not going to apply minfiying var renamer.

### Why?

Var renamer should be applied at least once.

### How?

Closes PACK-4245

Changed files:
filename: turbopack/crates/turbopack-ecmascript/src/minify.rs
patch: @@ -16,7 +16,10 @@ use swc_core::{
         },
         minifier::option::{CompressOptions, ExtraOptions, MangleOptions, MinifyOptions},
         parser::{lexer::Lexer, Parser, StringInput, Syntax},
-        transforms::base::fixer::paren_remover,
+        transforms::base::{
+            fixer::paren_remover,
+            hygiene::{self, hygiene_with_config},
+        },
     },
 };
 use tracing::{instrument, Level};
@@ -99,6 +102,13 @@ pub fn minify(path: &FileSystemPath, code: &Code, source_maps: bool, mangle: boo
                     },
                 );
 
+                if !mangle {
+                    program.mutate(hygiene_with_config(hygiene::Config {
+                        top_level_mark,
+                        ..Default::default()
+                    }));
+                }
+
                 Ok(program.apply(ecma::transforms::base::fixer::fixer(Some(
                     &comments as &dyn Comments,
                 ))))