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

Webpack does not work with native dependencies. #3569

Open
SamHoque opened this issue Dec 19, 2023 · 5 comments
Open

Webpack does not work with native dependencies. #3569

SamHoque opened this issue Dec 19, 2023 · 5 comments
Labels

Comments

@SamHoque
Copy link

ts-node .erb/scripts/check-native-dep.js && electron-builder install-app-deps && npm run build:dll

Webpack does not work with native dependencies.
flowbite-react is a native dependency and should be installed inside of the "./release/app" folder.
First, uninstall the packages from "./package.json":
npm uninstall your-package
Then, instead of installing the package to the root "./package.json":
npm install your-package
Install the package to "./release/app/package.json"
cd ./release/app && npm install your-package
Read more about native dependencies at:
https://electron-react-boilerplate.js.org/docs/adding-dependencies/#module-structure

@SamHoque SamHoque added the bug label Dec 19, 2023
@leohxj
Copy link

leohxj commented Dec 30, 2023

does your module use in renderer or main?

native dependencies works with main process.

@leohxj
Copy link

leohxj commented Dec 30, 2023

and flowbite-react is looks like a UI framework, it has native dependency?
image

@SamHoque
Copy link
Author

SamHoque commented Jan 7, 2024

I am using it in the renderer

@SamHoque
Copy link
Author

SamHoque commented Jan 7, 2024

Yes, its an UI Library thats why I am confused on the error.

@keemtj
Copy link

keemtj commented Jan 9, 2024

@SamHoque

Hi, I encountered a similar issue where a native package wasn't working as expected(other package. not yours). To resolve this, I installed the native-addon-loader package as a devDependency in the root package.json and modified the webpack files. Below is the relevant code:

// webpack.config.main.prod.ts
// and
// webpack.config.renderer.dev.ts

{
  ...
  module: {
    ...
    rules: [
      {
        test: /\.node$/,
        use: 'native-addon-loader',
      },
    ],
  },
  resolve: {
    extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.node'],
  },
}

By adding this configuration to both webpack.config.main.prod.ts and webpack.config.renderer.dev.ts, the commands npm run start and npm run package now work well.

I hope this experience proves helpful.

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

3 participants