@reteps/dockerfmt 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/format.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import './wasm_exec.js';
2
2
  export const formatDockerfileContents = async (fileContents, options, getWasm) => {
3
- const go = new Go(); // Defined in wasm_exec.js
3
+ // Use our namespaced Go class instead of globalThis.Go to avoid conflicts
4
+ // with other Go WASM packages (see wasm_exec.js modifications).
5
+ const GoClass = globalThis.__dockerfmt_Go;
6
+ const go = new GoClass();
4
7
  const wasmBuffer = await getWasm();
5
8
  const wasm = await WebAssembly.instantiate(wasmBuffer, go.importObject);
6
9
  /**
package/dist/format.wasm CHANGED
Binary file
package/dist/wasm_exec.js CHANGED
@@ -100,6 +100,10 @@
100
100
  const encoder = new TextEncoder("utf-8");
101
101
  const decoder = new TextDecoder("utf-8");
102
102
 
103
+ // Save any existing Go constructor so we can restore it after capturing our own.
104
+ // This prevents clobbering the global Go when other packages (e.g. sh-syntax)
105
+ // rely on their own wasm_exec.js version with different capabilities (like WASI support).
106
+ const __previousGo = globalThis.Go;
103
107
  globalThis.Go = class {
104
108
  constructor() {
105
109
  this.argv = ["js"];
@@ -572,4 +576,12 @@
572
576
  };
573
577
  }
574
578
  }
579
+ // Stash our Go class under a namespaced global and restore the previous one,
580
+ // so we don't break other Go WASM packages sharing the same global scope.
581
+ globalThis.__dockerfmt_Go = globalThis.Go;
582
+ if (__previousGo) {
583
+ globalThis.Go = __previousGo;
584
+ } else {
585
+ delete globalThis.Go;
586
+ }
575
587
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reteps/dockerfmt",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "repository": {