stealjs / steal-tools

Build easy. Load fast.
https://stealjs.com/docs/steal-tools.html
MIT License
67 stars 23 forks source link

Create dev bundles of web compatible ES modules #1034

Open matthewp opened 6 years ago

matthewp commented 6 years ago

Note, this was previously an RFC.

Summary

Provide a tool that will transpile 3rd party packages so that they can be used with <script type="module">.

Motivation

The primary reason is to provide a way for developers to take advantage of <script type="module"> while still remaining within the Steal ecosystem and taking advantage of Steal's tooling (especially steal-tools and its multi-build).

Speed

Loading a Steal application in development can be slow. This is for a number of reasons:

Some of this problems can be remedied easily, some would require a significant amount of work, but probably it would never be possible to match the browser's loading speed.

Compatibility

Since the native <script type="module"> cannot be extended (except through ServiceWorker fetch hook), Steal is essentially incompatible with the use of <script type="module">. This forces developers to choose either Steal (ands its features) or choose the native loader.

Impact

This will be an alternative to using steal.js in development. steal-tools should still work for production builds.

Design

Note: I'm calling this tool steal-tools web-bundle below but that is just a code name, open to changing it.

I'm proposing a new tool in the Steal ecosystem that makes a project web-compatible (compatible with <script type="module">).

This tool can be used a couple of different ways:

steal-tools web-bundle can-stache

This will look for the can-stache package and:

You can also bundle all of your project's dependencies by running:

steal-tools web-bundle

This will load your package.json main and compile any child packages.

Plugins

Since <script type="module"> does not have any hooks, it's not possible to load non-JavaScript modules with it. There are a couple of possible workarounds:

These options have strengths and weaknesses. For this reason I would consider plugins to be out-of-scope for the first version of this project, and something we add afterwards.