zazuko / clownface

Simple but powerful graph traversing library for RDF
https://zazuko.github.io/clownface/
37 stars 8 forks source link

feat: natively support browser environment (dual package) #44

Closed tpluscode closed 1 year ago

tpluscode commented 4 years ago

Here's how we could have clownface natively support the browser by going ES modules

All in all not much changed. Mostly it is just replacing require with import and use named exports instead of exports = to avoid the weirdness for require().default.

All of the source code has been renamed to .mjs and the commonjs is compiled with babel on prepack. Thus, the default for the package is still node-native, albeit v12+.

In the browser, using rollup/webpack/etc and in type: module projects modules will come first.

@rdfjs/ dependencies have been replaced with @rdf-esm forks. Those are module by default but simply re-export the originals from their index.cjs. Hence again, this package should have not impact on node as long as v12 or newer is used.

codecov-commenter commented 4 years ago

Codecov Report

Merging #44 into master will increase coverage by 0.07%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #44      +/-   ##
==========================================
+ Coverage   98.18%   98.26%   +0.07%     
==========================================
  Files           9       10       +1     
  Lines         276      865     +589     
  Branches        0      150     +150     
==========================================
+ Hits          271      850     +579     
- Misses          5       13       +8     
- Partials        0        2       +2     
Impacted Files Coverage Δ
index.mjs 100.00% <100.00%> (ø)
lib/Clownface.mjs 99.34% <100.00%> (ø)
lib/Context.mjs 98.17% <100.00%> (ø)
lib/fromPrimitive.mjs 100.00% <100.00%> (ø)
lib/inArray.mjs 100.00% <100.00%> (ø)
lib/languageTag.mjs 100.00% <100.00%> (ø)
lib/namespace.mjs 100.00% <100.00%> (ø)
lib/term.mjs 86.95% <100.00%> (ø)
lib/toArray.mjs 100.00% <100.00%> (ø)
lib/toTermArray.mjs 100.00% <100.00%> (ø)
... and 9 more

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 b1a4500...68e754c. Read the comment docs.