-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
As of right now the NPM package @refilelabs/image is built via wasm-pack build --target web --release.
While this works fine for browser-based applications, it causes compatibility issues in other environments such as node (see #6) or even extensions (see blog article (Chinese)).
To improve compatibility, we could:
- Publish multiple targets under corresponding directories, allowing users to import based on their environment:
import { ... } from "@refilelabs/image/browser"; import { ... } from "@refilelabs/image/node";
- Use the
exportsfield inpackage.jsonto define separate entry points for different environments:This way, bundlers automatically pick the correct version.{ "exports": { "browser": "./browser/index.js", "node": "./node/index.js", "default": "./browser/index.js" } } - Switch to a more general
wasm-packtarget, such as:bundler: Works well with Webpack/Rollup and is more flexible.no-modules: Provides maximum compatibility but requires manual setup.nodejs: A separate build for Node.js.
Any feedback or ideas are very welcome. While this most likely will cause a breaking change, I think the benefits will be well worth it in the long run.
@Trojanking123, since you've researched this topic, I'd really appreciate your input!
P.S. this seems to be a highly discussed topic (see drager/wasm-pack#313). Currently, the primary solution to this seems to be building multiple times and then merging into one package.
Reactions are currently unavailable