Skip to content

Commit

Permalink
chores: use parcel to generate UMD lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Genuifx authored and iveswen committed Dec 11, 2018
1 parent fbfc31f commit 36021b4
Show file tree
Hide file tree
Showing 6 changed files with 4,974 additions and 14 deletions.
12 changes: 10 additions & 2 deletions README.md
Expand Up @@ -5,19 +5,27 @@
Relate article: [
前端与编译原理——用JS写一个JS解释器》](http://sfau.lt/b5bkvoY)

## Install

``` sh
git clone https://github.com/jrainlau/canjs.git
```

## Usage
It's fine to run the JS code in string directly.

```javascript
const Canjs = require('Canjs')
const Canjs = require('./dist/index.js')

new Canjs(`
console.log('Hello World!')
`).run()
```

`CanJS` uses ES5 standard library, but you can also provide custom variables to it:

```javascript
const Canjs = require('Canjs')
const Canjs = require('./dist/index.js')

const wx = {
name: 'wx'
Expand Down
5 changes: 2 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.map

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions index.js
@@ -1,9 +1,3 @@
const Canjs = require('./src')

try {
window.Canjs = Canjs
} catch (e) {}

try {
global.Canjs = Canjs
} catch (e) {}
module.exports = Canjs;
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -4,7 +4,7 @@
"description": "CanJS is a javascript interpreter, which can run JS code in JS.",
"main": "index.js",
"scripts": {
"build": "parcel build ./index.js"
"build": "parcel build ./index.js --global Canjs"
},
"repository": {
"type": "git",
Expand All @@ -19,5 +19,8 @@
"homepage": "https://github.com/jrainlau/canjs#readme",
"dependencies": {
"acorn": "^6.0.4"
},
"devDependencies": {
"parcel": "^1.10.3"
}
}

0 comments on commit 36021b4

Please sign in to comment.