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

Unable to Compile with Webpack #300

Closed
sbowler opened this issue May 30, 2024 · 3 comments
Closed

Unable to Compile with Webpack #300

sbowler opened this issue May 30, 2024 · 3 comments

Comments

@sbowler
Copy link
Contributor

sbowler commented May 30, 2024

I have a NodeJs webserver that currently utilizes Webpack 5.75.0. Due to the way this library dynamically requires/imports the needed dll file, I receive a warning from Webpack
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
./node_modules/node-api-dotnet/init.js
@ ./node_modules/node-api-dotnet/index.js 1:19-36

This ends up with a runtime error when I try to require node-api-dotnet An unknown error occurred: Error: Cannot find module '....WebServer/win-x64/Microsoft.JavaScript.NodeApi.node'

From what I've read it sounds like it's generally bad practice to dynamically require files since it can cause issues like this, though I'm not sure what a better approach would be. I've been trying to figure out a way to work around the issue and didn't see anything in your documentation or tracked issues about this. Any help would be appreciated.

@jasongin
Copy link
Member

There is some discussion of a similar issue at #264 (comment)

I think the code could be changed to use non-dynamic requires, it would just be more verbose.

@sbowler
Copy link
Contributor Author

sbowler commented May 30, 2024

I thought that as well, but it is a bit different or potentially a different solution dealing with Electron.

I think perhaps a switch statement to include the correct library based on the different variables might work better, but as you said would be much more verbose.

@jasongin
Copy link
Member

Fixed by #303

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

No branches or pull requests

2 participants