Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sheppard/python-requirejs
Run RequireJS (r.js) from Python without needing node or rhino.
https://github.com/sheppard/python-requirejs
Last synced: 4 days ago
JSON representation
Run RequireJS (r.js) from Python without needing node or rhino.
- Host: GitHub
- URL: https://github.com/sheppard/python-requirejs
- Owner: sheppard
- License: mit
- Created: 2017-09-15T20:12:28.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-27T08:03:25.000Z (over 3 years ago)
- Last Synced: 2024-04-30T15:44:44.815Z (7 months ago)
- Language: JavaScript
- Size: 343 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# python-requirejs
Run RequireJS (r.js) from Python without requiring Node or Rhino. Leverages [PyMiniRacer] plus a minimal [JS environment][env.js] to make r.js think it's running in node.
[![Latest PyPI Release](https://img.shields.io/pypi/v/requirejs.svg)](https://pypi.org/project/requirejs/)
[![Release Notes](https://img.shields.io/github/release/wq/python-requirejs.svg)](https://github.com/wq/python-requirejs/releases)
[![License](https://img.shields.io/pypi/l/requirejs.svg)](https://github.com/wq/python-requirejs/blob/master/LICENSE)
[![GitHub Stars](https://img.shields.io/github/stars/wq/python-requirejs.svg)](https://github.com/wq/python-requirejs/stargazers)
[![GitHub Forks](https://img.shields.io/github/forks/wq/python-requirejs.svg)](https://github.com/wq/python-requirejs/network)
[![GitHub Issues](https://img.shields.io/github/issues/wq/python-requirejs.svg)](https://github.com/wq/python-requirejs/issues)[![Travis Build Status](https://img.shields.io/travis/wq/python-requirejs/master.svg)](https://travis-ci.org/wq/python-requirejs)
[![Python Support](https://img.shields.io/pypi/pyversions/requirejs.svg)](https://pypi.org/project/requirejs/)## Usage
`python-requirejs` is available via PyPI:
```bash
pip install requirejs
```### API
```python
import requirejsrequirejs.optimize(
appDir=".",
baseUrl="js/",
modules=[{
"name": "main",
}]
dir="../build",
)
```Hopefully, all of the [available build options for r.js](http://requirejs.org/docs/optimization.html#options) will Just Work. If you find any discrepancies, please [open a ticket](https://github.com/wq/python-requirejs/issues) 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:
```python
import requirejs
import jsonwith open('app/app.build.json') as f:
config = json.load(f)requirejs.optimize(
config,
working_directory="app/" # Unique to python-requirejs
)
```[PyMiniRacer]: https://github.com/sqreen/PyMiniRacer
[env.js]: https://github.com/wq/python-requirejs/blob/master/requirejs/env.js