Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add a simple babel build step #327

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"presets": [
"env"
],
"plugins": [
"transform-es2015-modules-umd"
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
build/npm*
node_modules
npm-debug.log
dist
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "tween.js",
"description": "Super simple, fast and easy to use tweening engine which incorporates optimised Robert Penner's equations.",
"version": "0.0.0-development",
"main": "src/Tween.js",
"main": "dist/TWEEN.js",
"homepage": "https://github.com/tweenjs/tween.js",
"repository": {
"type": "git",
Expand All @@ -18,14 +18,19 @@
],
"dependencies": {},
"scripts": {
"test": "npm run test-unit && npm run test-correctness && npm run test-style",
"test": "npm run build && npm run test-unit && npm run test-correctness && npm run test-style",
"test-unit": "nodeunit test/unit/nodeunitheadless.js",
"test-correctness": "jshint --config test/jshintrc src/Tween.js",
"test-style": "jscs --config test/jscs.json src/Tween.js",
"test-correctness": "jshint --config test/jshintrc src/TWEEN.js",
"test-style": "jscs --config test/jscs.json src/TWEEN.js",
"build": "babel src --out-dir dist",
"prepublish": "npm run test",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
"author": "tween.js contributors (https://github.com/tweenjs/tween.js/graphs/contributors)",
"devDependencies": {
"babel-cli": "^6.24.0",
"babel-plugin-transform-es2015-modules-umd": "^6.24.0",
"babel-preset-env": "^1.2.2",
"jscs": "^2.2.0",
"jshint": "^2.8.0",
"nodeunit": "^0.9.1",
Expand Down
34 changes: 6 additions & 28 deletions src/Tween.js → src/TWEEN.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* Thank you all, you're awesome!
*/

var TWEEN = TWEEN || (function () {
const TWEEN = (function () {

var _tweens = [];
let _tweens = [];

return {

Expand All @@ -33,7 +33,7 @@ var TWEEN = TWEEN || (function () {

remove: function (tween) {

var i = _tweens.indexOf(tween);
const i = _tweens.indexOf(tween);

if (i !== -1) {
_tweens.splice(i, 1);
Expand All @@ -47,7 +47,7 @@ var TWEEN = TWEEN || (function () {
return false;
}

var i = 0;
let i = 0;

time = time !== undefined ? time : TWEEN.now();

Expand All @@ -73,7 +73,7 @@ var TWEEN = TWEEN || (function () {
// In node.js, use process.hrtime.
if (typeof (window) === 'undefined' && typeof (process) !== 'undefined') {
TWEEN.now = function () {
var time = process.hrtime();
const time = process.hrtime();

// Convert [seconds, nanoseconds] to milliseconds.
return time[0] * 1000 + time[1] / 1000000;
Expand Down Expand Up @@ -857,26 +857,4 @@ TWEEN.Interpolation = {

};

// UMD (Universal Module Definition)
(function (root) {

if (typeof define === 'function' && define.amd) {

// AMD
define([], function () {
return TWEEN;
});

} else if (typeof module !== 'undefined' && typeof exports === 'object') {

// Node.js
module.exports = TWEEN;

} else if (root !== undefined) {

// Global variable
root.TWEEN = TWEEN;

}

})(this);
module.exports = TWEEN;
1 change: 1 addition & 0 deletions test/jshintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"esversion": 6,
"node": true,
"browser": true,
"curly": true,
Expand Down
2 changes: 1 addition & 1 deletion test/unit/nodeunitheadless.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// We will unit test both the original library and the minified version
var TWEEN_uncompressed = require('../../src/Tween.js');
var TWEEN_uncompressed = require('../../dist/TWEEN.js');
var getTests = require('./tests');

module.exports = {
Expand Down