Skip to content

Commit

Permalink
make noise pkg cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
dhvanipa committed Nov 3, 2023
1 parent 401e034 commit aa54d1e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/noise/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
7 changes: 6 additions & 1 deletion packages/noise/ts/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from "fs";
import path from "path";
// import * as buffer from "buffer";
// const { Buffer } = buffer;

Expand Down Expand Up @@ -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<Perlin> {
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) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/noise/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit aa54d1e

Please sign in to comment.