Skip to content

Fix rename option in qjs attribute when with function attribute not w… #428

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion macro/src/module/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ pub(crate) fn expand(options: OptionList<ModuleOption>, mut item: ItemMod) -> Re
let mod_name = module.name.clone();

module.export(
name,
js_name.clone(),
f.sig.ident.span(),
quote! {
_exports.export(#js_name,#mod_name::#ident)?;
Expand Down
11 changes: 10 additions & 1 deletion tests/macros/pass_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ mod test_mod {
1 + 1
}

#[rquickjs::function]
#[qjs(rename = "renamedFoo")]
pub fn renamed_foo() -> u32 {
1 + 2
}

/// You can make items public but not export them to JavaScript by adding the skip attribute.
#[qjs(skip)]
pub fn ignore_function() -> u32 {
Expand All @@ -98,10 +104,13 @@ fn main() {
ctx.clone(),
"test2",
r"
import { foo,aManuallyExportedValue, aConstValue, aStaticValue, FooBar } from 'test';
import { foo, renamedFoo, aManuallyExportedValue, aConstValue, aStaticValue, FooBar } from 'test';
if (foo() !== 2){
throw new Error(1);
}
if (abc() !== 2) {
throw new Error(1);
}
if (aManuallyExportedValue !== 'Some Value'){
throw new Error(2);
}
Expand Down
Loading