coolaj86 / TextEncoderLite_tmp

Polyfill for the Encoding Living Standard's API
Apache License 2.0
30 stars 19 forks source link

Node export issue #11

Open brettz9 opened 6 years ago

brettz9 commented 6 years ago

https://github.com/coolaj86/TextEncoderLite/blob/e1e031b4a7fb89c35629340a61a06ec4f50ce7cb/text-encoder-lite.js#L137-L143

The last line in the block is erasing the previous so only TextDecoderLite is exported for Node.

brettz9 commented 6 years ago

Or maybe the issue is due to this not having published to npm...

Oh, and the README should not refer to require('TextDecoderLite') but require('text-decoder-lite')

achimnol commented 6 years ago

I was just wondering why import { TextEncoderLite } from 'text-encoder-liter' is not working and discovered that those last lines are not in my npm-installed version. It has only:

if(typeof module === "object" && module) {  
  module.exports = TextDecoderLite
}
himdel commented 6 years ago

Yes, this is a bug... it's very surprising to do import TextEncoderLite from 'text-encoder-lite' and get something which doesn't have an encode method :).

It's also suprising to do const TextEncoderLite = require('text-encoder-lite').TextEncoderLite and get undefined, because it still returns just TextDecorerLite.

EDIT: this should be resolved by https://github.com/coolaj86/TextEncoderLite/pull/10 But no releases yet :(

Ruffio commented 6 years ago

@himdel would this PR (https://github.com/coolaj86/TextEncoderLite/pull/12/commits/23d8624b8a3e7d27b7bb55e06733eeecb1e0e19f) resolve the issue?

brettz9 commented 6 years ago

@Ruffio : That commit was only for the README... All that should need to be done to fix this is for the author to do a npm publish...