Gathering detailed insights and metrics for broccoli-babel-transpiler
Gathering detailed insights and metrics for broccoli-babel-transpiler
Gathering detailed insights and metrics for broccoli-babel-transpiler
Gathering detailed insights and metrics for broccoli-babel-transpiler
npm install broccoli-babel-transpiler
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
58 Stars
450 Commits
73 Forks
15 Watchers
18 Branches
46 Contributors
Updated on Apr 01, 2025
Latest Version
8.0.2
Package Id
broccoli-babel-transpiler@8.0.2
Unpacked Size
29.16 kB
Size
9.30 kB
File Count
7
NPM Version
10.9.2
Node Version
22.13.1
Published on
Apr 01, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
8
1
15
A Broccoli plugin that runs Babel plugins with caching and parallel capabilities.
1$ npm install broccoli-babel-transpiler --save-dev
In your Brocfile.js
:
1const babel = require('broccoli-babel-transpiler'); 2const scriptTree = babel(inputTree, babelOptions);
Note that, since Babel 6 (and v6 of this plugin), you need to be specific as to
what your transpilation target is. Running esTranspiler
with empty options
will not transpile anything. You will need:
presets
. See available options at Babel's GitHub repo.For a quick running example, install this plugin:
1$ npm install babel-preset-env
And then run the transform like this:
1const babel = require('broccoli-babel-transpiler'); 2let scriptTree = babel(inputTree, { 3 presets: [ 4 ['env', { 5 'targets': { 6 'browsers': ['last 2 versions'] 7 } 8 }] 9 ] 10});
You'll find three example projects using this plugin in the repository broccoli-babel-examples. Each one of them builds on top of the previous example so you can progress from bare minimum to ambitious development.
Currently this plugin only supports inline source map. If you need separate source map feature, you're welcome to submit a pull request.
filterExtensions
is an option to limit (or expand) the set of file extensions
that will be transformed.
The default filterExtension
is js
1const esTranspiler = require('broccoli-babel-transpiler');
2let scriptTree = esTranspiler(inputTree, {
3 filterExtensions:['js', 'es6'] // babelize both .js and .es6 files
4});
targetExtension
is an option to specify the extension of the output files
The default targetExtension
is js
1const esTranspiler = require('broccoli-babel-transpiler');
2let scriptTree = esTranspiler(inputTree, {
3 targetExtension: 'module.js' // create output files with module.js extension
4});
Use of custom plugins works similarly to babel
itself. You would pass a
plugins
array in options
:
1const esTranspiler = require('broccoli-babel-transpiler');
2const applyFeatureFlags = require('babel-plugin-feature-flags');
3
4let featureFlagPlugin = applyFeatureFlags({
5 import: { module: 'ember-metal/features' },
6 features: {
7 'ember-metal-blah': true
8 }
9});
10
11let scriptTree = esTranspiler(inputTree, {
12 babel: {
13 plugins: [
14 featureFlagPlugin
15 ]
16 }
17});
broccoli-babel-transpiler uses a persistent cache to enable rebuilds to be significantly faster (by avoiding transpilation for files that have not changed). However, since a plugin can do many things to affect the transpiled output it must also influence the cache key to ensure transpiled files are rebuilt if the plugin changes (or the plugins configuration).
In order to aid plugin developers in this process, broccoli-babel-transpiler will invoke two methods on a plugin so that it can augment the cache key:
cacheKey
- This method is used to describe any runtime information that may
want to invalidate the cached result of each file transpilation. This is
generally only needed when the configuration provided to the plugin is used
to modify the AST output by a plugin like babel-plugin-filter-imports
(module
exports to strip from a build), babel-plugin-feature-flags
(configured
features and current status to strip or embed in a final build), or
babel-plugin-htmlbars-inline-precompile
(uses ember-template-compiler.js
to compile inlined templates).baseDir
- This method is expected to return the plugins base dir. The
provided baseDir
is used to ensure the cache is invalidated if any of the
plugin's files change (including its deps). Each plugin should implement
baseDir
as: Plugin.prototype.baseDir = function() { return \_\_dirname; };
.broccoli-babel-transpiler can run multiple babel transpiles in parallel using a pool of workers, to take advantage of multi-core systems. Because these workers are separate processes, the plugins and callback functions that are normally passed as options to babel must be specified in a serializable form. To enable this parallelization there is an API to tell the worker how to construct the plugin or callback in its process.
To ensure a build remains parallel safe, one can set the
throwUnlessParallelizable
option to true (defaults to false). This will cause
an error to be thrown, if parallelization is not possible due to an
incompatible babel plugin.
1new Babel(input, { throwUnlessParallelizable: true | false });
Alternatively, an environment variable can be set:
1THROW_UNLESS_PARALLELIZABLE=1 node build.js
Plugins are specified as an object with a _parallelBabel
property:
1let plugin = { 2 _parallelBabel: { 3 requireFile: '/full/path/to/the/file', 4 useMethod: 'methodName', 5 buildUsing: 'buildFunction', 6 params: { ok: 'this object will be passed to buildFunction()' } 7 } 8};
Callbacks can be specified like plugins, or as functions with a
_parallelBabel
property:
1function callback() { /* do something */ }; 2 3callback._parallelBabel = { 4 requireFile: '/full/path/to/the/file', 5 useMethod: 'methodName', 6 buildUsing: 'buildFunction', 7 params: { ok: 'this object will be passed to buildFunction()' } 8};
This property specifies the file to require in the worker process to create the plugin or callback. This must be given as an absolute path.
1const esTranspiler = require('broccoli-babel-transpiler');
2
3let somePlugin = {
4 _parallelBabel: {
5 requireFile: '/full/path/to/the/file'
6 }
7});
8
9let scriptTree = esTranspiler(inputTree, {
10 babel: {
11 plugins: [
12 'transform-strict-mode', // plugins that are given as strings will automatically be parallelized
13 somePlugin
14 ]
15 }
16});
This property specifies the method to use from the file that is required.
If you have a plugin defined like this:
1// some_plugin.js 2 3module.exports = { 4 pluginFunction(babel) { 5 // do plugin things 6 } 7};
You can tell broccoli-babel-transpiler to use that function in the worker processes like so:
1const esTranspiler = require('broccoli-babel-transpiler'); 2 3let somePlugin = { 4 _parallelBabel: { 5 requireFile: '/path/to/some_plugin', 6 useMethod: 'pluginFunction' 7 } 8}); 9 10let scriptTree = esTranspiler(inputTree, { 11 babel: { 12 plugins: [ somePlugin ] 13 } 14});
These properties specify a function to run to build the plugin (or callback), and any parameters to pass to that function.
If the plugin needs to be built dynamically, you can do that like so:
1// some_plugin.js
2
3module.exports = {
4 buildPlugin(params) {
5 return doSomethingWith(params.text);
6 }
7};
This will tell the worker process to require the plugin and call the
buildPlugin
function with the params
object as an argument:
1const esTranspiler = require('broccoli-babel-transpiler'); 2 3let somePlugin = { 4 _parallelBabel: { 5 requireFile: '/path/to/some_plugin', 6 buildUsing: 'buildPlugin', 7 params: { text: 'some text' } 8 } 9}); 10 11let scriptTree = esTranspiler(inputTree, { 12 babel: { 13 plugins: [ somePlugin ] 14 } 15});
Note: If both useMethod
and buildUsing
are specified, useMethod
takes
precedence.
The number of parallel jobs defaults to the number of detected CPUs - 1.
This can be changed with the JOBS
environment variable:
1JOBS=4 ember build
To disable parallelization:
1JOBS=1 ember build
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 4/15 approved changesets -- score normalized to 2
Reason
dependency not pinned by hash detected -- score normalized to 1
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
20 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More