httptoolkit / react-reverse-portal

React reparenting :atom_symbol: Build an element once, move it anywhere
https://httptoolkit.com
Apache License 2.0
879 stars 29 forks source link

Adds ES5 distribution #5

Closed spong closed 4 years ago

spong commented 4 years ago

This PR adds an ES5 distribution (with source map) to dist/web and sets the package.json browser field to point to it.

This keeps the previous typescript configuration and commonJS/ES Module distributions in tact, and provides a new build-web script that uses the Babel CLI to transpile from the ESM source.

Running npm run build will build all three distributions.

spong commented 4 years ago

I had first tried using just the typescript compiler to keep things simple as you said, but was unable to get an ES5 distribution that IE11 would load and so reverted to a babel config I knew would work.

I just gave it another try though and was able to put together a tsconfig that works (PR updated with these changes). That said, using "module": "umd" results in IE11 erroring out with cannot find module 'react'. The only module setting I could get it to work with was "es6", so that's the rationale there.

As for naming (the es5 tsconfig & corresponding dist folder), not sure what's best here since you had them based by module type -- thoughts?

pimterry commented 4 years ago

Thanks, with those changes this looks great to me. I think web is a good target name, that's fine.

I've updated the tsconfig name from es5 to web so that matches too - I'll merge now and release as 1.0.4 imminently. Let me know if you have any other trouble, thanks for contributing! :+1:

spong commented 4 years ago

Perfect -- thanks so much @pimterry! 🙂 I've updated to 1.0.4 and verified IE11 backwards compatibility + no issue in Chrome/FF/Safari, so all is good! 👍