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
)

Metadata

Release files for requirejs 0.2.2

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.2
File Size Uploaded
requirejs-0.2.2.tar.gz 237.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for requirejs 0.2.2
File Interpreter ABI Platform
requirejs-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 477.6 kB

Release files / requirejs-0.2.2.tar.gz

Download URL requirejs-0.2.2.tar.gz
Size 237.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8c90fc1ebf197048531c9bb1f039c994f3bd97f6cd834a04d581af6f52c6427d
BLAKE2b-256 checksum
How to use checksums
351480ecdd3e22b213701963d5dbafc3cab31551dcd53bfc4f998b97c406b347
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2

Release files / requirejs-0.2.2-py3-none-any.whl

Download URL requirejs-0.2.2-py3-none-any.whl
Size 240.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0c883b0fa45820c649e4d3f7336fd7de405040b39fbd1e0fe4b8696bf015ccf4
BLAKE2b-256 checksum
How to use checksums
07ccb7cf1923188433c5aeb82bebadcba2ebd78fcb4389c12d5c77e8c7cd106f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

1 release file

0.2.0

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