diff --git a/package.json b/package.json index 1df2045..98143f5 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "format": "prettier --write .", "format:check": "prettier --check .", "lint": "tsc -p tsconfig.json --noEmit && eslint src", - "build": "npx build --package=@zenfs/core --globalName ZenFS_Emscripten --entry src/index.ts", + "build": "npx build --package=@zenfs/core --globalName ZenFS_Emscripten --entry src/index.ts --", "build:docs": "typedoc --out docs --name 'ZenFS Emscripten' src/index.ts", "prepublishOnly": "npm run build", "postinstall": "patch-package" diff --git a/src/backend.ts b/src/backend.ts index 6411133..2668f38 100644 --- a/src/backend.ts +++ b/src/backend.ts @@ -6,7 +6,6 @@ import { File } from '@zenfs/core/file.js'; import { FileSystem, FileSystemMetadata, Sync } from '@zenfs/core/filesystem.js'; import { FileType, Stats } from '@zenfs/core/stats.js'; import { Buffer } from 'buffer'; -import './emscripten.js'; /** * @hidden diff --git a/src/emscripten.ts b/src/emscripten.ts new file mode 100644 index 0000000..4a088cb --- /dev/null +++ b/src/emscripten.ts @@ -0,0 +1,10 @@ +/* + This is for types only. + By exporting a named export, and using `import type`, we avoid build errors +*/ + +import 'emscripten'; + +import EmFS = FS; + +export type { EmFS }; diff --git a/src/plugin.ts b/src/plugin.ts index f834cd7..5912e52 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -1,7 +1,5 @@ import zfs, { Errno, parseFlag, type Stats } from '@zenfs/core'; -import 'emscripten'; // Note: this is for types only. - -import EmFS = FS; +import type { EmFS } from './emscripten.js'; interface Mount extends EmFS.Mount { opts: { root?: string };