pladaria / reconnecting-websocket

Reconnecting WebSocket. For Web, React Native, cli (Node.js)
MIT License
1.22k stars 197 forks source link

Adding -mjs.js build to support polymer-cli #88

Closed cloudily closed 5 years ago

coveralls commented 5 years ago

Coverage Status

Coverage remained the same at 94.309% when pulling 151b7456c35417c5602c7731cf4f163edfc96b2c on cloudily:feature-polyer_cli_support_for_mjs into f67d5c2ccedae5f23605286cf513525396c1eb18 on pladaria:master.

pladaria commented 5 years ago

Hi, thank you for this PR

Before accepting it I need some more context. Why do you need this?

How does polymer-cli know about the newly created artifact? It is not listed in package.json. It is this following some kind of naming convention?

Thanks

cloudily commented 5 years ago

Hi @pladaria,

The mjs extension has not been formalized yet. It is currently recognized by node, but not by some build tools. For example, the polymer-cli throws an error with the unrecognized mjs extension. This is to provide build tools a way to interpret these files as they relate to ES imports. Please let me know if you have any further questions.

When importing into the frontend, we use the following syntax:

import ReconnectingWebSocket from 'reconnecting-websocket/dist/reconnecting-websocket.mjs';

This currently fails build tools because of the mjs extension, hence the addition. I didn't want to change it for everyone, as it would be a breaking change.

pladaria commented 5 years ago

All clear! Thank you for your explanation

pladaria commented 5 years ago

published 4.1.10 with that change

cloudily commented 5 years ago

Thanks, @pladaria