Skip to content
This repository was archived by the owner on Jan 9, 2025. It is now read-only.

Commit b22e0be

Browse files
committed
add babel transpile & webpacc
1 parent de3cc2f commit b22e0be

File tree

6 files changed

+39
-8
lines changed

6 files changed

+39
-8
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["latest"]
3+
}

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var parser = require('./libs/parser');
1818
var variable = require('./libs/variable');
1919
var { IfBlock, WhileBlock, ForeachBlock } = require('./libs/block');
2020

21-
class StoryScript {
21+
export default class StoryScript {
2222
constructor() {
2323
this.BLOCKSTACK = [];
2424
this.CURRENTBLOCK = null;
@@ -54,7 +54,7 @@ class StoryScript {
5454

5555
const scopes = [object.blocks[0].scope];
5656

57-
for (const i = 0; i < object.blocks.length; i++) {
57+
for (let i = 0; i < object.blocks.length; i++) {
5858
const block = object.blocks[i];
5959
const nextBlock = object.blocks[i + 1];
6060
const lastLine = block.currentLine - 1;
@@ -198,4 +198,4 @@ class StoryScript {
198198
}
199199
}
200200

201-
module.exports = StoryScript;
201+
// module.exports = StoryScript;

libs/block.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
var parser = require('./parser');
1817
var variable = require('./variable');
1918

2019
class IfBlock {

libs/variable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
const GLOBAL = {},
17+
let GLOBAL = {},
1818
SAVE = {},
1919
SCOPES = [];
20-
let CURRENTSCOPE = {}
20+
let CURRENTSCOPE = {};
2121

2222
function calculate(exp, node=0) {
2323
switch (exp.type) {

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
"name": "avg-storyscript",
33
"version": "0.0.1",
44
"description": "Build-in Story Script System for AVG.js.",
5-
"main": "index.js",
5+
"main": "dist/index.js",
66
"scripts": {
7+
"build": "webpack --progress --colors",
78
"test": "echo \"Error: no test specified\" && exit 1"
89
},
910
"keywords": [
@@ -15,7 +16,11 @@
1516
"author": "Icemic Jia <[email protected]>",
1617
"license": "Apache-2.0",
1718
"dependencies": {
18-
"ohm-js": "^0.12.3"
19+
"babel-core": "^6.17.0",
20+
"babel-loader": "^6.2.5",
21+
"babel-preset-latest": "^6.16.0",
22+
"ohm-js": "^0.12.3",
23+
"webpack": "^1.13.2"
1924
},
2025
"devDependencies": {
2126
"chai": "^3.5.0",

webpack.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var path = require('path');
2+
3+
module.exports = {
4+
entry: "./index.js",
5+
output: {
6+
path: path.resolve(__dirname, './dist'),
7+
filename: "index.js",
8+
libraryTarget: 'umd'
9+
},
10+
resolve: {
11+
extensions: ['', '.js']
12+
},
13+
module: {
14+
loaders: [
15+
{ test: /\.js$/, exclude: /node_modules/, loader: "babel-loader"},
16+
]
17+
},
18+
devServer: {
19+
historyApiFallback: true,
20+
hot: true,
21+
inline: true,
22+
progress: true,
23+
}
24+
};

0 commit comments

Comments
 (0)