Registry / devops / babel-plugin-remove-webpack

babel-plugin-remove-webpack

JSON →
library1.1.0jsnpmunverified

Babel plugin that removes webpack-specific functions (require.ensure, require.include) from JavaScript code, useful for running universal JavaScript on the server without shims. Version 1.1.0 is the latest and only stable release, with low maintenance cadence (last update years ago). Unlike manual polyfills, this plugin automatically strips webpack code at the AST level, enabling server-side execution without code splitting. For Node.js environments with babel-register, it avoids defining dummy functions per file. Not for use in webpack builds, as it would disable code splitting.

npm install babel-plugin-remove-webpack
INSTALL
IMPORT
SIG · BABEL-PLUGIN-REMOV
B
babel-plugin-remove-webpack
devopsjavascriptv1.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
module.exports = require('babel-plugin-remove-webpack')
import plugin from 'babel-plugin-remove-webpack'
CJS only; no default export for ESM. Use require() for Babel config.

Demonstrates how to install, configure, and use the plugin with babel-register or programmatically.

// Install: npm install --save-dev babel-plugin-remove-webpack // In .babelrc or babel.config.js: { "plugins": ["remove-webpack"] } // With babel-register in your server entry: require('@babel/register')({ plugins: ['remove-webpack'] }); require('./client-code'); // will run without require.ensure/require.include // Or programmatically: const babel = require('@babel/core'); const result = babel.transform( `require.ensure(['a'], function(r) { r('a'); });`, { plugins: ['remove-webpack'] } ); console.log(result.code); // (function () { require('a'); })();
Debug
Known issues
gotchaDo not use this plugin in webpack builds; it will remove code splitting.
fix
Only apply in server-side Babel transforms, not in webpack configuration.
affects: >=1.0.0
deprecatedrequire.ensure is deprecated in webpack in favor of dynamic import(). This plugin does not handle dynamic imports.
fix
Use dynamic import() on modern webpack and consider a different plugin for that case.
affects: >=1.0.0
gotchaPlugin is CJS-only; no ESM export. Cannot import via import statement.
fix
Use require() in Babel config or transform.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'babel-plugin-remove-webpack'
Missing npm install or wrong working directory.
fix
Run 'npm install babel-plugin-remove-webpack --save-dev' and ensure node_modules is accessible.
TypeError: Cannot read property 'ensure' of undefined
Plugin not applied or not working; require.ensure remains in code.
fix
Check Babel config includes 'remove-webpack' in plugins, and that the transform runs before execution.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
@babel/coreoptionalpeer dependency for Babel plugin compatibility
Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
babel-plugin-remove-webpack — npm install babel-plugin-remove-webpack · libregistry