add browser build - closes #17
This commit is contained in:
parent
2a2b2c427a
commit
439b378ebf
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@ test/tmp
|
|||||||
*.cache
|
*.cache
|
||||||
/templates.json
|
/templates.json
|
||||||
coverage
|
coverage
|
||||||
|
dist
|
||||||
|
|||||||
@ -6,3 +6,4 @@ test
|
|||||||
benchmark
|
benchmark
|
||||||
Makefile
|
Makefile
|
||||||
.*
|
.*
|
||||||
|
dist
|
||||||
|
|||||||
22
Makefile
22
Makefile
@ -6,7 +6,7 @@ export NODE_ENV = test
|
|||||||
.PHONY: clean test test-cov test-travis publish bench build
|
.PHONY: clean test test-cov test-travis publish bench build
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf coverage templates.json test/tmp build
|
rm -rf coverage templates.json test/tmp dist
|
||||||
|
|
||||||
test:
|
test:
|
||||||
$(MOCHA_CMD)
|
$(MOCHA_CMD)
|
||||||
@ -16,7 +16,7 @@ bench:
|
|||||||
node node_modules/matcha/bin/_matcha
|
node node_modules/matcha/bin/_matcha
|
||||||
|
|
||||||
test-cov:
|
test-cov:
|
||||||
make clean
|
rm -rf coverage
|
||||||
node $(ISTANBUL_CMD) $(MOCHA_CMD) --
|
node $(ISTANBUL_CMD) $(MOCHA_CMD) --
|
||||||
rm -rf test/tmp
|
rm -rf test/tmp
|
||||||
|
|
||||||
@ -25,22 +25,26 @@ test-travis:
|
|||||||
if test -n "$$CODECLIMATE_REPO_TOKEN"; then codeclimate < coverage/lcov.info; fi
|
if test -n "$$CODECLIMATE_REPO_TOKEN"; then codeclimate < coverage/lcov.info; fi
|
||||||
|
|
||||||
build:
|
build:
|
||||||
mkdir build
|
rm -rf dist
|
||||||
cd build
|
mkdir dist
|
||||||
browserify lib/6to5/transform.js >6to5.js
|
|
||||||
uglifyjs 6to5.js >6to5.min.js
|
node bin/cache-templates
|
||||||
|
|
||||||
|
browserify lib/6to5/transform.js -s to5 >dist/6to5.js
|
||||||
|
uglifyjs dist/6to5.js >dist/6to5.min.js
|
||||||
|
|
||||||
|
rm -rf templates.json
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
make clean
|
|
||||||
|
|
||||||
rm -rf node_modules
|
rm -rf node_modules
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
node bin/cache-templates
|
node bin/cache-templates
|
||||||
make test
|
make test
|
||||||
|
|
||||||
|
test -f templates.json
|
||||||
npm publish
|
npm publish
|
||||||
|
|
||||||
# todo - auto-create tag
|
# todo - auto-create tag
|
||||||
|
|
||||||
make clean
|
rm -rf templates.json
|
||||||
|
|||||||
16
README.md
16
README.md
@ -156,6 +156,22 @@ polyfill is also required negating the [polyfill caveat](#polyfill).
|
|||||||
require("6to5/register");
|
require("6to5/register");
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Browser
|
||||||
|
|
||||||
|
You can build a browser version of the compiler by running the following in the
|
||||||
|
6to5 directory:
|
||||||
|
|
||||||
|
$ make build
|
||||||
|
|
||||||
|
This will output the files `dist/6to5.js` and `dist/6to5.min.js`.
|
||||||
|
|
||||||
|
Just include one of those in the browser and access the transform method via the
|
||||||
|
global `to5`.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
to5("class Test {}").code;
|
||||||
|
```
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
|
|
||||||
6to5 modules compile straight to CommonJS, because of this various liberties are
|
6to5 modules compile straight to CommonJS, because of this various liberties are
|
||||||
|
|||||||
@ -201,11 +201,11 @@ exports.repeat = function (width, cha) {
|
|||||||
return new Array(width + 1).join(cha);
|
return new Array(width + 1).join(cha);
|
||||||
};
|
};
|
||||||
|
|
||||||
var templatesCacheLoc = __dirname + "/../../templates.json";
|
try {
|
||||||
|
exports.templates = require("../../templates.json");
|
||||||
|
} catch (err) {
|
||||||
|
if (err.code !== "MODULE_NOT_FOUND") throw err;
|
||||||
|
|
||||||
if (fs.existsSync(templatesCacheLoc)) {
|
|
||||||
exports.templates = require(templatesCacheLoc);
|
|
||||||
} else {
|
|
||||||
exports.templates = {};
|
exports.templates = {};
|
||||||
|
|
||||||
var templatesLoc = __dirname + "/templates";
|
var templatesLoc = __dirname + "/templates";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user