What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
To use modern JavaScript syntax in a webpack project, install webpack locally, configure an entry and output, then add babel-loader with Babel’s @babel/preset-env. webpack builds the dependency graph and bundles modules; Babel transforms other syntax when the project’s target browsers or runtime require it. “ES6” is often used as shorthand for modern JavaScript, but the right setup depends on the features you use and the environments you support.
What webpack and Babel each do
webpack follows imports through your project, builds a dependency graph, and bundles the resulting modules. It understands import and export, but it does not transform every newer JavaScript feature. The webpack guide puts it plainly: “Webpack will not alter any code other than import and export statements.” See webpack’s Getting Started guide.
Babel transforms JavaScript syntax according to the environments you target. In a webpack project, babel-loader connects Babel to webpack so source files can be transformed as webpack processes them. This is not a blanket requirement for every project: if the runtimes you support already understand the syntax you use, some or all transforms may be unnecessary.
Check runtime and package compatibility first
Use a Node.js version supported by the webpack, CLI, Babel, and loader releases you install. The current webpack Getting Started guide uses webpack-cli 7 and says its examples require Node.js 20.9.0 or later. That is a requirement for those examples, not a universal minimum for every webpack generation. Check webpack’s installation guide and the package compatibility information before copying commands into an existing project.
Recommended Free Tools
#1 Best Overall
The babel-loader documentation lists these compatibility ranges:
| babel-loader generation | Documented compatibility |
|---|---|
| v8 | webpack 4 or 5; Babel 7; Node.js 8.9 or later |
| v9 | webpack 5; Babel ^7.12.0; Node.js 14.15.0 or later |
| v10 | webpack ^5.61.0; Babel ^7.12.0 or ^8.0.0-alpha; Node.js ^18.20.0, ^20.10.0, or >=22.0.0 |
These ranges are release-sensitive. Verify the current loader documentation and your installed package versions rather than assuming the newest loader works with an older webpack or Node.js setup.
Create the webpack project
-
Create a directory for the project and initialize npm:
Rank #2
mkdir modern-js-app cd modern-js-app npm init -y -
Install webpack and its command-line interface as development dependencies:
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.npm install -D webpack webpack-cliKeep build tools project-local. This lets each project manage its own tool versions; webpack’s installation guidance cautions against a global install for typical projects.
-
Create
src/index.jsand add a small entry module:const greeting = (name = 'world') => `Hello, ${name}!`; console.log(greeting()); -
Create
webpack.config.jsin the project root:const path = require('node:path'); module.exports = { entry: './src/index.js', output: { filename: 'bundle.js', path: path.resolve(__dirname, 'dist'), }, };The standard configuration filename is discovered by webpack by default. This configuration tells webpack where the dependency graph starts and where to write the bundled output.
Add Babel to the webpack pipeline
Install the loader and Babel packages as development dependencies:
npm install -D babel-loader @babel/core @babel/preset-env
The webpack CLI is included separately in the project setup above. Add a rule for JavaScript files to webpack.config.js:
Free tools Windows power users keep installed
One-click scans. No signup required.
const path = require('node:path');
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{
test: /.(?:js|mjs|cjs)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', { targets: 'defaults' }],
],
},
},
},
],
},
};
The rule matches .js, .mjs, and .cjs files, skips dependencies in node_modules by default, and passes matching project files to Babel. The targets example uses Babel’s defaults target; choose targets that reflect the browsers or runtime your project actually promises to support. Babel documents target-based transform selection in its @babel/preset-env guide.
Rank #4
Choose targets and configuration deliberately
Targets determine which syntax Babel transforms. Current browsers or a specific Node.js runtime may need fewer transforms than a project that must support older environments. An unexplained legacy target can add transforms and compatibility work without serving a real audience. Decide which runtimes matter, then configure @babel/preset-env accordingly.
The inline loader options shown above suit a small project. If several tools in your project need the same Babel settings, put the preset configuration in a project-level Babel configuration instead, and keep the webpack rule focused on selecting files for the loader.
When Babel is used with a bundler, its module handling is generally best left at modules: "auto". This lets Babel use caller information supplied by webpack. Avoid manually supplying caller data that may override details from the bundler.
Best Value
Syntax transforms are not runtime polyfills
Transforming syntax and providing missing JavaScript APIs are separate tasks. Babel can rewrite syntax for selected targets, but that alone does not guarantee that every runtime API exists in those environments. If your application depends on APIs unsupported by a target, determine separately whether and how to provide polyfills; do not treat successful syntax transformation as proof of API compatibility.
Build the bundle and check the result
-
Add a build script to
package.json:{ "scripts": { "build": "webpack" } } -
Run the project-local build:
npm run build -
Check that webpack completes without errors and creates
dist/bundle.js. Inspect the emitted file if you need to confirm what was bundled or transformed; a successful build does not by itself establish that every supported browser or runtime has all required APIs.
When a bundler may be unnecessary
webpack is useful when a project needs an explicit, configurable build pipeline. The official guide notes that a small page with one or two scripts may not need a bundler. For a larger application or a project that needs webpack’s module and asset processing, the setup above provides a clear division: webpack bundles the modules, while Babel adapts syntax to the chosen targets.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →

