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

Ensure that relative imports from module import are module-relative #2033

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rmja
Copy link

@rmja rmja commented Jan 20, 2025

Consider the Engine configuration with enabled modules:

options.EnableModules("/modules-directory");

where the contents of /modules-directory is:

/modules-directory/my-module/index.js
/modules-directory/my-module/helper-file.js

The content of the index file references the helper file is:

export * from "./helper-file.js";

Note that the path to ./some-file.js is relative to the index file.

If we then do

engine.Modules.Add("my-module", File.ReadAllText("/modules-directory/my-module/index.js"));

Then when calling into my-module, the some-file.js file should be found from the /modules-directory/my-module directory, and not from /modules-directory.

@rmja
Copy link
Author

rmja commented Jan 20, 2025

Okay, I can see from the failing test that this is actually the intended behavior?

@lahma
Copy link
Collaborator

lahma commented Jan 20, 2025

Generally the test cases establish the current API contract so I guess this would be a breaking change, unless the old behavior can be considered incorrect.

One option is to provide more extension points if needed so that you can achieve your goal.

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