Skip to content

Provide a way to detect wasm-pack target via cfg #795

Open
@RReverser

Description

@RReverser

💡 Feature description

Currently, there is no way to do perform conditional compilation based on the --target passed to wasm-pack.

It would be great if wasm-pack would pass it on via --cfg to Rust (should be easy enough to pass it in RUSTFLAGS), so that users could check this target in their code as any other conditional compilation attribute.

💻 Basic example

pub const HAS_ESM_SUPPORT: bool = cfg!(any(
  wasm_pack_target = "bundler",
  wasm_pack_target = "web"
));

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions