Skip to content

Commit

Permalink
Refactor project to use Rollup for packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
jgarber623 committed May 15, 2018
1 parent 244100c commit 8af0e37
Show file tree
Hide file tree
Showing 17 changed files with 790 additions and 305 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
dist/*
scripts/*
spec/*
7 changes: 3 additions & 4 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
extends: 'eslint:recommended'
parserOptions:
sourceType: module
env:
browser: true
es6: true
extends: 'eslint:recommended'
globals:
define: true
module: true
rules:
indent:
- error
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ language: node_js
node_js:
- 8
- 9
- 10
cache:
directories:
- node_modules
Expand Down
25 changes: 13 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
I'd love to have your help improving CashCash! If you'd like to pitch in, you can do so in a number of ways:

1. Look through open [Issues](https://github.com/jgarber623/CashCash/issues).
2. Review any open [Pull Requests](https://github.com/jgarber623/CashCash/pulls).
3. [Fork CashCash](#get-set-up-to-contribute) and fix an open Issue or add your own feature.
4. File new Issues if you have a good idea or see a bug and don't know how to fix it yourself. _Only do this after you've made sure the behavior or problem you're seeing isn't already documented in an open Issue._
1. Review any open [Pull Requests](https://github.com/jgarber623/CashCash/pulls).
1. [Fork CashCash](#get-set-up-to-contribute) and fix an open Issue or add your own feature.
1. File new Issues if you have a good idea or see a bug and don't know how to fix it yourself. _Only do this after you've made sure the behavior or problem you're seeing isn't already documented in an open Issue._

I definitely appreciate your interest in (and help improving) CashCash. Thanks!

Expand All @@ -24,15 +24,16 @@ If you're using a different operating system, use a different package manager, o
Contributing to CashCash is pretty straightforward:

1. Fork the CashCash repo and clone it.
2. Install development dependencies by running `npm install` from the root of the project.
3. Create a feature branch for the issue or new feature you're looking to tackle: `git checkout -b your-descriptive-branch-name`.
4. _Write some code!_
5. If your changes would benefit from testing, add the necessary tests and verify everything passes by running `npm test`.
6. Commit your changes: `git commit -am 'Add some new feature or fix some issue'`.
7. Push the branch to your fork of CashCash: `git push origin your-descriptive-branch-name`.
8. Create a new Pull Request and I'll give it a look!

## "But what files do I change?!?"
1. Install development dependencies by running `npm install` from the root of the project.
1. Create a feature branch for the issue or new feature you're looking to tackle: `git checkout -b your-descriptive-branch-name`.
1. Run `npm start` which instructs [Rollup](https://rollupjs.org) to watch `src/cashcash.js` for changes and automatically exports built files to the `dist` folder.
1. _Write some code!_
1. If your changes would benefit from testing, add the necessary tests and verify everything passes by running `npm test`.
1. Commit your changes: `git commit -am 'Add some new feature or fix some issue'`.
1. Push the branch to your fork of CashCash: `git push origin your-descriptive-branch-name`.
1. Create a new Pull Request and I'll give it a look!

## "But which files do I change?!?"

Excellent question. CashCash's source code is in the file `src/cashcash.js`. Make your changes here!

Expand Down
21 changes: 5 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,11 @@

CashCash is also really tiny:

<table>
<tbody>
<tr>
<th align="left">Uncompressed</th>
<td>1,429 bytes</td>
</tr>
<tr>
<th align="left">Minified</th>
<td>888 bytes</td>
</tr>
<tr>
<th align="left">Minified and gzipped</th>
<td>523 bytes</td>
</tr>
</tbody>
</table>
| Format | File Size | Gzipped Size |
|:-----------------------|:------------|:-------------|
| Uncompressed (module) | 1,072 bytes | 516 bytes |
| Uncompressed (browser) | 1,366 bytes | 613 bytes |
| Minified (browser) | 870 bytes | 516 bytes |

## Getting CashCash

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cashcash",
"description": "A very small DOM library inspired by jQuery.",
"version": "1.1.0",
"version": "1.2.0",
"main": "dist/cashcash.js",
"moduleType": [
"globals",
Expand Down
39 changes: 39 additions & 0 deletions dist/cashcash.es.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*!
* CashCash v1.2.0
*
* A very small DOM library inspired by jQuery.
*
* Source code available at: https://github.com/jgarber623/CashCash
*
* (c) 2016-present Jason Garber (https://sixtwothree.org)
*
* CashCash may be freely distributed under the MIT license.
*/

var Cash = function(selector, context) {
selector = typeof selector === "string" ? selector.trim() : "";
if (selector.length) {
selector = typeof context === "string" && context.trim().length ? context.trim() + " " + selector : selector;
context = context instanceof HTMLElement ? context : document;
var elements = context.querySelectorAll(selector), count = elements.length;
this.length = count;
this.context = context;
this.selector = selector;
while (count--) {
this[count] = elements[count];
}
}
};

var CashCash = function(selector, context) {
return new Cash(selector, context);
};

Cash.prototype = CashCash.prototype = {
length: 0,
toArray: function() {
return Array.prototype.slice.call(this);
}
};

export default CashCash;
16 changes: 5 additions & 11 deletions dist/cashcash.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* CashCash 1.1.0
* CashCash v1.2.0
*
* A very small DOM library inspired by jQuery.
*
Expand All @@ -10,15 +10,9 @@
* CashCash may be freely distributed under the MIT license.
*/

(function(root, factory) {
if (typeof define === "function" && define.amd) {
define([], factory);
} else if (typeof module === "object" && module.exports) {
module.exports = factory();
} else {
root.CashCash = factory();
}
})(typeof self !== "undefined" ? self : this, function() {
(function(global, factory) {
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global.CashCash = factory();
})(this, function() {
"use strict";
var Cash = function(selector, context) {
selector = typeof selector === "string" ? selector.trim() : "";
Expand All @@ -44,4 +38,4 @@
}
};
return CashCash;
});
});
4 changes: 2 additions & 2 deletions dist/cashcash.min.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* CashCash 1.1.0
* CashCash v1.2.0
*
* A very small DOM library inspired by jQuery.
*
Expand All @@ -10,4 +10,4 @@
* CashCash may be freely distributed under the MIT license.
*/

!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():t.CashCash=e()}("undefined"!=typeof self?self:this,function(){"use strict";var t=function(t,e){if(t="string"==typeof t?t.trim():"",t.length){t="string"==typeof e&&e.trim().length?e.trim()+" "+t:t,e=e instanceof HTMLElement?e:document;var n=e.querySelectorAll(t),o=n.length;for(this.length=o,this.context=e,this.selector=t;o--;)this[o]=n[o]}},e=function(e,n){return new t(e,n)};return t.prototype=e.prototype={length:0,toArray:function(){return Array.prototype.slice.call(this)}},e});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.CashCash=e()}(this,function(){"use strict";var t=function(t,e){if((t="string"==typeof t?t.trim():"").length){t="string"==typeof e&&e.trim().length?e.trim()+" "+t:t;var n=(e=e instanceof HTMLElement?e:document).querySelectorAll(t),o=n.length;for(this.length=o,this.context=e,this.selector=t;o--;)this[o]=n[o]}},e=function(e,n){return new t(e,n)};return t.prototype=e.prototype={length:0,toArray:function(){return Array.prototype.slice.call(this)}},e});
2 changes: 1 addition & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h1>CashCash: Example</h1>
<p id="paragraph-4">Morbi lacinia et dui a convallis. Donec vel leo vel tortor ultricies suscipit sit amet in neque. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam euismod lectus aliquam, cursus massa eget, luctus enim. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis mollis, velit at varius cursus, leo quam porta justo, nec ornare sapien nulla nec eros. Praesent ligula ligula, condimentum a nulla ac, ultricies accumsan sapien. Aenean condimentum tortor et nulla gravida, ut efficitur enim placerat. Sed fermentum tempus pellentesque. Morbi porttitor orci a enim ornare, a sodales mi congue. Proin a consectetur ipsum.</p>
</main>

<script src="../src/cashcash.js"></script>
<script src="../dist/cashcash.js"></script>
<script>
var $main = CashCash('main'),
$h1 = CashCash('h1', $main[0]),
Expand Down
Loading

0 comments on commit 8af0e37

Please sign in to comment.