diff --git a/.gitignore b/.gitignore index ebbf4927a..25d810f46 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ /.DS_Store /.sass-cache /npm-debug.log* +/stats.html /yarn-error.log diff --git a/package.json b/package.json index 9712a3456..5a1926a1a 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,16 @@ "module": "dist/js/shepherd.esm.js", "dependencies": { "element-matches": "^0.1.2", - "lodash-es": "^4.17.11", + "lodash.debounce": "^4.0.8", + "lodash.defer": "^4.1.0", + "lodash.forown": "^4.4.0", + "lodash.iselement": "^4.1.1", + "lodash.isfunction": "^3.0.9", + "lodash.isnumber": "^3.0.3", + "lodash.isobjectlike": "^4.0.0", + "lodash.isstring": "^4.0.1", + "lodash.isundefined": "^3.0.1", + "lodash.zipobject": "^4.1.3", "tippy.js": "^4.3.0" }, "devDependencies": { @@ -77,6 +86,7 @@ "postcss": "^7.0.14", "replace": "^1.1.0", "rollup": "^1.10.1", + "rollup-plugin-analyzer": "^3.0.0", "rollup-plugin-babel": "^4.3.2", "rollup-plugin-browsersync": "^1.0.0", "rollup-plugin-commonjs": "^9.3.4", @@ -89,6 +99,7 @@ "rollup-plugin-sass": "^1.2.2", "rollup-plugin-stylelint": "^0.0.4", "rollup-plugin-terser": "^4.0.4", + "rollup-plugin-visualizer": "^1.1.1", "sinon": "^7.3.2", "start-server-and-test": "^1.9.0", "stylelint": "^10.0.1", diff --git a/rollup.config.js b/rollup.config.js index c87ea362d..95f5b8aef 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -13,6 +13,7 @@ import resolve from 'rollup-plugin-node-resolve'; import sass from 'rollup-plugin-sass'; import stylelint from 'rollup-plugin-stylelint'; import { terser } from 'rollup-plugin-terser'; +import visualizer from 'rollup-plugin-visualizer'; const pkg = require('./package.json'); const banner = ['/*!', pkg.name, pkg.version, '*/\n'].join(' '); @@ -90,6 +91,7 @@ if (process.env.DEVELOPMENT) { plugins.push(license({ banner })); plugins.push(filesize()); +plugins.push(visualizer()); const rollupBuilds = [ // Generate unminifed bundle @@ -143,7 +145,8 @@ if (!process.env.DEVELOPMENT) { license({ banner }), - filesize() + filesize(), + visualizer() ] }); } diff --git a/src/js/evented.js b/src/js/evented.js index 4c9aa715f..5a64ef8c5 100644 --- a/src/js/evented.js +++ b/src/js/evented.js @@ -1,5 +1,5 @@ -import drop from 'lodash-es/drop'; -import isUndefined from 'lodash-es/isUndefined'; +import { drop } from './utils/general'; +import isUndefined from 'lodash.isundefined'; export class Evented { on(event, handler, ctx) { diff --git a/src/js/modal.js b/src/js/modal.js index 3fc732b62..da55a81ed 100644 --- a/src/js/modal.js +++ b/src/js/modal.js @@ -6,8 +6,8 @@ import { classNames as modalClassNames } from './utils/modal'; import { addStepEventListeners, getElementForStep } from './utils/dom'; -import debounce from 'lodash-es/debounce'; -import defer from 'lodash-es/defer'; +import debounce from 'lodash.debounce'; +import defer from 'lodash.defer'; export class Modal { constructor(options) { diff --git a/src/js/step.js b/src/js/step.js index 4c08640f0..678b3dad1 100644 --- a/src/js/step.js +++ b/src/js/step.js @@ -1,9 +1,8 @@ -import forOwn from 'lodash-es/forOwn'; -import isElement from 'lodash-es/isElement'; -import isEmpty from 'lodash-es/isEmpty'; -import isFunction from 'lodash-es/isFunction'; -import isString from 'lodash-es/isString'; -import isUndefined from 'lodash-es/isUndefined'; +import forOwn from 'lodash.forown'; +import isElement from 'lodash.iselement'; +import isFunction from 'lodash.isfunction'; +import isString from 'lodash.isstring'; +import isUndefined from 'lodash.isundefined'; import { Evented } from './evented.js'; import 'element-matches'; import { bindAdvance, bindButtonEvents, bindCancelLink, bindMethods } from './utils/bind.js'; @@ -143,7 +142,7 @@ export class Step extends Evented { * @param {HTMLElement} content The element for the step, to append the footer with buttons to */ _addButtons(content) { - if (!isEmpty(this.options.buttons)) { + if (Array.isArray(this.options.buttons) && this.options.buttons.length) { const footer = document.createElement('footer'); const buttons = createFromHTML(''); diff --git a/src/js/tour.js b/src/js/tour.js index f467df79b..ac41dbccf 100644 --- a/src/js/tour.js +++ b/src/js/tour.js @@ -1,8 +1,7 @@ -import isEmpty from 'lodash-es/isEmpty'; -import isFunction from 'lodash-es/isFunction'; -import isNumber from 'lodash-es/isNumber'; -import isString from 'lodash-es/isString'; -import isUndefined from 'lodash-es/isUndefined'; +import isFunction from 'lodash.isfunction'; +import isNumber from 'lodash.isnumber'; +import isString from 'lodash.isstring'; +import isUndefined from 'lodash.isundefined'; import { Evented } from './evented.js'; import { Modal } from './modal.js'; import { Step } from './step.js'; @@ -153,7 +152,7 @@ export class Tour extends Evented { * @param {String} event The event name to trigger */ done(event) { - if (!isEmpty(this.steps)) { + if (Array.isArray(this.steps)) { this.steps.forEach((step) => step.destroy()); } diff --git a/src/js/utils/bind.js b/src/js/utils/bind.js index dd6363478..2d236aefc 100644 --- a/src/js/utils/bind.js +++ b/src/js/utils/bind.js @@ -1,7 +1,7 @@ import { parseShorthand } from './general.js'; -import forOwn from 'lodash-es/forOwn'; -import isString from 'lodash-es/isString'; -import isUndefined from 'lodash-es/isUndefined'; +import forOwn from 'lodash.forown'; +import isString from 'lodash.isstring'; +import isUndefined from 'lodash.isundefined'; /** * Sets up the handler to determine if we should advance the tour diff --git a/src/js/utils/general.js b/src/js/utils/general.js index c6501fd07..e49043c63 100644 --- a/src/js/utils/general.js +++ b/src/js/utils/general.js @@ -1,7 +1,7 @@ -import isObjectLike from 'lodash-es/isObjectLike'; -import isString from 'lodash-es/isString'; -import isUndefined from 'lodash-es/isUndefined'; -import zipObject from 'lodash-es/zipObject'; +import isObjectLike from 'lodash.isobjectlike'; +import isString from 'lodash.isstring'; +import isUndefined from 'lodash.isundefined'; +import zipObject from 'lodash.zipobject'; import tippy from 'tippy.js'; import { missingTippy } from './error-messages'; @@ -36,6 +36,20 @@ export function createFromHTML(html) { return el.children[0]; } +/** + * Creates a slice of `arr` with n elements dropped from the beginning. + * @param {Array} arr + * @param {Number} n + * @return {*} + */ +export function drop(arr, n = 1) { + if (Array.isArray(arr)) { + return arr.slice(n); + } + + return []; +} + /** * Parse the position object or string to return the attachment and element to attach to * @param {Object|String} position Either a string or object denoting the selector and position for attachment diff --git a/yarn.lock b/yarn.lock index 85b7f5209..e79fb25ac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5785,11 +5785,6 @@ locate-path@^3.0.0: p-locate "^3.0.0" path-exists "^3.0.0" -lodash-es@^4.17.11: - version "4.17.11" - resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.11.tgz#145ab4a7ac5c5e52a3531fb4f310255a152b4be0" - integrity sha512-DHb1ub+rMjjrxqlB3H56/6MXtm1lSksDp2rA2cNWjG8mlDUYFhUj3Di2Zn5IwSU87xLv8tNIQ7sSwE/YOX/D/Q== - lodash.assignin@^4.0.9: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.assignin/-/lodash.assignin-4.2.0.tgz#ba8df5fb841eb0a3e8044232b0e263a8dc6a28a2" @@ -5805,11 +5800,21 @@ lodash.camelcase@^4.3.0: resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" integrity sha1-soqmKIorn8ZRA1x3EfZathkDMaY= +lodash.debounce@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" + integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168= + lodash.defaults@^4.0.1: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c" integrity sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw= +lodash.defer@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/lodash.defer/-/lodash.defer-4.1.0.tgz#e9c158a961de1a46ea24fda34685b4ccdd358f3f" + integrity sha1-6cFYqWHeGkbqJP2jRoW0zN01jz8= + lodash.filter@^4.4.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.filter/-/lodash.filter-4.6.0.tgz#668b1d4981603ae1cc5a6fa760143e480b4c4ace" @@ -5825,11 +5830,46 @@ lodash.foreach@^4.3.0: resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53" integrity sha1-Gmo16s5AEoDH8G3d7DUWWrJ+PlM= +lodash.forown@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.forown/-/lodash.forown-4.4.0.tgz#85115cf04f73ef966eced52511d3893cc46683af" + integrity sha1-hRFc8E9z75ZuztUlEdOJPMRmg68= + +lodash.iselement@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lodash.iselement/-/lodash.iselement-4.1.1.tgz#f678d4f6f3a964f9ec7f115f2546f3e4a0ba82ca" + integrity sha1-9njU9vOpZPnsfxFfJUbz5KC6gso= + lodash.isfinite@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/lodash.isfinite/-/lodash.isfinite-3.3.2.tgz#fb89b65a9a80281833f0b7478b3a5104f898ebb3" integrity sha1-+4m2WpqAKBgz8LdHizpRBPiY67M= +lodash.isfunction@^3.0.9: + version "3.0.9" + resolved "https://registry.yarnpkg.com/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz#06de25df4db327ac931981d1bdb067e5af68d051" + integrity sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw== + +lodash.isnumber@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz#3ce76810c5928d03352301ac287317f11c0b1ffc" + integrity sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w= + +lodash.isobjectlike@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/lodash.isobjectlike/-/lodash.isobjectlike-4.0.0.tgz#742c5fc65add27924d3d24191681aa9a17b2b60d" + integrity sha1-dCxfxlrdJ5JNPSQZFoGqmheytg0= + +lodash.isstring@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451" + integrity sha1-1SfftUVuynzJu5XV2ur4i6VKVFE= + +lodash.isundefined@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash.isundefined/-/lodash.isundefined-3.0.1.tgz#23ef3d9535565203a66cefd5b830f848911afb48" + integrity sha1-I+89lTVWUgOmbO/VuDD4SJEa+0g= + lodash.map@^4.4.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3" @@ -5880,6 +5920,11 @@ lodash.uniq@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= +lodash.zipobject@^4.1.3: + version "4.1.3" + resolved "https://registry.yarnpkg.com/lodash.zipobject/-/lodash.zipobject-4.1.3.tgz#b399f5aba8ff62a746f6979bf20b214f964dbef8" + integrity sha1-s5n1q6j/YqdG9peb8gshT5ZNvvg= + lodash@4.17.11, lodash@^4.1.0, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.4, lodash@^4.2.0: version "4.17.11" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" @@ -6603,6 +6648,13 @@ opn@5.3.0: dependencies: is-wsl "^1.1.0" +opn@^5.4.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/opn/-/opn-5.5.0.tgz#fc7164fab56d235904c51c3b27da6758ca3b9bfc" + integrity sha512-PqHpggC9bLV0VeWcdKhkpxY+3JTzetLSqTCWL/z/tFIbI6G8JCjondXklT1JinczLz2Xib62sSp0T/gKT4KksA== + dependencies: + is-wsl "^1.1.0" + optimist@0.6.x, optimist@^0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" @@ -8055,6 +8107,11 @@ rimraf@2.6.3, rimraf@^2.2.8, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2, rimraf dependencies: glob "^7.1.3" +rollup-plugin-analyzer@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-analyzer/-/rollup-plugin-analyzer-3.0.0.tgz#284f67f213529a34cd1dd306a6f438b96c60321d" + integrity sha512-xokEBlQEdpN3mAXtJT8plDjdQKBKyfNxT1tyGJCq+xi0da3FNJ8RyLcve0fV1IVZAfBGsv8sXwWO8yNSGR2e7w== + rollup-plugin-babel@^4.3.2: version "4.3.2" resolved "https://registry.yarnpkg.com/rollup-plugin-babel/-/rollup-plugin-babel-4.3.2.tgz#8c0e1bd7aa9826e90769cf76895007098ffd1413" @@ -8166,6 +8223,16 @@ rollup-plugin-terser@^4.0.4: serialize-javascript "^1.6.1" terser "^3.14.1" +rollup-plugin-visualizer@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/rollup-plugin-visualizer/-/rollup-plugin-visualizer-1.1.1.tgz#454ae0aed23845407ebfb81cc52114af308d6d90" + integrity sha512-7xkSKp+dyJmSC7jg2LXqViaHuOnF1VvIFCnsZEKjrgT5ZVyiLLSbeszxFcQSfNJILphqgAEmWAUz0Z4xYScrRw== + dependencies: + mkdirp "^0.5.1" + opn "^5.4.0" + source-map "^0.7.3" + typeface-oswald "0.0.54" + "rollup-pluginutils@>= 1.3.1", rollup-pluginutils@^2.0.1, rollup-pluginutils@^2.3.0, rollup-pluginutils@^2.3.3, rollup-pluginutils@^2.6.0: version "2.6.0" resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.6.0.tgz#203706edd43dfafeaebc355d7351119402fc83ad" @@ -8581,6 +8648,11 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== +source-map@^0.7.3: + version "0.7.3" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" + integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== + sourcemap-codec@^1.4.1, sourcemap-codec@^1.4.4: version "1.4.4" resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.4.tgz#c63ea927c029dd6bd9a2b7fa03b3fec02ad56e9f" @@ -9324,6 +9396,11 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= +typeface-oswald@0.0.54: + version "0.0.54" + resolved "https://registry.yarnpkg.com/typeface-oswald/-/typeface-oswald-0.0.54.tgz#1e253011622cdd50f580c04e7d625e7f449763d7" + integrity sha512-U1WMNp4qfy4/3khIfHMVAIKnNu941MXUfs3+H9R8PFgnoz42Hh9pboSFztWr86zut0eXC8byalmVhfkiKON/8Q== + ua-parser-js@0.7.17: version "0.7.17" resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac"