Gathering detailed insights and metrics for systemjs-builder
Gathering detailed insights and metrics for systemjs-builder
Gathering detailed insights and metrics for systemjs-builder
Gathering detailed insights and metrics for systemjs-builder
grunt-systemjs-builder
grunt task for building projects based on systemjs
systemjs-config-builder
Generate SystemJS config files from node_modules
gulp-systemjs-builder
A tiny wrapper around SystemJS builder .bundle and .buildStatic methods
@cliqz-oss/systemjs-builder
SystemJS Build Tool
npm install systemjs-builder
Typescript
Module System
Node Version
NPM Version
SystemJS Builder 0.16.15
Updated on May 21, 2019
SystemJS Builder 0.16.14
Updated on May 21, 2019
SystemJS Builder 0.16.13
Updated on May 03, 2018
SystemJS Builder 0.16.12
Updated on Oct 16, 2017
SystemJS Builder 0.16.11
Updated on Sep 18, 2017
SystemJS Builder 0.16.10
Updated on Aug 21, 2017
JavaScript (95.56%)
HTML (4.37%)
Shell (0.06%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
465 Stars
1,170 Commits
114 Forks
29 Watchers
9 Branches
61 Contributors
Updated on Aug 06, 2024
Latest Version
0.16.15
Package Id
systemjs-builder@0.16.15
Size
46.99 kB
NPM Version
6.4.1
Node Version
10.15.3
Published on
May 21, 2019
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
17
This project has been deprecated as of SystemJS 2.0. It will continue to support SystemJS 0.21 legacy builds though. Instead, Rollup code splitting builds are encouraged.
SystemJS Builder 0.16 release notes
Note for SystemJS 0.19 support use SystemJS Builder 0.15
Provides a single-file build for SystemJS of mixed-dependency module trees.
Builds ES6 into ES5, CommonJS, AMD and globals into a single file in a way that supports the CSP SystemJS loader as well as circular references.
app.js
1import $ from "./jquery.js"; 2export var hello = 'es6';
jquery.js
1define(function() { 2 return 'this is jquery'; 3});
Will build the module app
into a bundle containing both app
and jquery
defined through System.register
calls.
Circular references and bindings in ES6, CommonJS and AMD all behave exactly as they should, including maintaining execution order.
1npm install systemjs-builder
Ensure that the transpiler is installed separately (npm install babel-core
here).
1var path = require("path"); 2var Builder = require('systemjs-builder'); 3 4// optional constructor options 5// sets the baseURL and loads the configuration file 6var builder = new Builder('path/to/baseURL', 'path/to/system/config-file.js'); 7 8builder 9.bundle('local/module.js', 'outfile.js') 10.then(function() { 11 console.log('Build complete'); 12}) 13.catch(function(err) { 14 console.log('Build error'); 15 console.log(err); 16});
Configuration can be injected via builder.config
:
1builder.config({ 2 map: { 3 'a': 'b.js' 4 } 5}); 6builder.build('a');
To load custom configuration files use builder.loadConfig
:
1// `builder.loadConfig` will load config from a file containing `System.config({...})` 2builder.loadConfig('./cfg.js') 3.then(function() { 4 // ready to build 5});
Multiple config calls can be run, which will combine into the loader configuration.
To reset the loader state and configuration use builder.reset()
.
When config was passed into the new Builder(baseURL, configFile)
constructor, the config will be reset to this exact configFile
state.
To make a bundle that is independent of the SystemJS loader entirely, we can make SFX bundles:
1builder.buildStatic('myModule.js', 'outfile.js', options);
This bundle file can then be included with a <script>
tag, and no other dependencies would need to be included in the page. You'll likely want your module
to export a global variable when loaded from a script tag, and this can be configured via globalName
. For example
1builder.buildStatic('src/NavBar.js', 'dist/NavBarStaticBuild.js', { 2 globalName: 'NavBar' 3});
will cause the output of your module to be assigned to a global variable named NavBar
. If you're making a static bundle, while excluding certain dependencies, those dependencies
will of course need to have already been loaded on your page, with their own global variables exported. You can match these global variables up with your needed dependencies
with globalDeps
. For example
1builder.buildStatic('src/NavBar.js - react', 'dist/NavBarStaticBuild.js', { 2 globalName: 'NavBar', 3 globalDeps: { 4 'react': 'React' 5 } 6});
will create a static build of NavBar—without React—which, when loaded via a script tag, exports an eponymous global variable, and assumes the existence of a React global variable, which will be used for the react
dependency.
This would support users with a setup of
1<script src='path/to/react.min.js'></script> 2<script src='path/to/NavBarStaticBuild.js'></script>
Note that another way of excluding react
would be with externals
.
1builder.buildStatic('src/NavBar.js', 'dist/NavBarStaticBuild.js', { 2 externals: ['react'], 3 globalName: 'NavBar', 4 globalDeps: { 5 'react': 'React' 6 } 7});
This would also exclude react but, if react defined any dependencies which NavBar also defined, those dependencies would be included in the build.
Of course the above explanations involving globalDeps
and globalName
only apply to when your end user loads the static file from a script tag. Since the output is (by default, see below) UMD, a
script loader like SystemJS or requireJS would process it as configured, or via AMD respectively.
By default, the Traceur or Babel runtime are automatically included in the SFX bundle if needed. To exclude the Babel or Traceur runtime set the runtime
build option to false:
1builder.buildStatic('myModule.js', 'outfile.js', { runtime: false });
SFX bundles can also be output as a custom module format - amd
, cjs
or es6
for consumption in different environments.
This is handled via the format
(previously sfxFormat
) option:
1builder.buildStatic('myModule.js', 'outfile.js', { format: 'cjs' });
The first module used as input (myModule.js
here) will then have its exports output as the CommonJS exports of the whole SFX bundle itself
when run in a CommonJS environment.
To have globals like jQuery
not included, and included in a separate script tag, set up an adapter module something like:
jquery.js
1module.exports = window.jQuery;
As well as an options.config
parameter, it is also possible to specify minification and source maps options:
1builder.bundle('myModule.js', 'outfile.js', { minify: true, sourceMaps: true, config: cfg });
Compile time with source maps can also be improved with the lowResSourceMaps
option, where the mapping granularity is per-line instead of per-character:
1builder.bundle('myModule.js', 'outfile.js', { sourceMaps: true, lowResSourceMaps: true });
mangle
, defaults to true.globalDefs
, object allowing for global definition assignments for dead code removal.1builder.bundle('myModule.js', 'outfile.js', { minify: true, mangle: false, globalDefs: { DEBUG: false } });
sourceMaps
, Either boolean value (enable/disable) or string value 'inline'
which will inline the SourceMap data as Base64 data URI right in the generated output file (never use in production). (Default is false
)sourceMapContents
, Boolean value that determines if original sources shall be directly included in the SourceMap. Using inline source contents generates truely self contained SourceMaps which will not need to load the external original source files during debugging. (Default is false
; when using sourceMaps='inline'
it defaults true
)Leave out the outFile
option to run an in-memory build:
1builder.bundle('myModule.js', { minify: true }).then(function(output) { 2 output.source; // generated bundle source 3 output.sourceMap; // generated bundle source map 4 output.modules; // array of module names defined in the bundle 5});
The output
object above is provided for all builds, including when outFile
is set.
output.modules
can be used to directly populate SystemJS bundles configuration.
If loading resources that shouldn't even be traced as part of the build (say an external import), these can be configured with:
1builder.config({ 2 meta: { 3 'resource/to/ignore.js': { 4 build: false 5 } 6 } 7});
The framework fetch function can be overridden in order to provide the source for a file manually. This is useful if you want to pre-process the source of a file before using the builder.
1var mySource = 'import * from foo; var foo = "bar";'; // get source as a string 2builder.bundle('foo.js', { 3 fetch: function (load, fetch) { 4 if (load.name.indexOf('foo.js') !== -1) { 5 return mySource; 6 } else { 7 // fall back to the normal fetch method 8 return fetch(load); 9 } 10 } 11});
The load
variable describes the file that is trying to be loaded. This is called once for every file that is trying to be fetched, including dependencies.
The fetch
function should return a string.
Both builder.build
and builder.buildStatic
support bundle arithmetic expressions. This allows for the easy construction of custom bundles.
There is also a builder.trace
for building direct trace tree objects, which can be directly passed into builder.bundle
or builder.buildStatic
.
In this example we build all our application code in app/
excluding the tree app/corelibs
:
1var Builder = require('systemjs-builder'); 2 3var builder = new Builder({ 4 baseURL: '...', 5 map: { 6 } // etc. config 7}); 8 9builder.bundle('app/* - app/corelibs.js', 'output-file.js', { minify: true, sourceMaps: true });
To build the dependencies in common between two modules, use the &
operator:
1builder.bundle('app/page1.js & app/page2.js', 'common.js');
We can then exclude this common bundle in future builds:
1builder.bundle('app/componentA.js - common.js', { minify: true, sourceMaps: true });
Build a bundle of all dependencies of the app/
package excluding anything from app/
itself.
For this we can use the [module]
syntax which represents a single module instead of all its dependencies as well:
1builder.bundle('app/**/* - [app/**/*]', 'dependencies.js', { minify: true, sourceMaps: true });
The above means take the tree of app and all its dependencies, and subtract just the modules in app, thus leaving us with just the tree of dependencies of the app package.
Parentheses are supported, so the following would bundle everything in common with page1
and page2
, and also everything in common between page3
and page4
:
1builder.bundle('(app/page1.js & app/page2.js) + (app/page3.js & app/page4.js)', 'common.js');
Instead of using the arithmetic syntax, we can construct the trace ourselves.
In this example we build app/first
and app/second
into two separate bundles, while creating a separate shared bundle:
1var Builder = require('systemjs-builder'); 2 3var builder = new Builder({ 4 // ... 5}); 6 7Promise.all([builder.trace('app/first.js'), builder.trace('app/second.js')]) 8.then(function(trees) { 9 var commonTree = builder.intersectTrees(trees[0], trees[1]); 10 return Promise.all([ 11 builder.bundle(commonTree, 'shared-bundle.js'), 12 builder.bundle(builder.subtractTrees(trees[0], commonTree), 'first-bundle.js'), 13 builder.bundle(builder.subtractTrees(trees[1], commonTree), 'second-bundle.js') 14 ]); 15});
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 5/21 approved changesets -- score normalized to 2
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
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