-
Notifications
You must be signed in to change notification settings - Fork 191
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
Edge, IE11 broken. Invalid bundling and exports. #438
Comments
I have written up a PR that addresses these issues and also allows support for more environments, which is logical considering this library claims to be isomorphic - which is actually not the case at present. Also claims IE11 and edge support which is also not the case. |
In the end i abandoned the PR #439 as its going to take significant work to refactor the library. Id be happy to do it, just need assurance that this would be accepted first. |
Workaround for those Webpack / bundler users who want support for Edge and IE 11 you can simply add the "browser" bundle (umd) as an external dependancy. Bundling it via Webpack e.g. /**
* Webpack config object
* @return {Object}
*/
module.exports = (env, argv) => {
// ...
externals: {
wpapi: 'WPAPI'
},
// ...
}; Then import as usual: import WPAPI from "wpapi"; :-( My suggestion to the authors would be to write the library in ES then transpile to CJS and UMD. That way we are working from best case to worst case, smallest footprint. |
If you want to avoid editing the Webpack config and/or including it using a script tag you can also import the browser bundle directly: import WPAPI from 'wpapi/browser/wpapi.min'; |
That works although not a great idea as it raises other issues |
We recently release an early version of https://github.com/wp-headless/fetch that is now being used in production. It's not an easy decision to fragment the ecosystem when there are other offerings. We believe our approach is significantly different enough to warrant this risk. We did so for the following reasons: * Long unresolved [browser issues](WP-API/node-wpapi#438) * Bloated [packages size](https://bundlephobia.com/result?p=wpapi@0.12.1) * No [tree-shakable](https://webpack.js.org/guides/tree-shaking/) ESM or CJS build available * Opinionated API that attempts to do more then is needed. * Lack of automated browser testing and coverage * + more wp-headless/fetch will be a valuable option to the community and therefore should be listed. Thanks! :-)
Currently bundling for Webpack environments / module environments is broken. In the Webpack build the library is build and transpiled - although in
package.json
it only points to the root (unstranspiled)/wpapi.js
file. This is okay for most modern browsers as - only by chance - the features are supported.Although this is not the case for Edge and IE11 both not supporting the object rest spread operator.
In summary the build is essentially broken for browsers environments - node works.
This long standing issue: #426 outlines the case with specific errors.
The text was updated successfully, but these errors were encountered: