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

Derive the import namespace from the provider module #786

Merged
merged 2 commits into from
Oct 21, 2024

Conversation

jeffcharles
Copy link
Collaborator

Description of the change

Updates the provider to have a custom section named import_namespace and has the Javy CLI use that custom section to determine what import namespace to use when creating dynamically linked modules.

Why am I making this change?

Part of #768. This change will allow plugins to specify their own import namespaces instead of having to use one set in the Javy CLI. Also arguably, javy-core should be responsible for saying when to bump any version and not the CLI.

I had a little trouble figuring out a logical place to put the derive_import_namespace_from_provider function. I'm putting it in the bytecode module for now. Arguably we could introduce an abstraction around providers with various methods for things like getting a byte slice for writing to disk, performing bytecode compilation, and getting the import namespace. I'll probably need to do that refactoring very shortly to accommodate some changes I want to make to codegen so I'm thinking it makes sense to punt until I'm working on that.

Checklist

  • I've updated the relevant CHANGELOG files if necessary. Changes to javy-cli and javy-core do not require updating CHANGELOG files.
  • I've updated the relevant crate versions if necessary. Versioning policy for library crates
  • I've updated documentation including crate documentation if necessary.

/// The QuickJS provider module version.
provider_version: Option<&'static str>,
/// The import namespace for dynamically linked modules.
import_namespace: Option<ImportNamespace>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason why this can't be import_namespace: ImportNamespace and default to FromProvider? i.e., drop the Option?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funnily enough that was my first implementation. Then I added back the option to bring it closer to how it's currently implemented on main. I'll drop the option and set the default to FromProvider.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, what I'll end up doing is having the provider do something polymorphically instead based on just merging #787.

@jeffcharles jeffcharles merged commit 4a7f0ad into main Oct 21, 2024
7 checks passed
@jeffcharles jeffcharles deleted the jc.derive-import-namespace-from-provider branch October 21, 2024 17:24
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

Successfully merging this pull request may close these issues.

2 participants