As mentioned before, there are a few options for creating JavaScript bundles. Rollup and Babel are popular tools that can perform this task. The webpack is a good option because it is widely used and has a large plugin base.
This recipe demonstrates how to install and configure webpack to build a JavaScript bundle.
You'll need to have Node.js installed. If not, please see the appropriate recipe for installing Node.js with nvm
.
- Open your command-line application, navigate to your workspace, and create a new node package:
mkdir 02-creating-client-bundlescd 02-creating-client-bundlesnpm init -y
- Duplicate the
main.js
file from the Nesting modules under a single namespace recipe in Chapter 1, Building with Modules:
// main.js import { atlas, saturnV } from './rockets/index.js' export function main () { saturnV.launch(); atlas.launch(); }
- Create the
rockets
dependencies directory (these files can be copied from Nesting modules...