rax-webpack-plugin

raw JSON →
0.6.6 verified Sat Apr 25 auth: no javascript

Webpack plugin for the Rax framework, used to bundle Rax applications with support for multiple target formats (UMD, CMD, bundle, factory). Stable version 0.6.6, with later releases up to v1.2.x in the monorepo. Provides built-in module externalization, polyfill inclusion, and multi-platform output (web, weex, node, React Native). Differentiates from generic webpack plugins by offering Rax-specific features like framework comment injection and duplicate dependency checks. The package is part of the Alibaba Rax project and has a peer dependency on webpack 1–4.

error TypeError: RaxPlugin is not a constructor
cause Incorrect import: using default ES import on a CJS module.
fix
Use const RaxPlugin = require('rax-webpack-plugin');
error Cannot find module 'rax-webpack-plugin'
cause Package not installed or missing peer dependencies.
fix
Run npm install --save-dev rax-webpack-plugin and ensure webpack is installed.
error Module parse failed: Unexpected token (1:0) when building
cause Missing required options for RaxPlugin, e.g., target not specified.
fix
Instantiate RaxPlugin with valid options object, e.g., new RaxPlugin({ target: 'umd' }).
gotcha Plugin does not support ESM imports; must use CommonJS require().
fix Use require('rax-webpack-plugin') instead of import.
gotcha BuiltinModules is a static property on RaxPlugin, not exported as default.
fix Access via RaxPlugin.BuiltinModules or destructure const { BuiltinModules } = require('rax-webpack-plugin').
gotcha Specifying both moduleName and globalName is required for UMD target; omitting causes runtime errors.
fix Provide both options when target is 'umd'.
breaking Peer dependency webpack ^1.x.x || ^2.x.x || ^3.x.x || ^4.x.x; webpack 5 not supported.
fix Use webpack 4 or lower, or migrate to alternative plugin.
npm install rax-webpack-plugin
yarn add rax-webpack-plugin
pnpm add rax-webpack-plugin

Minimal webpack configuration using rax-webpack-plugin with UMD target and external built-in modules.

const RaxPlugin = require('rax-webpack-plugin');

module.exports = {
  entry: './src/app.js',
  output: {
    filename: 'bundle.js',
  },
  plugins: [
    new RaxPlugin({
      target: 'umd',
      moduleName: 'MyApp',
      globalName: 'MyApp',
      externalBuiltinModules: true,
      includePolyfills: false,
    }),
  ],
};