Web-compatible ES module build
See original GitHub issueHey @developit! I was wondering if you would be open to a new build that is ES modules compatible for the web? I have a branch of this working locally. It uses a small custom babel plugin that turns stuff like './util'
into './util.js'
;
It works in Safari:
In my branch I run the babel plugin and put everything into dist/es/
. This took me like 5 minutes, super easy. If you are open to adding this, there are a couple of options:
dist/es
or some such folder
This would be the way I did it for my proof of concept. This means that browser users would use Preact with something like:
import { Component } from './node_modules/preact/dist/es/preact.js';
This would require no changes to your src/
codebase. If you wanted to keep src/ the way it is, this is the way to go.
preact.js
in root folder
A bit nicer solution for web users would be if you added preact.js
to the root folder and all it did was:
export * from './src/preact.js';
Or it could point to './es/dist/preact.js'
. If you are willing to change your src/ modules to add the .js
at the end and point to exact files in that way, then no Babel transformations would be needed.
Users would only have to do:
import { Component } from './node_modules/preact/preact.js';
Which is just a tiny bit easier.
Let me know what you think! cc @treshugart
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:8 (7 by maintainers)
Top GitHub Comments
Why ES5? If someone is using this bundle they are either using a module-compat browser or are using a build tool where they can transpile how they wish, right?
Is that an issue specific to Chrome? If so, does it still apply when using the new V8 engine (Ignition + TurboFan) I wonder?