How to control order of imports in generated JS
jkelleyrtp opened this issue · comments
Summary
I have a bit of a strange setup.
I'm linking in a module with the module syntax:
#[wasm_bindgen(module = "src/js/web.js")]
extern "C" {
pub type WebInterpreter;
}
And then I have an inline snippet down below:
#[wasm_bindgen(module = r#"class Interpreter extends WebInterpreter {}"#)]
However, when I go to load the page, the generated glue orders the inline snippet above the module, breaking the extends relationship.
import { JSChannel } from './snippets/dioxus-interpreter-js-dce332548ff09d6f/inline0.js';
import { setAttributeInner } from './snippets/dioxus-interpreter-js-dce332548ff09d6f/src/js/web.js';
import { get_form_data } from './snippets/dioxus-web-5003c04febee1e56/inline0.js';
import { get_select_data } from './snippets/dioxus-web-5003c04febee1e56/inline1.js';
import { Dioxus } from './snippets/dioxus-web-5003c04febee1e56/src/eval.js';
Notice how JSChannel from inline0.js is being imported before setAttributeInner in src/js/web.js. And yet in my Rust code they're ordered properly. Is there just no way of getting the order right?
I think they're sorted by the path you're importing from (the final one, e.g. ./snippets/dioxus-interpreter-js-dce332548ff09d6f/inline0.js
). That's just for the sake of deterministic outputs though, not any kind of guarantee.
How come they have to be in two separate snippets in the first place?