Skip to content
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

Allow Redux to be imported as type="module" #3389

Closed
wants to merge 2 commits into from
Closed

Allow Redux to be imported as type="module" #3389

wants to merge 2 commits into from

Conversation

Wildhoney
Copy link
Contributor

@Wildhoney Wildhoney commented Mar 31, 2019

We'd all love to import Redux as type="module" natively in the browser, however the process.env and the symbol-observable ponyfill make that problematic.

By checking for the existence of symbol-observable ourselves — rather than delegating it to a module unless we really need to — as well as checking for typeof process we can make it happen.

Redux is a simple enough library. Let's all be standards compliant, friends (or as close as we can at this point)! 🍻

Discuss...

@Wildhoney Wildhoney changed the title Allowed Redux to be imported as type="module" Allow Redux to be imported as type="module" Mar 31, 2019
@netlify
Copy link

netlify bot commented Mar 31, 2019

Deploy preview for redux-docs ready!

Built with commit 2cb518d

https://deploy-preview-3389--redux-docs.netlify.com

@timdorr
Copy link
Member

timdorr commented Apr 1, 2019

There is already a mjs build provided by #3143

@timdorr timdorr closed this Apr 1, 2019
@Wildhoney
Copy link
Contributor Author

Thanks @timdorr

I saw the *.mjs file but discounted it without testing it, as it's typically a Node.js convention. I've not seen *.mjs being used as a browser module before anywhere else.

Do you think we need to document its existence? As the current installation section in the README doesn't appear to make reference to it.

Could we also not unify the module files (es/redux.js and es/redux.mjs), which was my attempt with this PR? That way we could reference a single file in the package.json file. At the moment the *.mjs has no reference in the package.json – that coupled with no README mention makes it terribly difficult to locate.

@timdorr
Copy link
Member

timdorr commented Apr 1, 2019

The mjs file is built in production mode only, so it cannot replace the standard module, which supports both.

Some documentation on it's existence would be good. There isn't yet a package.json field for it that we can use safely, so an entry in the docs would be a good start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants