-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix webpack when using browser_wasi_shim as dependency #13
Conversation
CommonJS style exports were previously used in index.js despite being an ESM module. Switching to the ESM export syntax fixes webpack. Fixes #12
@brandonchinn178 @bhelx could you please take a look? |
Looks great! Although you could make it even more concise: export { WASI } from './wasi.js'
... Also, I didn't want to make another issue for this, but could you also remove the console.log calls, or at least put them behind a debug flag? |
Yeah, it definitely should not be mixed. We should go one way or the other. It can be tricky to get something to work in both module formats without a build step though. Typically what I do is use esbuild and provide different entries for CJS and ESM. Will this work for both @brandonchinn178 ? |
No, it wont work for both, but the question is moot right now because A more production-ready deployment would involve a build step outputting both ESM and CJS artifacts and updating package.json to point to the relevant files according to module type. It's the annoying state of the JS ecosystem, but that's what it is. To sum up:
|
@brandonchinn178 thanks for explaining. I'm okay with merging if it unblocks you. I think I can work around this in my build step.
I don't know a ton about JS but this is my interpretation as well. There isn't currently a way I've found to make a universal module without some kind of build step. I've found esbuild to be a pretty simple dependency to use that isn't as massive as webpack. I can also work on the build step, but I know @bjorn3 was hoping to avoid that so I'd so I leave it to him to make the final call. |
But keep them in case they are ever necessary
Done |
Neat.
I'm fine with having a build step for the module published on npm. I just want to be able to do local development without requiring any build step. |
Thanks @brandonchinn178 !
@bjorn3 I'll see if i can figure this out. In my experience once you add a build step it takes over, but I'll test it out. |
Should I merge this and publish a new release or should I wait on this build step getting added? |
I think you're good to merge. I can pin on the previous version or send a follow up if it causes a problem. |
Published as v0.2.3 |
Local development should be unaffected. The build step should just add more files, not change any of the existing ones, so you should be able to work on it as usual. Thanks for the quick turnaround! |
CommonJS style exports were previously used in index.js despite being an ESM module. Switching to the ESM export syntax fixes webpack.
Fixes #12