Skip to main content

Run RequireJS (r.js) without node.

Project description

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
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

requirejs-0.2.2.tar.gz (237.1 kB view details)

Uploaded Source

Built Distribution

requirejs-0.2.2-py3-none-any.whl (240.5 kB view details)

Uploaded Python 3

File details

Details for the file requirejs-0.2.2.tar.gz.

File metadata

  • Download URL: requirejs-0.2.2.tar.gz
  • Upload date:
  • Size: 237.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for requirejs-0.2.2.tar.gz
Algorithm Hash digest
SHA256 8c90fc1ebf197048531c9bb1f039c994f3bd97f6cd834a04d581af6f52c6427d
MD5 54147c7495e3ab28f176c67b18bf1bee
BLAKE2b-256 351480ecdd3e22b213701963d5dbafc3cab31551dcd53bfc4f998b97c406b347

See more details on using hashes here.

File details

Details for the file requirejs-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: requirejs-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 240.5 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for requirejs-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0c883b0fa45820c649e4d3f7336fd7de405040b39fbd1e0fe4b8696bf015ccf4
MD5 e27e28b4be43406b6bca6895906a9d8f
BLAKE2b-256 07ccb7cf1923188433c5aeb82bebadcba2ebd78fcb4389c12d5c77e8c7cd106f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page