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

Bindgen file only generates on Rust code changes #1488

Closed
TheLarkInn opened this issue Feb 14, 2023 · 0 comments · Fixed by #1489
Closed

Bindgen file only generates on Rust code changes #1488

TheLarkInn opened this issue Feb 14, 2023 · 0 comments · Fixed by #1489
Assignees
Labels

Comments

@TheLarkInn
Copy link
Contributor

TheLarkInn commented Feb 14, 2023

Expected Results:

  • Any time I run napi build, the bindgen JavaScript file & .d.ts file should generate

Current Results:

  • If my rust code hasn't changed since a previous run of napi build, I delete all generated assets, and run napi build again, only the .node file is generated.

Upon further inspection, it appears that this is caused by the following code:

napi-rs/cli/src/build.ts

Lines 605 to 609 in 853f52e

const idents = await processIntermediateTypeFile(
intermediateTypeFile,
dtsFilePath,
this.noDtsHeader,
)

Where idents is only populated on file change and:

napi-rs/cli/src/build.ts

Lines 816 to 822 in 853f52e

if (distFileName && idents.length) {
const template = createJsBinding(localName, packageName)
const declareCodes = `const { ${idents.join(', ')} } = nativeBinding\n`
const exportsCode = idents.reduce(
(acc, cur) => `${acc}\nmodule.exports.${cur} = ${cur}`,
'',
)

Where the ident check occurs.

I think we need to be calculating all idents each run, and not just changed.

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

Successfully merging a pull request may close this issue.

2 participants