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

[Feature]: Support CommonJS modules #560

Open
notanaverageman opened this issue Jan 14, 2025 · 2 comments
Open

[Feature]: Support CommonJS modules #560

notanaverageman opened this issue Jan 14, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@notanaverageman
Copy link

Why is this needed?

I'm using Goja as the JavaScript runtime and it doesn't support ES modules. When I try to use this library with moduleResolution: "node" and module: "commonjs" it gives the following error:

Cannot find module '@grafana/grafana-foundation-sdk/timeseries' or its corresponding type declarations.
  There are types at '.../node_modules/@grafana/grafana-foundation-sdk/dist/timeseries/index.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.

What would you like to be added?

CommonJS support for module resolution.

@notanaverageman notanaverageman added the enhancement New feature or request label Jan 14, 2025
@mikaello
Copy link

mikaello commented Jan 14, 2025

I noticed that there is a pull request to implement module support in Goja, but it appears to be delayed due to time constraints on the maintainer's side. Grafana has forked Goja into Sobek and has merged the module support there. Perhaps migrating to Sobek could help resolve your issue?

@notanaverageman
Copy link
Author

Sobek maintainers doesn't have a short term plan to make ES modules integration easier: grafana/sobek#49 (comment)

While in the future we might make a project simialr to goja_nodejs, the current purpose of Sobek is to compliment k6 development.

I would like to pull out some code from k6 and make it generally available for Sobek users to just use it, but this is unfortunately not in the current priority list and likely will require some changes. Some of those changes are already kind of underway for different reasons, so 🤷

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

No branches or pull requests

2 participants