Gathering detailed insights and metrics for requirejs
Gathering detailed insights and metrics for requirejs
Gathering detailed insights and metrics for requirejs
Gathering detailed insights and metrics for requirejs
Runs RequireJS in Node and Rhino, and used to run the RequireJS optimizer
npm install requirejs
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
2,573 Stars
1,772 Commits
671 Forks
91 Watching
15 Branches
60 Contributors
Updated on 28 Nov 2024
JavaScript (99.43%)
HTML (0.43%)
CSS (0.1%)
Shell (0.05%)
Cumulative downloads
Total Downloads
Last day
-8.3%
255,139
Compared to previous day
Last week
0.7%
1,429,113
Compared to previous week
Last month
12.2%
5,840,353
Compared to previous month
Last year
28.8%
55,397,779
Compared to previous year
No dependencies detected.
A command line tool for running JavaScript scripts that use the Asynchronous Module Definition API (AMD) for declaring and using JavaScript modules and regular JavaScript script files.
It is part of the RequireJS project, and works with the RequireJS implementation of AMD.
r.js is a single script that has two major functions:
npm install -g requirejs
From then on, you can use r.js
on the command line to run the optimizer.
Download the latest release from the RequireJS download page.
xpcshell support was added in r.js version 2.1.5, so use that r.js version or later.
Download the latest release of r.js from the RequireJS download page.
r.js is made up of a series of modules that are built into one file for distribution. The dist directory contains the built version of the code. In the master branch, it should match the current state of the master code.
If you are doing local modifications from a clone of this repo, you can run the following command to generate an r.js at the root of this repo:
node dist.js
To generate an r.js that also gets copied to dist with a time stamp, run:
./copydist.js
If your JS project's main application file is called main.js, then do the following:
r.js main.js
Requires Node 0.4 or later.
r.js allows using Node modules installed via npm. For more info see the Use with Node docs.
As of r.js 2.1.16, r.js can run in Nashorn, Java 8+'s JavaScript engine, via the jjs
command line tool that is installed with Java.
Then general format of the command:
jjs -scripting path/to/r.js -- [r.js command line arguments here]
Examples:
# Calling r.js to optimize a project using the build config in build.js
jjs -scripting path/to/r.js -- -o build.js
# Calling r.js to run AMD modules, where the main app program is main.js
jjs -scripting path/to/r.js -- main.js
All further examples will use the Node notation, but substitute the r.js references below with the command line structure mentioned above (jjs -scripting path/to/r.js --
).
Using Rhino requires some JAR files in the CLASSPATH for it to work:
Download those files to your machine. To run r.js, you can use this type of command:
java -classpath path/to/rhino/js.jar:path/to/closure/compiler.jar org.mozilla.javascript.tools.shell.Main -opt -1 r.js main.js
java -classpath path/to/rhino/js.jar;path/to/closure/compiler.jar org.mozilla.javascript.tools.shell.Main -opt -1 r.js main.js
s If you want to run it in the debugger, replace org.mozilla.javascript.tools.shell.Main with org.mozilla.javascript.tools.debugger.Main.
All further examples will use the Node notation, but substitute the r.js references below with the appropriate java command.
To run the optimizer using a build config file or command line build options:
path/to/xpcshell path/to/r.js -o buildconfig.js
r.js can also be used as a library in another .js file run via xpcshell.
The optimizer can be run by passing the -o command to r.js:
r.js -o path/to/buildconfig.js
See the Optimization doc for more information on the optimizer.
If running in Java, be sure to grab the Rhino and Closure Compiler jar files in the lib/ directory, then run this command:
java -classpath path/to/rhino/js.jar:path/to/closure/compiler.jar org.mozilla.javascript.tools.shell.Main r.js -o path/to/buildconfig.js
java -classpath path/to/rhino/js.jar;path/to/closure/compiler.jar org.mozilla.javascript.tools.shell.Main r.js -o path/to/buildconfig.js
The optimizer is better than using a plain concatenation script because it runs require.js as part of the optimization, so it knows how to:
To get the version of r.js and the version of require.js used by r.js:
r.js -v
To convert a directory of CommonJS modules to ones that have define() wrappers:
r.js -convert path/to/commonjs/dir output/dir
Most, but not all, CommonJS modules can be converted to define()-wrapped modules and still work.
However, there are some modules that may fail if:
MIT
jQuery Foundation Code of Conduct.
r.js assumes that there are some other projects checked out as sibling directories to it, and named certain names, in order for the tests to pass.
So it is best to create the following directory structure with the following git clone commands:
mkdir requirejs
cd requirejs
git clone git://github.com/requirejs/r.js.git
git clone git://github.com/requirejs/requirejs.git
git clone git://github.com/requirejs/text.git
So there should be a sibling requirejs
and text
directories to the r.js
directory containing your clone of the r.js project.
The r.js project has the following directory layout:
dist.js takes the build/jslib/x.js file and injects the require.js files and other files from the build/jslib directory into it.
If you make changes to any of those files, you will need to run node dist.js to generate a new r.js. Be sure to run it through the tests , using both Node and Java/Rhino:
* node dist.js
* cd tests
* node ../r.js all.js
* java -classpath ../lib/rhino/js.jar:../lib/closure/compiler.jar org.mozilla.javascript.tools.shell.Main ../r.js all.js
* cd ../build/tests
* node ../../r.js all.js
* java -classpath ../../lib/rhino/js.jar:../../lib/closure/compiler.jar org.mozilla.javascript.tools.shell.Main ../../r.js all.js
For running tests, put xpcshell in env/xpcshell/ as a directory, that contains all the files needed for it to run, including the xpcshell binary. Downloading a xulrunner nightly might work.
See the RequireJS Contributing page for info on how to contribute code/bug fixes to this project.
Use GitHub pull requests to point to code changes, although for larger changes, contact the requirejs mailing list to discuss them first.
r.js includes modules from these projects:
To do a release of version 0.0.0:
Update the RequireJS download site to point to the latest release, then update the requirejs/requirejs-npm repo to have the latest changes and publish the result to npm.
Make sure to keep #!/usr/bin/env node
as the first line in bin/r.js in
the requirejs-npm repo.
The latest stable version of the package.
Stable Version
1
10/10
Summary
jrburke requirejs vulnerable to prototype pollution
Affected Versions
<= 2.3.6
Patched Versions
2.3.7
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
security policy file detected
Details
Reason
Found 2/26 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
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