open-policy-agent / npm-opa-wasm

Open Policy Agent WebAssembly NPM module (opa-wasm)
Apache License 2.0
139 stars 43 forks source link

make this an ES module #38

Closed srenatus closed 2 years ago

srenatus commented 3 years ago

Also from #36:

This module is based on commonjs and considering ES Modules is the standard, providing support for that would be great. Currently, working with esModuleInterop and importing like this:

import opa from "@open-policy-agent/opa-wasm";
const { loadPolicy } = opa;
srenatus commented 3 years ago

💭 Would using some clever CDN like https://www.skypack.dev/ solve this? I.e. convert to ESM on the fly?

srenatus commented 3 years ago

Parceljs.org seems like it's both able to do that and not too difficult to handle. I'll give it a try.

srenatus commented 3 years ago

@tvvignesh if you're still using this, I'd appreciate feedback on the draft PR ☝️ Does it do the trick?

jorgecasar commented 2 years ago

I can help with that. Are you agree to propose a PR?

srenatus commented 2 years ago

@jorgecasar yeah that would be great. When playing with microbundle (#87), it seemed like you could have both, a commonJS and an ES module. I think that's what we'd want? 🤔

jorgecasar commented 2 years ago

I see that tests are not working. In my case the results are: Test Suites: 5 failed, 2 passed, 7 total. I guess we have to fix test before migrate to ESM to be sure we don't break anything.

I was using nodejs 16.9.1

srenatus commented 2 years ago

So we're using 12 and 14 in CI. Is it time to enable 16? 🤔 Can you share what breaks for you? (Otherwise I'll try it next week.)

jorgecasar commented 2 years ago

I just run npm test and there are some issues with circular references in JSON. I will copy the full log ASAP

srenatus commented 2 years ago

Isn't this done? Hmm.