diff --git a/packages/noise/package.json b/packages/noise/package.json index 8f18923cde..3e475159b4 100644 --- a/packages/noise/package.json +++ b/packages/noise/package.json @@ -2,9 +2,11 @@ "name": "@latticexyz/noise", "version": "2.0.0-next.4", "license": "MIT", - "type": "module", "exports": { - ".": "./dist/index.js" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.js" + } }, "types": "ts/index.ts", "scripts": { diff --git a/packages/noise/ts/index.ts b/packages/noise/ts/index.ts index 3c8e2632a1..f7956b85ae 100644 --- a/packages/noise/ts/index.ts +++ b/packages/noise/ts/index.ts @@ -1,4 +1,5 @@ import fs from "fs"; +import path from "path"; // import * as buffer from "buffer"; // const { Buffer } = buffer; @@ -41,7 +42,11 @@ export function createSplines(splines: [number, number][]): (x: number) => numbe export type Perlin = (_x: number, _y: number, _z: number, denom: number) => number; export async function createPerlin(): Promise { - const wasmModule = await fetchAndCompileWasmModule(new URL("../build/release.wasm", import.meta.url)); + const wasmModule = await fetchAndCompileWasmModule( + import.meta.url + ? new URL("../build/release.wasm", import.meta.url) + : path.resolve(__dirname, "../build/release.wasm") + ); const wasmInstance = await WebAssembly.instantiate(wasmModule, { env: { abort: (e: string) => { diff --git a/packages/noise/tsup.config.ts b/packages/noise/tsup.config.ts index 264a5bbff8..7fe1c11010 100644 --- a/packages/noise/tsup.config.ts +++ b/packages/noise/tsup.config.ts @@ -3,7 +3,7 @@ import { defineConfig } from "tsup"; export default defineConfig({ entry: ["ts/index.ts"], target: "esnext", - format: ["esm"], + format: ["esm", "cjs"], dts: false, sourcemap: true, clean: true,