-
Notifications
You must be signed in to change notification settings - Fork 215
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
Distribute an EcmaScript Module #231
Comments
Looks like this was added in 0.6.0 a while back: https://github.com/mozilla/webextension-polyfill/releases/tag/0.6.0 |
Fixed by #202 |
@eritbh Making it "loadable as an ES module" doesn't make it an actual ES module. If it can be loaded with // with webpack and other similar bundlers
var browser = require("webextension-polyfill");
// or using requirejs without a build step
require(["webextension-polyfill"], function (browser) {
console.log(browser);
}); I would also expect the following to work import browser from "./webextension-polyfill.js"; From the
It would be better if there was a proper ES module in the Interop between commonjs/AMD and ESM is inconsistent because there is no way to create an ES module that can be loaded as a script. I don't think it would be too difficult to add a proper ES module to the It could just be a simple wrapper like the following export default ((factory) => {
var mod = { exports: {} };
return factory(mod, mod.exports);
})((module, exports) => {
// ...
}); |
That's interesting - what sort of situation might cause you to want In any event, it looks like I was wrong about this being fixed already - I wasn't clear on what you were asking for, and the issue @Rob--W linked as "fixing" this one is from before this issue was even opened. |
Distributing a proper ES module makes it easier to work with modern build systems and it would make more sense if the polyfill behaved the same with all module formats. |
Since the web is moving towards EcmaScript modules (and most browsers supported by this polyfill also support modules) I believe that an ESM version of the script should be included in the
dist
folder, e.g.browser-polyfill.esm.js
.This could be easily done by wrapping the script with a wrapper for CommonJS (like Rollup's CommonJS plugin does it), and wouldn't be a breaking change.
The text was updated successfully, but these errors were encountered: