Skip to content

Commit

Permalink
Optimize bundles by stripping comments from main and module bundles (#…
Browse files Browse the repository at this point in the history
…394)

This PR adds `comments = false` to the babel config to help optimize the bundles.
  • Loading branch information
sebnitu authored Sep 14, 2020
1 parent 8a55089 commit 3120289
Show file tree
Hide file tree
Showing 15 changed files with 583 additions and 2,871 deletions.
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = (api) => {
} else {
config.presets = ['@babel/preset-env'];
config.plugins = ['@babel/plugin-transform-runtime'];
config.comments = false;
}

return config;
Expand Down
1,530 changes: 300 additions & 1,230 deletions docs/dist/scripts.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions docs/dist/scripts.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"dependencies": {
"feather-icons": "^4.28.0",
"list.js": "^1.5.0",
"scroll-stash": "^1.1.0",
"scroll-stash": "^1.1.1",
"svgxuse": "^1.2.6",
"vrembem": "^1.22.1",
"wicg-inert": "^3.0.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/checkbox/dist/scripts.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

var Checkbox = /*#__PURE__*/function () {
var Checkbox = function () {
function Checkbox(options) {
classCallCheck(this, Checkbox);

Expand Down
2 changes: 1 addition & 1 deletion packages/checkbox/dist/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

var Checkbox = /*#__PURE__*/function () {
var Checkbox = function () {
function Checkbox(options) {
classCallCheck(this, Checkbox);

Expand Down
54 changes: 1 addition & 53 deletions packages/core/dist/scripts.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ var setTabindex = function setTabindex(state, selector) {
}
};

/**
* Adds a class or classes to an element or NodeList
* ---
* @param {Node || NodeList} el - Element(s) to add class(es) to
* @param {String || Array} cl - Class(es) to add
*/
var addClass = function addClass(el) {
for (var _len = arguments.length, cl = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
cl[_key - 1] = arguments[_key];
Expand All @@ -56,12 +50,6 @@ var addClass = function addClass(el) {
});
};

/**
* Takes a hyphen cased string and converts it to camel case
* ---
* @param {String } str - the string to convert to camel case
* @returns {Boolean} - returns a camel cased string
*/
var camelCase = function camelCase(str) {
return str.replace(/-([a-z])/g, function (g) {
return g[1].toUpperCase();
Expand Down Expand Up @@ -110,7 +98,7 @@ var focusTrigger = function focusTrigger() {
obj.memory.trigger.focus();
obj.memory.trigger = null;
};
var FocusTrap = /*#__PURE__*/function () {
var FocusTrap = function () {
function FocusTrap() {
classCallCheck(this, FocusTrap);

Expand Down Expand Up @@ -191,26 +179,12 @@ var FocusTrap = /*#__PURE__*/function () {
return FocusTrap;
}();

/**
* Get an element(s) from a selector or return value if not a string
* ---
* @param {String} selector - Selector to query
* @param {Boolean} single - Whether to return a single or all matches
*/
var getElement = function getElement(selector) {
var single = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
if (typeof selector != 'string') return selector;
return single ? document.querySelector(selector) : document.querySelectorAll(selector);
};

/**
* Checks an element or NodeList whether they contain a class or classes
* Ref: https://davidwalsh.name/nodelist-array
* ---
* @param {Node} el - Element(s) to check class(es) on
* @param {String || Array} c - Class(es) to check
* @returns {Boolean} - Returns true if class exists, otherwise false
*/
var hasClass = function hasClass(el) {
el = el.forEach ? el : [el];
el = [].slice.call(el);
Expand All @@ -226,26 +200,12 @@ var hasClass = function hasClass(el) {
});
};

/**
* Takes a camel cased string and converts it to hyphen case
* ---
* @param {String } str - the string to convert to hyphen case
* @returns {Boolean} - returns a hyphen cased string
*/
var hyphenCase = function hyphenCase(str) {
return str.replace(/([a-z][A-Z])/g, function (g) {
return g[0] + '-' + g[1].toLowerCase();
});
};

/**
* Moves element(s) in the DOM based on a reference and move type
* ---
* @param {String} target - The element(s) to move
* @param {String} type - Move type can be 'after', 'before', 'append' or 'prepend'
* @param {String} reference - The reference element the move is relative to
*/

function moveElement(target, type) {
var reference = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;

Expand Down Expand Up @@ -295,12 +255,6 @@ function moveElement(target, type) {
}
}

/**
* Remove a class or classes from an element or NodeList
* ---
* @param {Node || NodeList} el - Element(s) to remove class(es) from
* @param {String || Array} cl - Class(es) to remove
*/
var removeClass = function removeClass(el) {
for (var _len = arguments.length, cl = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
cl[_key - 1] = arguments[_key];
Expand All @@ -314,12 +268,6 @@ var removeClass = function removeClass(el) {
});
};

/**
* Toggle a class or classes on an element or NodeList
* ---
* @param {Node || NodeList} el - Element(s) to toggle class(es) on
* @param {String || Array} cl - Class(es) to toggle
*/
var toggleClass = function toggleClass(el) {
for (var _len = arguments.length, cl = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
cl[_key - 1] = arguments[_key];
Expand Down
54 changes: 1 addition & 53 deletions packages/core/dist/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@
}
};

/**
* Adds a class or classes to an element or NodeList
* ---
* @param {Node || NodeList} el - Element(s) to add class(es) to
* @param {String || Array} cl - Class(es) to add
*/
var addClass = function addClass(el) {
for (var _len = arguments.length, cl = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
cl[_key - 1] = arguments[_key];
Expand All @@ -62,12 +56,6 @@
});
};

/**
* Takes a hyphen cased string and converts it to camel case
* ---
* @param {String } str - the string to convert to camel case
* @returns {Boolean} - returns a camel cased string
*/
var camelCase = function camelCase(str) {
return str.replace(/-([a-z])/g, function (g) {
return g[1].toUpperCase();
Expand Down Expand Up @@ -116,7 +104,7 @@
obj.memory.trigger.focus();
obj.memory.trigger = null;
};
var FocusTrap = /*#__PURE__*/function () {
var FocusTrap = function () {
function FocusTrap() {
classCallCheck(this, FocusTrap);

Expand Down Expand Up @@ -197,26 +185,12 @@
return FocusTrap;
}();

/**
* Get an element(s) from a selector or return value if not a string
* ---
* @param {String} selector - Selector to query
* @param {Boolean} single - Whether to return a single or all matches
*/
var getElement = function getElement(selector) {
var single = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
if (typeof selector != 'string') return selector;
return single ? document.querySelector(selector) : document.querySelectorAll(selector);
};

/**
* Checks an element or NodeList whether they contain a class or classes
* Ref: https://davidwalsh.name/nodelist-array
* ---
* @param {Node} el - Element(s) to check class(es) on
* @param {String || Array} c - Class(es) to check
* @returns {Boolean} - Returns true if class exists, otherwise false
*/
var hasClass = function hasClass(el) {
el = el.forEach ? el : [el];
el = [].slice.call(el);
Expand All @@ -232,26 +206,12 @@
});
};

/**
* Takes a camel cased string and converts it to hyphen case
* ---
* @param {String } str - the string to convert to hyphen case
* @returns {Boolean} - returns a hyphen cased string
*/
var hyphenCase = function hyphenCase(str) {
return str.replace(/([a-z][A-Z])/g, function (g) {
return g[0] + '-' + g[1].toLowerCase();
});
};

/**
* Moves element(s) in the DOM based on a reference and move type
* ---
* @param {String} target - The element(s) to move
* @param {String} type - Move type can be 'after', 'before', 'append' or 'prepend'
* @param {String} reference - The reference element the move is relative to
*/

function moveElement(target, type) {
var reference = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;

Expand Down Expand Up @@ -301,12 +261,6 @@
}
}

/**
* Remove a class or classes from an element or NodeList
* ---
* @param {Node || NodeList} el - Element(s) to remove class(es) from
* @param {String || Array} cl - Class(es) to remove
*/
var removeClass = function removeClass(el) {
for (var _len = arguments.length, cl = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
cl[_key - 1] = arguments[_key];
Expand All @@ -320,12 +274,6 @@
});
};

/**
* Toggle a class or classes on an element or NodeList
* ---
* @param {Node || NodeList} el - Element(s) to toggle class(es) on
* @param {String || Array} cl - Class(es) to toggle
*/
var toggleClass = function toggleClass(el) {
for (var _len = arguments.length, cl = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
cl[_key - 1] = arguments[_key];
Expand Down
Loading

0 comments on commit 3120289

Please sign in to comment.