Falko Schindler baa97acfe8 Unify declaration of third-party dependencies (#2991) há 9 meses atrás
..
.gitignore baa97acfe8 Unify declaration of third-party dependencies (#2991) há 9 meses atrás
README.md baa97acfe8 Unify declaration of third-party dependencies (#2991) há 9 meses atrás
main.py baa97acfe8 Unify declaration of third-party dependencies (#2991) há 9 meses atrás
number_checker.js baa97acfe8 Unify declaration of third-party dependencies (#2991) há 9 meses atrás
number_checker.py baa97acfe8 Unify declaration of third-party dependencies (#2991) há 9 meses atrás
package.json baa97acfe8 Unify declaration of third-party dependencies (#2991) há 9 meses atrás
webpack.config.js baa97acfe8 Unify declaration of third-party dependencies (#2991) há 9 meses atrás

README.md

Use Bundled Node Modules as Third-party Dependencies

This example demonstrates how to use multiple third-party node modules as dependencies in a NiceGUI app. The app uses the is-odd node modules to check if a number is even or odd. We chose this package to demonstrate a very simple node module which has a dependency itself, namely the is-number package. Using NPM, we can easily install both packages and bundle them into a single file which can be used in the app. The package.json file defines the is-odd dependency and some dev dependencies for bundling the node module, the webpack.config.js file specifies the entry point for the node module, and number_checker.js as well as number_checker.py define a new UI element to be used in the NiceGUI app main.py.

  1. First, install all third-party node modules (assuming you have NPM installed):

    npm install
    

This will create a node_modules directory containing the is-odd and is-number modules as well as some dev dependencies.

  1. Now bundle the node module:

    npm run build
    
  2. Finally, you can run the app as usual:

    python3 main.py