Mozu Require Compiler

raw JSON →
3.0.2 verified Fri May 01 auth: no javascript deprecated

A customized version of the RequireJS optimizer (r.js) tailored for Mozu applications. This package provides a command-line tool for building AMD modules using the RequireJS module system. Version 3.0.2 is the latest release, but it is based on an older r.js codebase. It supports Node.js, Rhino/Java, and xpcshell environments. The primary use case is optimizing and combining AMD modules for browser delivery. Compared to the official requirejs package, this fork may include Mozu-specific patches or configuration defaults. However, it is largely unmaintained and users are advised to use the official `requirejs` package instead.

error Error: Cannot find module 'mozu-require-compiler'
cause Package not installed globally or locally.
fix
npm install -g mozu-require-compiler (deprecated) or use requirejs instead.
error TypeError: require(...) is not a function
cause Using CommonJS require on AMD-only code.
fix
Use define/require in AMD style, or convert to CommonJS if using Node.
error r.js: command not found
cause Official r.js not installed; mozu-require-compiler installs as 'r.js' but may not be in PATH.
fix
Ensure mozu-require-compiler is installed globally with -g flag.
error Error: Build config not found: /path/to/buildconfig.js
cause Incorrect path or missing file.
fix
Provide absolute path or ensure file exists relative to working directory.
deprecated mozu-require-compiler is a deprecated fork of r.js. Use the official requirejs package instead.
fix npm uninstall -g mozu-require-compiler && npm install -g requirejs
breaking The package may lack updates for modern Node.js versions and may break > Node 10.
fix Use requirejs package or update to a maintained AMD bundler.
gotcha The CLI command is `r.js` not `mozu-require-compiler` after installation.
fix Run `r.js -v` instead of `mozu-require-compiler`.
gotcha The package may include Mozu-specific default configurations that differ from standard requirejs behavior.
fix Review the default build config; override in your project's config file.
deprecated The last release (3.0.2) was published years ago; there is no active maintenance.
fix Migrate to requirejs or a modern bundler like webpack or Rollup.
npm install mozu-require-compiler
yarn add mozu-require-compiler
pnpm add mozu-require-compiler

Install the official requirejs package, create a build configuration for your AMD project, and run the optimizer.

// Install official requirejs
npm install -g requirejs

// Build project using a build config
r.js -o buildconfig.js

// Example buildconfig.js
({
  appDir: './src',
  baseUrl: '.',
  dir: './dist',
  modules: [
    { name: 'main' }
  ],
  paths: {
    jquery: 'empty:'
  }
})