Skip to content
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

Use import() instead of require() for commonjs/esmodule support #162

Closed
jasikpark opened this issue Oct 27, 2022 · 4 comments
Closed

Use import() instead of require() for commonjs/esmodule support #162

jasikpark opened this issue Oct 27, 2022 · 4 comments

Comments

@jasikpark
Copy link

jasikpark commented Oct 27, 2022

I'm trying to get a fuzz harness set up for https://github.com/natemoo-re/ultrahtml but I'm running into a problem with the fact that the module is written as an esmodule instead of a commonjs module

It'd be great if jazzer.js supported es modules natively, ex:

export function fuzz() {}

instead of module.exports.fuzz = function() {} or using TS to generate commonjs

https://github.com/jasikpark/fuzz-ultrahtml

@bertschneider
Copy link
Contributor

Actually, we already worked on this, but it didn't make it into the main branch. This issue is a good reminder to continue switching over to import.

In the meantime you could try out the version on branch es-module-import.

@jasikpark
Copy link
Author

Oooh, great! Not having es module support has been one of the initial problems for me trying to use this and jsfuzz w/ es module packages w/o bundling them fully

@bertschneider
Copy link
Contributor

We just merged a first step towards general ESM support. The remaining quirk is the instrumentation of ESM files, as intercepting loaded code requires custom Node.js loaders. We will continue to investigate this, though.

In the meantime, could you please try out the current version on main? The next release will probably be due early next year.

@jasikpark
Copy link
Author

I'll close this as https://github.com/jasikpark/fuzz-prettier is using the typescript jest integration happily, import ESM packages as well 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants