modly icon indicating copy to clipboard operation
modly copied to clipboard

fix(electron): use namespace tar import for extension extraction

Open DrHepa opened this issue 7 months ago • 1 comments

Summary

While testing extension install/repair flows in a fork of Modly, I hit an issue around the tar import used in electron/main/ipc-handlers.ts during archive extraction.

A small import change fixed the extension extraction path for me:

  • from:
    import tar from 'tar'
    
  • to:
    import * as tar from 'tar'
    

Why I’m opening this first

This is a small and isolated compatibility fix, so I wanted to ask before opening a PR.

Context

The extraction flow currently calls:

await tar.x({ file: tarPath, cwd: extractDir, strip: 1 })

in:

  • electron/main/ipc-handlers.ts

In my environment, using the namespace import made the extension repair/install flow behave correctly.

Affected surface

This looks related to the extension archive extraction path used by:

  • install/repair flows
  • downloaded extension unpacking
  • any path that relies on tar.x(...) from Electron main

Proposed change

Use the namespace import for tar in Electron main:

import * as tar from 'tar'

instead of the default import.

Why this seems safer

This avoids ESM/CommonJS interop ambiguity around the tar package shape and matches how some packages expose their API in Node/Electron environments.

Scope

This is intentionally small:

  • no behavioral changes
  • no feature changes
  • just a compatibility/import fix for an existing path

Question

Would you be open to a small PR for this import change?

DrHepa avatar Apr 13 '26 10:04 DrHepa

I fixed it directly, it’ll be included in the next patch

lightningpixel avatar Apr 17 '26 09:04 lightningpixel