@nxtedition/lib 22.0.9 → 22.0.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "22.0.9",
3
+ "version": "22.0.11",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
@@ -1,12 +1,19 @@
1
1
  import { createRequire } from 'node:module'
2
2
  import { readFileSync } from 'node:fs'
3
3
  import { parseSync, printSync, initSync } from '@swc/wasm-web'
4
+ import init from '@swc/wasm-web'
4
5
 
5
- const require = createRequire(import.meta.url)
6
- const wasmPath = require.resolve('@swc/wasm-web').replace('wasm.js', 'wasm_bg.wasm')
7
- const wasmBuffer = readFileSync(wasmPath)
6
+ const isNode = typeof process !== 'undefined' && process.toString() === '[object process]'
8
7
 
9
- initSync({ module: wasmBuffer })
8
+ if (isNode) {
9
+ const require = createRequire(import.meta.url)
10
+ const wasmPath = require.resolve('@swc/wasm-web').replace('wasm.js', 'wasm_bg.wasm')
11
+ const wasmBuffer = readFileSync(wasmPath)
12
+
13
+ initSync({ module: wasmBuffer })
14
+ } else {
15
+ await init()
16
+ }
10
17
 
11
18
  export default function (code) {
12
19
  const ast = parseSync(code, { syntax: 'ecmascript', script: true })