Skip to content
This repository was archived by the owner on Mar 2, 2021. It is now read-only.

Commit 045da55

Browse files
Cleanup and integrated minprops
1 parent 4c9995e commit 045da55

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ npm install markoify --save
1212
# Usage:
1313

1414
```bash
15-
browserify -t markoify --extension=".marko" main.js -o browser.js
15+
browserify -g markoify --extension=".marko" main.js -o browser.js
1616
```
1717

1818
# Example

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@
2323
"escodegen": "^1.8.0",
2424
"esprima": "^3.1.3",
2525
"estraverse": "^4.2.0",
26-
"raptor-async": "^1.1.2",
26+
"minprops": "^1.0.0",
2727
"through": "^2.3.8"
2828
},
2929
"devDependencies": {
3030
"browserify": "^14.0.0",
3131
"chai": "^3.5.0",
32-
"mocha": "^3.2.0",
33-
"view-engine": "^1.1.1"
32+
"marko": "^4.0.0-rc.24",
33+
"mocha": "^3.2.0"
3434
},
35-
"license": "Apache License v2.0",
35+
"license": "Apache-2.0",
3636
"bin": {},
3737
"main": "src/index.js",
3838
"publishConfig": {

src/index.js

+12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ var estraverse = require('estraverse');
77
var parseOpts = {};
88
var through = require('through');
99
var compiler = require('marko/compiler');
10+
var minprops = require('minprops');
11+
12+
var isDevelopment =
13+
!process.env.NODE_ENV ||
14+
process.env.NODE_ENV === 'development' ||
15+
process.env.NODE_ENV === 'dev';
16+
17+
var minpropsEnabled = !isDevelopment;
1018

1119
function transformAST(file, input, callback) {
1220
var ast = esprima.parse(input, parseOpts);
@@ -65,6 +73,10 @@ module.exports = function transform(file) {
6573
} else {
6674
input = compiler.compile(input, file);
6775
}
76+
} else {
77+
if (minpropsEnabled) {
78+
input = minprops(input, file);
79+
}
6880
}
6981

7082
if (input.indexOf('.marko') === -1) {

0 commit comments

Comments
 (0)