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

Map paths to import roots in Rhai.toml #80

Open
schungx opened this issue Aug 7, 2022 · 2 comments
Open

Map paths to import roots in Rhai.toml #80

schungx opened this issue Aug 7, 2022 · 2 comments
Labels

Comments

@schungx
Copy link
Collaborator

schungx commented Aug 7, 2022

Some users may organize their module scripts directly under the source directory, but resolve them into different paths at runtime.

For example, if we have:

src/
  main.rhai
  modules/
    foo/
      baz/
        main.rhai
    bar/
      main.rhai

During runtime, the user may want imports to work this way:

import "baz" as baz;
import "bar" as bar;

So can something like this be put into Rhai.toml:

[modules]
foo = "./modules/foo"
bar = "./modules/bar"
baz = "./modules/foo/baz"
@tamasfe tamasfe added feature A-HIR Area: HIR labels Aug 7, 2022
@tamasfe
Copy link
Member

tamasfe commented Aug 7, 2022

Currently import remapping is not exposed in the HIR, but it is planned.

Maybe we could let the user do it via rhai scripts themselves from the config, what do you think?

@schungx
Copy link
Collaborator Author

schungx commented Aug 8, 2022

Maybe we could let the user do it via rhai scripts themselves from the config, what do you think?

Sort of like a build script? Possible, but I think a bit cumbersome for users. And, in order to provide the flexibility, we'd need to define a complete config API in Rhai.

So maybe something simple that takes the cue from Node and WebPack config options... that might already be enough.

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

No branches or pull requests

2 participants