Skip to main content

Run RequireJS (r.js) from Python without requiring Node or Rhino. Leverages PyMiniRacer plus a minimal JS environment to make r.js think it’s running in node.

Latest PyPI Release Release Notes License GitHub Stars GitHub Forks GitHub Issues

Travis Build Status Python Support

Usage

python-requirejs is available via PyPI:

pip install requirejs

API

import requirejs

requirejs.optimize(
    appDir=".",
    baseUrl="js/",
    modules=[{
        "name": "main",
    }]
    dir="../build",
)

Hopefully, all of the available build options for r.js will Just Work. If you find any discrepancies, please open a ticket to let us know.

This library is meant to be a drop-in replacement for node r.js -o app.build.json, and is tested by comparing its output with that command. However, since the optimize API is being called as a function, you may need to set the working directory explicitly to avoid any unexpected differences in how relative paths are computed:

import requirejs
import json

with open('app/app.build.json') as f:
    config = json.load(f)

requirejs.optimize(
    config,
    working_directory="app/"  # Unique to python-requirejs
)

Release files for requirejs 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for requirejs 0.2.0
File Size Uploaded
requirejs-0.2.0.tar.gz 236.8 kB Details

Release files / requirejs-0.2.0.tar.gz

Download URL requirejs-0.2.0.tar.gz
Size 236.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b6857934505ddfd15af02f736dcc592f5c94b4712a21faa00db0cef5072df227
BLAKE2b-256 checksum
How to use checksums
14e9b674624e36a959b536ec4082b052aac67da1df3c8095c620b9a2c38bef7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.2.2

2 release files

0.2.1

1 release file

This release

0.2.0 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page