Skip to content

Support jsnext:main and module fields #862

@dvdzkwsk

Description

@dvdzkwsk

This is fairly low on the priority list, especially since v1.0.0 is still looking to be shipped, but I wanted to document it for record keeping.

It would be great for SUIR to provide a bundle that maintains ES6 imports/exports so that bundlers that natively understand ES6 modules (webpack 2, rollup) can tree shake its usage in order to produce smaller bundles. Adding support for babel-plugin-lodash is already a great start, especially for webpack 1.0 and similar; this change would take it a step further by allowing bundlers to perform the same thing natively without the overhead of additional tooling.

Note: it's important that the code still be preprocessed with babel, because we should not assume anything else about the user's environment.

I believe that this is important piece of functionality, especially as the library grows, because it means that users don't have to be as concerned about the library's weight as a whole and can reap the benefits of targeted bundles without additional work on their part, especially as more bundlers implement tree shaking natively.

See:

Steps

  1. Import SUIR in a bundler that understands ES6 modules.
  2. Do not use a plugin to transform imports (such as babel-plugin-lodash)

Expected Result

Unused SUIR code should not be included in the final bundle.

Actual Result

All SUIR code is put into the bundle regardless of whether or not it was used.

Version

all

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