mathiasbynens / he

A robust HTML entity encoder/decoder written in JavaScript.
https://mths.be/he
MIT License
3.45k stars 254 forks source link

fix: add es module #79

Open sastan opened 3 years ago

sastan commented 3 years ago

This PR adds an es module (he.esm.js). This is currently handcrafted by basically removing the UMD wrapper and adding the exports at the bottom of the file. This file is then references from package.json using the module field. This is in my opinion a non-breaking change.

I hope this can be published soon as it would allow he to be used by packages that are esm based and and bundlers that have difficulties to detect the exported names.

I'd like to have this automated but i could not get the grunt build to run:

Running "shell:process-data" (shell) task
/Users/sastan/Projects/os/he/node_modules/sort-object/index.js:71
                var k = get(sortBy, key)[j++];
                                        ^

TypeError: Cannot read property '0' of undefined
    at sort (..../he/node_modules/sort-object/index.js:71:27)
    at Object.<anonymous> (..../he/scripts/process-data.js:96:35)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3
Warning: Command failed: node scripts/process-data.js
..../he/node_modules/sort-object/index.js:71
                var k = get(sortBy, key)[j++];
                                        ^

Any hint about how to solve this and i would adjust the PR.

Related #76

marcos-castrillo commented 10 months ago

Any news regarding this change? My team is looking forward to seeing it