beaugunderson / ip-address

πŸ’» a library for parsing and manipulating IPv4 and IPv6 addresses in JavaScript
http://ip-address.js.org/
MIT License
580 stars 73 forks source link

build: include esm and cjs builds for better compatibility #120

Closed napei closed 3 years ago

napei commented 4 years ago

I recently started using this library in Angular, which like many other build optimisers prefers ESModules instead of CommonJS to be able to tree-shake the source code, and be overall more efficient. This change essentially specifies a CommonJS build and an ESM build separately to be used by whichever.

I have not tested this change rigorously as I don't work with npm packages too much.

Perhaps this is something that can be investigated?

pcafstockf commented 3 years ago

Anything I can do to help the PR along?

beaugunderson commented 3 years ago

i missed this one entirely--will take a peek; ping me in a day if i don't report back :)

napei commented 3 years ago

i missed this one entirely--will take a peek; ping me in a day if i don't report back :)

Awesome! I should have made an issue to go along with it. I'll rebase the branch and get it fixed again.

I also ran this with node 15, which uses npm 7 which has a different package-lock format. I removed that commit, but, adding node 15 to travis wouldn't hurt.

Also, might need "type": "module" in package.json to make tests run. I switched the tests to use jest which is a more standard test library for typescript. Everything still runs the same, but it properly transpiles code without complaining about modules for tests. If this needs to be removed from this PR let me know, however without effort I didn't have time for I couldn't get tests to work as they were.

codecov[bot] commented 3 years ago

Codecov Report

Merging #120 (0aeeebe) into master (a2e039a) will decrease coverage by 0.07%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #120      +/-   ##
==========================================
- Coverage   98.04%   97.97%   -0.08%     
==========================================
  Files           9        9              
  Lines         562      493      -69     
  Branches       82       81       -1     
==========================================
- Hits          551      483      -68     
- Misses          3        4       +1     
+ Partials        8        6       -2     
Impacted Files Coverage Ξ”
lib/ipv6.ts 97.88% <0.00%> (-0.26%) :arrow_down:
lib/ipv4.ts 100.00% <0.00%> (ΓΈ)
lib/address-error.ts 80.00% <0.00%> (+13.33%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data Powered by Codecov. Last update a2e039a...0aeeebe. Read the comment docs.

napei commented 3 years ago

ping me in a day if i don't report back :)

@beaugunderson just checking in πŸ‘‹

napei commented 3 years ago

@beaugunderson ping πŸ””

Just checking in πŸ˜„

beaugunderson commented 3 years ago

@napei thank you! appreciate the ping πŸ™ gonna look at the test failures now and will get this merged

beaugunderson commented 3 years ago

thanks @napei, will release this as 8.0.0 shortly and include some dependency updates as well

beaugunderson commented 3 years ago

closing in favor of #138, sorry for the delay here and thank you for the PR!