Skip to content

What to do about the --browser flag? #1332

Open
@alexcrichton

Description

@alexcrichton

With RFC 6 now merged and implemented, along with a tweak or two, we now have the following output modes:

  • no flags specified - generate "bundler compatible" as well as future-compatible output where wasm files are assumed to be an ES module and everything is an ES module
  • --nodejs - generate CommonJS imports as well as assuming a synchronous instantiation is ok. Also assumes node.js for various support APIs.
  • --web - generates an ES module which exports a function to manually instantiate the wasm module. Intended for raw inclusion on web pages today.
  • --no-modules - like --web, except incompatible with js snippets and provides a global instead of an ES module.

In addition to all these flags we have this weird --browser flag sitting on the site. The only real purpose of this flag any more is to indicate that when no flags are specified (generating "bundler compatible output") the JS should assume that node.js isn't being used and browser APIs are always available. This is a slight optimization over not passing the flag as it allows us to elide the check for things like "where is TextDecoder?" and such.

The --browser flag has a pretty unfortunate name to say the least, being pretty confusing with the other flags. Should we keep the use case of slimming the JS by a few bytes? Should this just be deprecated and removed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions