# py-loader-jpic

> Webpack loader for Python

Latest version **0.3.1** (published 2019-02-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install py-loader-jpic
pnpm add py-loader-jpic
yarn add py-loader-jpic
bun add py-loader-jpic
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2019-02-10 |
| First published | 2019-02-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 7.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 49 |
| Author | martim00 |
| Maintainers | yourlabs |

## Links

- npm: https://www.npmjs.com/package/py-loader-jpic
- Repository: git@github.com:martim00/python-webpack-loader
- Homepage: https://github.com/martim00/python-webpack-loader
- npm.io page: https://npm.io/package/py-loader-jpic

## Dependencies (3)

- [extend](https://npm.io/package/extend.md) ^3.0.1
- [node-cmd](https://npm.io/package/node-cmd.md) ^3.0.0
- [loader-utils](https://npm.io/package/loader-utils.md) ^1.1.0

## Recent versions

- 0.3.1 (latest) — 2019-02-10

## README

<div align="center">
  <img width="160" height="160"
    src="https://cdn.worldvectorlogo.com/logos/python-5.svg">
  <a href="https://github.com/webpack/webpack">
    <img width="200" height="200" hspace="20"
      src="https://webpack.js.org/assets/icon-square-big.svg">
  </a>
  <h1>Python Webpack Loader</h1>
</div>

Loads Python files and transpile to JavaScript using the awesome [Transcrypt](http://www.transcrypt.org/), [Jiphy](https://github.com/timothycrosley/jiphy) or [Javascripthon](https://github.com/metapensiero/metapensiero.pj) compilers.


## Install

```bash
pip install transcrypt  # or jiphy, or javascripthon
npm install --save-dev py-loader
```

You may specify `jiphy` instead of `transcrypt` if you prefer. In this case, ensure that `options.compiler` in `webpack.config.js` is set to `jiphy` (see below). The compiler option for Javascripthon is `pj`.

## Usage

```js
import Something from 'main.py';
```

### Configuration

**webpack.config.js**
```js
module.exports = {
  module: {
    rules: [
      {
        test: /\.py$/,
        loader: 'py-loader',
        options: {
          compiler: 'transcrypt'
        }
      }
    ]
  }
}
```

### VueJS support

`py-loader` can also be used to compile .vue Single File Components used by [VueJS](https://www.vuejs.org). This assumes that you already have `vue-loader` set up and working with javascript .vue files. Modify your `vue-loader` config file as shown:

```js
  loaders: {
    'py': require.resolve('py-loader')
  },
```

An example of a simple VueJS app written in (mostly) Python can be seen in the `examples/vue-demo` folder.

***Caveats***
* Only tested with Transcrypt
* The import statement for loading sub-components still looks a bit weird
* Web-pack entry point is still a javascript file

## Extend

`py-loader` can be extended to use other Python compilers. Just fork this repo and extend the `compilers` object in `index.js`.

Please submit a pull request with your addition.


## Contributors

- DuncanMacWeb (https://github.com/DuncanMacWeb)
- Sebastian Silva (https://github.com/icarito)
- Ryan Liao (https://github.com/pirsquare)

---
_Source: https://npm.io/package/py-loader-jpic · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
