-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bundling only the polyfill (no shims) #406
Comments
Hi, and happy to help where I can here @luisherranz. As far as I can tell what you want is just the polyfill features, but without the risk of shim features applying that Wordpress users might rely on downstream causing compatibility problems? So some kind of "lock down" for es-module-shims itself where it goes into a polyfill mode that can't be hooked? This does seem to be mostly compatible with how our configuration model works in that the configuration is read immediately on startup and only applies then. Alternatively we could expose some explicit function like Does this sound like the overall type of direction you are after here? If so we can flesh out the design a little further. |
Yeah, exactly, although it's a bit more difficult because of the way backward compatibility works in WordPress.
So, ideally, we would not ship the shim features at all (if that's possible), or ship a version where they are deactivated by default and there's no way to activate them. So I think this is more a bundling problem than a feature problem. Does that make sense? 🙂 |
If you control the script loading order, you could ensure that es-module-shims is always loaded immediately before a I'm open to treating this as a distribution problem over a configuration problem, just want to be sure. |
We can structure it that way in the code included in WordPress Core, but people can still filter final HTML and remove the
Nice! Any idea of what could the next steps be? I'll happily work on it if you point me in the right direction 🙂 |
How about something along the following lines:
Ideally other than that there shouldn't be a lot of code restructuring - it should mostly just work out through dead code elimination between the builds. We would then end up with the following build
How does that sound? |
There is also prior art here in #258. |
That sounds like a perfect plan, yes. Since you are willing to make a new major version for this, would it also be a good opportunity to take a look at officially supporting conditional loading of the polyfill as well? Do you have any thoughts on how that would work? |
Great to hear. And yes exactly, you're 100% right - once we have a polyfill-only build it can make sense to do the conditional loading optimizations now separate from the feature detection layer. We could tackle both projects together, or do one and then the other. The important thing here will be to ensure that the shim build remains a singular build without any async importing, for that reason I'd expect it might be easier to tackle the polyfill build first then the conditional loading as a separate follow-on PR to achieve this. Please let me know if there's anything I can do at all to help here further @luisherranz. Always happy to hop on a call to discuss any of the work. |
Perfect. Thanks, Guy. I'll take a look at the code and build process as soon as I can and I'll get back to you 🙂 |
@gziolo correctly realized that if we load the That's great news because it means that we can use the current So, thank you so much for your willingness to help us with this, but in the end, it won't be necessary. I'm going to close this issue now as resolved. @gziolo has also been testing an alternative way to load the import map dynamically using As I'm going to close this issue because it is related to the polyfill-only bundling, I'll report our findings in the one that is already opened for dynamic loading: |
@luisherranz thanks for sharing here, this sounds like the right approach to me. |
Hey 👋🙂
I'm leading an initiative to add native support for modules and import maps in WordPress, but to do so, WordPress will have to ship a polyfill for some years.
The problem is that, in WordPress, due to its infinite backward compatibility policy, once a feature is shipped, it cannot be removed. If we ship this polyfill with all the optional shims, we won't be able to remove the polyfill in the future because we won't know if there are any plugins out there that are using one of the shims and could break.
We really like this library and the way it works, but is there a way to bundle only the polyfill without any of the shims without having to fork it?
The text was updated successfully, but these errors were encountered: