Registry / web-framework / ember-cli-terser

ember-cli-terser

JSON →
library4.0.2jsnpmunverified

ember-cli-terser is an Ember CLI addon designed to integrate the Terser JavaScript minifier into the Ember CLI build pipeline. Its primary function is to automatically minify JavaScript files during production builds, thereby optimizing application size and improving loading performance. The current stable version is 4.0.2. Its release cadence is generally aligned with major versions of the underlying `terser` library and updates to the Ember CLI ecosystem, often involving necessary Node.js support changes. A key differentiator is its seamless integration into the Ember CLI environment, allowing developers to configure `terser` options directly within `ember-cli-build.js` without manual adjustments to the build process. It effectively supersedes older minifiers like UglifyJS, providing modern JavaScript minification capabilities for Ember applications.

npm install ember-cli-terser
INSTALL
IMPORT
SIG · EMBER-CLI-TERSER
E
ember-cli-terser
web-frameworkjavascriptv4.0.2
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.

ember-cli-terser
new EmberApp({ 'ember-cli-terser': { enabled: true, /* ... */ } });
import { terserConfig } from 'ember-cli-terser';
This represents the top-level configuration object key within the `EmberApp` options in your `ember-cli-build.js`. `ember-cli-terser` does not expose direct JavaScript exports for import into application code; its usage is entirely through Ember CLI's build configuration.
terser
new EmberApp({ 'ember-cli-terser': { terser: { compress: {}, output: {} } } });
import * as Terser from 'ember-cli-terser/terser';
This refers to the nested object within the `ember-cli-terser` configuration in `ember-cli-build.js` that directly passes options to the underlying `terser` minifier. It is not an importable symbol.
enabled
new EmberApp({ 'ember-cli-terser': { enabled: false } });
import { enableMinification } from 'ember-cli-terser';
A boolean flag used within the `ember-cli-terser` configuration in `ember-cli-build.js` to explicitly enable or disable minification. Not an importable symbol.

Demonstrates how to install `ember-cli-terser` and configure its minification options, including Terser-specific settings and source map handling, within an Ember CLI project's `ember-cli-build.js` file.

// Terminal (run in your Ember CLI project root) ember install ember-cli-terser // ember-cli-build.js const EmberApp = require('ember-cli/lib/broccoli/ember-app'); // If using Embroider, you might also have this: // const { maybeEmbroider } = require('@embroider/test-setup'); module.exports = function(defaults) { let app = new EmberApp(defaults, { // Configure ember-cli-terser options here 'ember-cli-terser': { enabled: true, // Default: true for production builds, false for development exclude: ['vendor.js'], // Example: Exclude specific files from minification terser: { compress: { sequences: 50, dead_code: true, drop_console: process.env.EMBER_ENV === 'production' // Drop console logs only in production }, output: { semicolons: false // Example: Omit semicolons where possible }, mangle: { safari10: true // Specific fix for Safari 10 bugs } }, // Options for broccoli-terser-sourcemap can also be top-level hiddenSourceMap: true // Prevents adding '//# sourceMappingURL' comments }, // General EmberApp sourcemap configuration sourcemaps: { enabled: process.env.EMBER_ENV === 'production', // Enable sourcemaps only for production builds extensions: ['js'] } }); // If using Embroider: // return maybeEmbroider(app); return app; };
Debug
Known issues
breakingStarting with v4.0.0, deep defaulting of minification options was removed. Users must now explicitly define all desired `terser` options.
fix
Review your `ember-cli-build.js` configuration. Ensure all `terser` options (e.g., `compress`, `output`, `mangle`) are fully specified if you relied on previous implicit defaults. Consult the `terser@5` documentation for available options.
affects: >=4.0.0
breaking`ember-cli-terser` v4.0.0 updated to `terser@5` via `broccoli-terser-sourcemap@4`. This upgrade may introduce compatibility issues with older `terser` options or behavior changes.
fix
Verify that your `terser` configuration in `ember-cli-build.js` is compatible with `terser@5`. Consult the `terser` changelog for any breaking changes in option syntax or default behaviors between v4 and v5.
affects: >=4.0.0
breaking`ember-cli-terser` v4.0.0 dropped support for Node.js versions 8, 9, 11, and 13. Running on these versions will lead to errors.
fix
Upgrade your Node.js environment to a supported version: 10.*, 12.*, or >= 14.
affects: >=4.0.0
gotchaSource maps are disabled by default for production builds in Ember CLI. Minified code in production may lack debugging information unless explicitly enabled.
fix
To enable source maps for production, configure `sourcemaps: { enabled: true, extensions: ['js'] }` in your `ember-cli-build.js`. Additionally, you might use `hiddenSourceMap: true` within `ember-cli-terser` options to prevent source map URLs from being added to output files.
affects: *
Errors
Common errors & fixes
TypeError: Cannot read property 'options' of undefined (or similar errors related to terser configuration)
Incorrectly structured `terser` options or use of deprecated fields after upgrading `ember-cli-terser` to v4 (which uses `terser@5`), especially due to the removal of deep defaulting.
fix
Carefully review the `terser` configuration object within your `ember-cli-build.js` against the `terser@5` documentation and the `ember-cli-terser` README. Ensure all options are correctly nested and adhere to the current API.
Minification not happening in development builds, or `ember serve` performance is slow.
`ember-cli-terser` is disabled by default for development builds to speed up compilation times.
fix
If minification is desired in development, explicitly set `enabled: true` in the `ember-cli-terser` options within `ember-cli-build.js`. For production-like builds, use `ember build --environment=production`.
Error: Node.js version x.x.x is not supported by ember-cli-terser@4 (or similar Node.js version compatibility errors).
Attempting to use `ember-cli-terser` v4 with an unsupported Node.js version (e.g., 8, 9, 11, 13).
fix
Upgrade your Node.js environment to a compatible version (10.*, 12.*, or >= 14) as specified in the package's `engines` field.
Application functionality breaks or behaves unexpectedly after minification.
Aggressive `terser` options (e.g., in `compress` or `mangle`) can sometimes alter JavaScript code in a way that conflicts with specific application logic or external libraries.
fix
Gradually relax `terser` options in `ember-cli-build.js`, starting with `compress.sequences`, `compress.dead_code`, `mangle.safari10`, or by adding problematic files to the `exclude` array. Test thoroughly after each adjustment to pinpoint the problematic option.
Upgrade
Version history
4.0.2latest on npm
Audit
Dependencies
ember-clirequiredCore peer dependency for any Ember CLI addon, required for integration into the build pipeline.
terserrequiredThe primary JavaScript minification engine that ember-cli-terser integrates and exposes options for.
broccoli-terser-sourcemaprequiredUnderlying Broccoli plugin used by ember-cli-terser to perform minification and sourcemap generation within the build process.
Agent activity
2 hits · last 30 days
node
2
Resources
ember-cli-terser — npm install ember-cli-terser · libregistry