From 7355c9e0919de70ac10cd23c48b9b4702bf7045a Mon Sep 17 00:00:00 2001 From: Mateusz Krzeszowiak Date: Wed, 3 Jul 2019 12:50:59 +0200 Subject: [PATCH] Small refactoring --- .gitignore | 1 + README.md | 4 +- build.js | 779 --------------------------------- cli.js | 2 +- config.sample.js | 28 +- lib/baseConfig.js | 2 +- lib/{optimize.js => bundle.js} | 4 +- lib/dependencies/collect.js | 5 +- lib/generate.js | 2 +- 9 files changed, 26 insertions(+), 801 deletions(-) delete mode 100644 build.js rename lib/{optimize.js => bundle.js} (93%) diff --git a/.gitignore b/.gitignore index 7174cf5..f204654 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ config.js +build.js # Created by https://www.gitignore.io/api/osx,node,windows,visualstudiocode # Edit at https://www.gitignore.io/?templates=osx,node,windows,visualstudiocode diff --git a/README.md b/README.md index 5307b57..5d58da0 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ modules: [ { name: 'foo/bar', create: true, - exclude: ['requirejs/require'], + exclude: ['bundles/common'], include: ['foo/bar/baz'], }, ]; @@ -77,7 +77,7 @@ modules: [ Promise.resolve({ name: 'foo/bar', create: true, - exclude: ['requirejs/require'], + exclude: ['bundles/common'], include: ['foo/bar/baz'], }), ]; diff --git a/build.js b/build.js deleted file mode 100644 index 43a4c41..0000000 --- a/build.js +++ /dev/null @@ -1,779 +0,0 @@ -module.exports = { - deps: ['text!js-translation.json'], - shim: { - 'jquery/jquery-migrate': ['jquery', 'jquery/jquery.cookie'], - 'jquery/jstree/jquery.hotkeys': { - deps: ['jquery'], - }, - 'jquery/hover-intent': { - deps: ['jquery'], - }, - 'mage/adminhtml/backup': { - deps: ['prototype'], - }, - 'mage/captcha': { - deps: ['prototype'], - }, - 'mage/common': { - deps: ['jquery'], - }, - 'mage/new-gallery': { - deps: ['jquery'], - }, - 'mage/webapi': { - deps: ['jquery'], - }, - 'jquery/ui': { - deps: ['jquery'], - }, - MutationObserver: { - deps: ['es6-collections'], - }, - moment: { - exports: 'moment', - }, - matchMedia: { - exports: 'mediaCheck', - }, - 'jquery/jquery-storageapi': { - deps: ['jquery/jquery.cookie'], - }, - 'MagePal_GoogleTagManager/js/datalayer': { - deps: ['Magento_Customer/js/customer-data'], - }, - paypalInContextExpressCheckout: { - exports: 'paypal', - }, - 'tiny_mce_4/tinymce.min': { - exports: 'tinyMCE', - }, - vimeoAPI: {}, - 'Magento_Tinymce3/tiny_mce/tiny_mce_src': { - exports: 'tinymce', - }, - isMobile: { - exports: 'isMobile', - }, - bootstrapDropdown: { - deps: ['jquery'], - }, - bootstrapSelect: { - deps: ['jquery', 'bootstrapDropdown'], - }, - 'mage/dataPost': { - deps: ['js/uenc-updater'], - }, - 'js/cms': { - deps: ['js/commons'], - }, - 'js/pdp': { - deps: ['js/commons'], - }, - 'js/category': { - deps: ['js/commons'], - }, - 'js/checkout': { - deps: ['js/commons'], - }, - 'js/customer': { - deps: ['js/commons'], - }, - 'js/styleguide': { - deps: ['js/commons'], - }, - 'js/contact': { - deps: ['js/commons'], - }, - 'fotorama/fotorama': ['jquery'], - }, - paths: { - 'jquery/ui': 'jquery/jquery-ui', - 'jquery/validate': 'jquery/jquery.validate', - 'jquery/hover-intent': 'jquery/jquery.hoverIntent', - 'jquery/file-uploader': 'jquery/fileUploader/jquery.fileupload-fp', - prototype: 'legacy-build.min', - 'jquery/jquery-storageapi': 'jquery/jquery.storageapi.min', - text: 'requirejs/text', - domReady: 'requirejs/domReady', - spectrum: 'jquery/spectrum/spectrum', - tinycolor: 'jquery/spectrum/tinycolor', - paypalInContextExpressCheckout: 'empty:', - 'ui/template': 'Magento_Ui/templates', - temandoCheckoutFieldsDefinition: - 'Temando_Shipping/js/model/fields-definition', - temandoDeliveryOptions: 'Temando_Shipping/js/model/delivery-options', - temandoShippingRatesValidator: - 'Temando_Shipping/js/model/shipping-rates-validator/temando', - temandoShippingRatesValidationRules: - 'Temando_Shipping/js/model/shipping-rates-validation-rules/temando', - Swiper: 'js/vendor/swiper', - dropdown: 'js/vendor/bootstrap-dropdown', - selectpicker: 'js/vendor/bootstrap-select', - vendors: 'vendors', - Stickyfill: 'js/vendor/stickyfill', - isMobile: 'js/vendor/ismobile', - bootstrapDropdown: 'js/vendor/bootstrap-dropdown', - bootstrapSelect: 'js/vendor/bootstrap-select', - mixins: 'mage/requirejs/mixins', - }, - map: { - '*': { - rowBuilder: 'Magento_Theme/js/row-builder', - toggleAdvanced: 'mage/toggle', - translateInline: 'mage/translate-inline', - sticky: 'mage/sticky', - tabs: 'mage/tabs', - zoom: 'mage/zoom', - collapsible: 'mage/collapsible', - dropdownDialog: 'mage/dropdown', - dropdown: 'mage/dropdowns', - accordion: 'mage/accordion', - loader: 'mage/loader', - tooltip: 'mage/tooltip', - deletableItem: 'mage/deletable-item', - itemTable: 'mage/item-table', - fieldsetControls: 'mage/fieldset-controls', - fieldsetResetControl: 'mage/fieldset-controls', - redirectUrl: 'mage/redirect-url', - loaderAjax: 'mage/loader', - menu: 'mage/menu', - popupWindow: 'mage/popup-window', - validation: 'mage/validation/validation', - welcome: 'Magento_Theme/js/view/welcome', - breadcrumbs: 'Magento_Theme/js/view/breadcrumbs', - ko: 'knockoutjs/knockout', - knockout: 'knockoutjs/knockout', - mageUtils: 'mage/utils/main', - rjsResolver: 'mage/requirejs/resolver', - checkoutBalance: 'Magento_Customer/js/checkout-balance', - address: 'Magento_Customer/js/address', - changeEmailPassword: 'Magento_Customer/js/change-email-password', - passwordStrengthIndicator: - 'Magento_Customer/js/password-strength-indicator', - zxcvbn: 'Magento_Customer/js/zxcvbn', - addressValidation: 'Magento_Customer/js/addressValidation', - magepalGtmDatalayer: 'MagePal_GoogleTagManager/js/datalayer', - compareList: 'Magento_Catalog/js/list', - relatedProducts: 'Magento_Catalog/js/related-products', - upsellProducts: 'Magento_Catalog/js/upsell-products', - productListToolbarForm: 'MageSuite_Sorting/js/product/list/toolbar', - catalogGallery: 'Magento_Catalog/js/gallery', - priceBox: 'Magento_Catalog/js/price-box', - priceOptionDate: 'Magento_Catalog/js/price-option-date', - priceOptionFile: 'Magento_Catalog/js/price-option-file', - priceOptions: 'Magento_Catalog/js/price-options', - priceUtils: 'Magento_Catalog/js/price-utils', - catalogAddToCart: 'Magento_Catalog/js/catalog-add-to-cart', - addToCart: 'Magento_Msrp/js/msrp', - creditCardType: 'Magento_Payment/js/cc-type', - quickSearch: 'Smile_ElasticsuiteCore/js/form-mini', - giftMessage: 'Magento_Sales/js/gift-message', - ordersReturns: 'Magento_Sales/js/orders-returns', - editTrigger: 'mage/edit-trigger', - addClass: 'Magento_Translation/js/add-class', - catalogSearch: 'Magento_CatalogSearch/form-mini', - raven: 'MageSuite_SentryIo/raven', - discountCode: 'Magento_Checkout/js/discount-codes', - shoppingCart: 'Magento_Checkout/js/shopping-cart', - regionUpdater: 'Magento_Checkout/js/region-updater', - sidebar: 'Magento_Checkout/js/sidebar', - checkoutLoader: 'Magento_Checkout/js/checkout-loader', - checkoutData: 'Magento_Checkout/js/checkout-data', - proceedToCheckout: 'Magento_Checkout/js/proceed-to-checkout', - helpfulness: 'Aheadworks_Faq/js/helpfulness', - transparent: 'Magento_Payment/js/transparent', - bundleOption: 'Magento_Bundle/bundle', - priceBundle: 'Magento_Bundle/js/price-bundle', - slide: 'Magento_Bundle/js/slide', - productSummary: 'Magento_Bundle/js/product-summary', - captcha: 'Magento_Captcha/js/captcha', - amazonLogout: 'Amazon_Login/js/amazon-logout', - amazonOAuthRedirect: 'Amazon_Login/js/amazon-redirect', - amazonCsrf: 'Amazon_Login/js/amazon-csrf', - configurable: 'Magento_ConfigurableProduct/js/configurable', - amazonCore: 'Amazon_Payment/js/amazon-core', - amazonWidgetsLoader: 'Amazon_Payment/js/amazon-widgets-loader', - amazonButton: 'Amazon_Payment/js/amazon-button', - amazonProductAdd: 'Amazon_Payment/js/amazon-product-add', - bluebird: 'Amazon_Payment/js/lib/bluebird.min', - amazonPaymentConfig: 'Amazon_Payment/js/model/amazonPaymentConfig', - sjcl: 'Amazon_Payment/js/lib/sjcl.min', - orderReview: 'Magento_Paypal/js/order-review', - paypalCheckout: 'Magento_Paypal/js/paypal-checkout', - requireCookie: 'Magento_Cookie/js/require-cookie', - cookieNotices: 'Magento_Cookie/js/notices', - downloadable: 'Magento_Downloadable/js/downloadable', - giftOptions: 'Magento_GiftMessage/js/gift-options', - extraOptions: 'Magento_GiftMessage/js/extra-options', - uiElement: 'Magento_Ui/js/lib/core/element/element', - uiCollection: 'Magento_Ui/js/lib/core/collection', - uiComponent: 'Magento_Ui/js/lib/core/collection', - uiClass: 'Magento_Ui/js/lib/core/class', - uiEvents: 'Magento_Ui/js/lib/core/events', - uiRegistry: 'Magento_Ui/js/lib/registry/registry', - consoleLogger: 'Magento_Ui/js/lib/logger/console-logger', - uiLayout: 'Magento_Ui/js/core/renderer/layout', - buttonAdapter: 'Magento_Ui/js/form/button-adapter', - tinymce4: 'tiny_mce_4/tinymce.min', - wysiwygAdapter: 'mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter', - rangeSlider: 'Smile_ElasticsuiteCatalog/js/range-slider-widget', - multiShipping: 'Magento_Multishipping/js/multi-shipping', - orderOverview: 'Magento_Multishipping/js/overview', - payment: 'Magento_Multishipping/js/payment', - billingLoader: 'Magento_Checkout/js/checkout-loader', - cartUpdate: 'Magento_Checkout/js/action/update-shopping-cart', - pageCache: 'Magento_PageCache/js/page-cache', - braintree: - 'https://js.braintreegateway.com/js/braintree-2.32.0.min.js', - recentlyViewedProducts: 'Magento_Reports/js/recently-viewed', - loadPlayer: 'Magento_ProductVideo/js/load-player', - fotoramaVideoEvents: - 'Magento_ProductVideo/js/fotorama-add-video-events', - wishlist: 'Magento_Wishlist/js/wishlist', - addToWishlist: 'Magento_Wishlist/js/add-to-wishlist', - wishlistSearch: 'Magento_Wishlist/js/search', - awGiftCardChangeAmount: - 'Aheadworks_Giftcard/js/widget/product/change-amount', - awGiftCardChangeDesign: - 'Aheadworks_Giftcard/js/widget/product/change-design', - awGiftCardPreview: 'Aheadworks_Giftcard/js/widget/product/preview', - awGiftCardManagement: - 'Aheadworks_Giftcard/js/widget/giftcardManagement', - awGiftCardCalendar: - 'Aheadworks_Giftcard/js/widget/product/calendar', - tinymceDeprecated: 'Magento_Tinymce3/tiny_mce/tiny_mce_src', - klarnapi: 'https://x.klarnacdn.net/kp/lib/v1/api.js', - taxToggle: 'Magento_Weee/js/tax-toggle', - 'Magento_Checkout/js/model/shipping-save-processor/default': - 'Repertus_Packstation/js/shipping-save-processor-default-override', - 'set-checkout-messages': - 'Vertex_Tax/js/model/set-checkout-messages', - checkoutCustomizations: - 'Magento_Checkout/js/checkout-customizations', - }, - }, - optimize: 'uglify2', - inlineText: true, - logLevel: 2, - preserveLicenseComments: false, - modules: [ - { - name: 'requirejs/require', - create: false, - include: [ - 'mixins', - 'jquery', - 'js/commons', - 'jquery/ui', - 'jquery/patches/jquery', - 'jquery/jquery.mobile.custom', - 'js/uenc-updater', - 'underscore', - 'jquery/patches/jquery-ui', - 'jquery/jquery-migrate', - 'mage/template', - 'mage/smart-keyboard-handler', - 'Magento_Catalog/js/price-utils', - 'jquery/jquery.parsequery', - 'domReady', - 'matchMedia', - 'mage/ie-class-fixer', - 'knockoutjs/knockout', - 'knockoutjs/knockout-es5', - 'mage/apply/scripts', - 'mage/apply/main', - 'mage/mage', - 'mage/translate', - 'mage/translate-inline', - 'Swiper', - 'Magento_Ui/js/lib/knockout/extender/observable_array', - 'js/validation-ext', - 'js/collapsible-ext', - 'isMobile', - 'bootstrapDropdown', - 'moment', - 'knockoutjs/knockout-repeat', - 'knockoutjs/knockout-fast-foreach', - 'Magento_Ui/js/lib/knockout/bindings/mage-init', - 'Magento_Ui/js/lib/knockout/bindings/fadeVisible', - 'mage/utils/wrapper', - 'es6-collections', - 'Magento_Ui/js/lib/core/events', - 'Magento_Ui/js/lib/knockout/extender/bound-nodes', - 'bootstrapSelect', - 'js/category', - 'jquery/jquery.cookie', - 'jquery/jquery.metadata', - 'jquery/validate', - 'mage/validation', - 'mage/validation/validation', - 'Magento_Swatches/js/swatch-renderer', - 'tinycolor', - 'spectrum', - 'Magento_Ui/js/lib/registry/registry', - 'Magento_Ui/js/lib/knockout/template/loader', - 'Magento_Ui/js/lib/knockout/template/renderer', - 'Magento_Ui/js/lib/knockout/bindings/i18n', - 'Magento_Ui/js/lib/knockout/bindings/range', - 'Magento_Ui/js/lib/knockout/bindings/keyboard', - 'Magento_Ui/js/lib/knockout/bindings/after-render', - 'Magento_Ui/js/lib/knockout/bindings/autoselect', - 'Magento_Ui/js/lib/knockout/bindings/outer_click', - 'Magento_Ui/js/lib/knockout/bindings/collapsible', - 'Magento_Ui/js/lib/knockout/bindings/staticChecked', - 'Magento_Ui/js/lib/knockout/bindings/simple-checked', - 'Magento_Ui/js/lib/knockout/bindings/bind-html', - 'Magento_Ui/js/lib/knockout/bindings/color-picker', - 'Magento_Ui/js/lib/logger/message-pool', - 'Magento_Ui/js/lib/logger/levels-pool', - 'Magento_Ui/js/lib/logger/logger', - 'Magento_Ui/js/lib/logger/console-output-handler', - 'Magento_Ui/js/lib/logger/logger-utils', - 'text', - 'text!ui/template/tooltip/tooltip.html', - 'Magento_Ui/js/lib/knockout/bindings/tooltip', - 'text!ui/template/modal/modal-custom.html', - 'text!ui/template/modal/modal-popup.html', - 'text!ui/template/modal/modal-slide.html', - 'jquery/jquery-storageapi', - 'mage/collapsible', - 'mage/tabs', - 'Magento_Ui/js/lib/key-codes', - 'Magento_Ui/js/modal/modal', - 'Magento_Ui/js/modal/confirm', - 'mage/dataPost', - 'jquery/jquery-ui-timepicker-addon', - 'mage/calendar', - 'Magento_Ui/js/lib/view/utils/bindings', - 'Magento_Ui/js/lib/logger/entry', - 'Magento_Ui/js/lib/logger/entry-factory', - 'mage/utils/objects', - 'mage/utils/compare', - 'mage/utils/strings', - 'mage/utils/arrays', - 'mage/utils/template', - 'Magento_Ui/js/lib/logger/formatter', - 'MutationObserver', - 'FormData', - 'mage/utils/misc', - 'mage/utils/main', - 'Magento_Ui/js/lib/knockout/bindings/optgroup', - 'Magento_Ui/js/lib/knockout/bindings/datepicker', - 'Magento_Ui/js/lib/core/class', - 'Magento_Ui/js/lib/knockout/template/observable_source', - 'Magento_Ui/js/lib/core/storage/local', - 'Magento_Ui/js/lib/logger/console-logger', - 'Magento_Ui/js/lib/knockout/template/engine', - 'Magento_Ui/js/lib/knockout/bindings/scope', - 'domReady!', - 'Magento_Theme/js/responsive', - 'Magento_Theme/js/theme', - 'mage/common', - 'Magento_Ui/js/lib/view/utils/dom-observer', - 'Magento_Ui/js/lib/view/utils/async', - 'Magento_Ui/js/lib/knockout/bindings/resizable', - 'Magento_Ui/js/lib/knockout/bindings/bootstrap', - 'Magento_Ui/js/lib/knockout/bootstrap', - 'mage/bootstrap', - 'MageSuite_Sorting/js/product/list/toolbar', - 'mage/loader', - 'Magento_Ui/js/block-loader', - 'Magento_Customer/js/section-config', - 'Magento_Wishlist/js/add-to-wishlist', - 'text!ui/template/block-loader.html', - 'Magento_Cookie/js/require-cookie', - 'mage/dropdown', - 'Magento_PageCache/js/submit-button-enabler', - 'Magento_Catalog/js/catalog-add-to-cart-ext', - 'Magento_Catalog/js/price-box', - 'mage/accordion', - 'mage/translate-init', - 'mage/cookies', - 'Magento_PageCache/js/page-cache', - 'Magento_Cookie/js/notices', - 'Magento_Ui/js/core/renderer/types', - 'Magento_Ui/js/core/renderer/layout', - 'Magento_Ui/js/core/app', - 'Magento_Search/js/form-mini', - 'mage/url', - 'mage/storage', - 'Magento_Customer/js/customer-data', - 'Magento_Ui/js/view/messages-ext', - 'Magento_Catalog/js/product/view/product-ids', - 'Magento_Catalog/js/product/view/product-ids-resolver', - 'Magento_Catalog/js/catalog-add-to-cart', - 'Magento_Ui/js/lib/core/element/links', - 'Magento_Ui/js/lib/core/element/element', - 'Magento_Customer/js/invalidation-processor', - 'Magento_Ui/js/lib/core/collection', - 'Magento_Tax/js/view/checkout/minicart/subtotal/totals', - 'Magento_Msrp/js/view/checkout/minicart/subtotal/totals', - 'Magento_Catalog/js/view/image', - 'Magento_Wishlist/js/view/wishlist', - 'Magento_Theme/js/view/messages', - 'Magento_Customer/js/model/authentication-popup', - 'Magento_Ui/js/modal/alert', - 'MSP_ReCaptcha/js/registry', - 'MSP_ReCaptcha/js/reCaptcha', - 'MSP_ReCaptcha/js/ui-messages-mixin', - 'Magento_Captcha/js/model/captchaList', - 'Magento_Customer/js/invalidation-rules/website-rule', - 'mage/decorate', - 'Magento_Checkout/js/sidebar', - 'Magento_Checkout/js/view/minicart', - 'Magento_Ui/js/lib/spinner', - 'mage/requirejs/resolver', - 'Magento_Catalog/js/product/storage/ids-storage', - 'Magento_Catalog/js/product/storage/ids-storage-compare', - 'text!Magento_Checkout/template/minicart/content.html', - 'text!ui/template/collection.html', - 'Magento_Ui/js/model/messages', - 'Magento_Ui/js/model/messageList', - 'Magento_Ui/js/view/messages', - 'Magento_Customer/js/action/login', - 'Magento_Ui/js/form/adapter/buttons', - 'Magento_Ui/js/form/adapter', - 'Magento_Ui/js/form/form', - 'Magento_Customer/js/view/authentication-popup', - 'Magento_Captcha/js/action/refresh', - 'Magento_Captcha/js/model/captcha', - 'Magento_Captcha/js/view/checkout/defaultCaptcha', - 'Magento_Captcha/js/view/checkout/loginCaptcha', - 'Magento_Catalog/js/product/query-builder', - 'Magento_Catalog/js/product/storage/data-storage', - 'Magento_Catalog/js/product/storage/storage-service', - 'Magento_Catalog/js/storage-manager', - 'text!Magento_Customer/template/authentication-popup.html', - 'text!Magento_Ui/template/messages.html', - 'text!MSP_ReCaptcha/template/reCaptcha.html', - 'text!Magento_Captcha/template/checkout/captcha.html', - 'mage/trim-input', - ], - exclude: [], - }, - { - name: 'bundles/category', - create: true, - exclude: ['requirejs/require'], - include: [], - }, - { - name: 'bundles/checkout', - create: true, - exclude: ['requirejs/require'], - include: [ - 'Stickyfill', - 'js/checkout', - 'Magento_Checkout/js/shopping-cart', - 'Aheadworks_Giftcard/js/widget/giftcardManagement', - 'Magento_Checkout/js/discount-codes', - 'Magento_Checkout/js/proceed-to-checkout', - 'Magento_GiftMessage/js/model/gift-message', - 'Magento_GiftMessage/js/model/gift-options', - 'Magento_Checkout/js/model/shipping-rates-validation-rules', - 'Magento_Dhl/js/model/shipping-rates-validation-rules', - 'Magento_Dhl/js/model/shipping-rates-validator', - 'Magento_Fedex/js/model/shipping-rates-validation-rules', - 'Magento_Fedex/js/model/shipping-rates-validator', - 'Magento_Ups/js/model/shipping-rates-validation-rules', - 'Magento_Ups/js/model/shipping-rates-validator', - 'Magento_OfflineShipping/js/model/shipping-rates-validation-rules/freeshipping', - 'Magento_OfflineShipping/js/model/shipping-rates-validator/freeshipping', - 'Magento_OfflineShipping/js/model/shipping-rates-validation-rules/flatrate', - 'Magento_OfflineShipping/js/model/shipping-rates-validator/flatrate', - 'Magento_OfflineShipping/js/model/shipping-rates-validation-rules/tablerate', - 'Magento_OfflineShipping/js/model/shipping-rates-validator/tablerate', - 'Magento_Checkout/js/model/quote', - 'Magento_Tax/js/view/checkout/shipping_method/price', - 'Magento_Usps/js/model/shipping-rates-validation-rules', - 'Magento_Usps/js/model/shipping-rates-validator', - 'Magento_Checkout/js/checkout-data', - 'Magento_Checkout/js/model/totals', - 'Magento_Checkout/js/action/select-shipping-method', - 'Magento_Checkout/js/model/default-post-code-resolver', - 'Magento_Checkout/js/model/shipping-address/form-popup-state', - 'Magento_Checkout/js/action/select-shipping-address', - 'Magento_Checkout/js/model/postcode-validator', - 'text!Magento_Checkout/template/minicart/item/default.html', - 'Magento_Checkout/js/model/checkout-data-resolver-ext', - 'text!Magento_Checkout/template/minicart/subtotal.html', - 'Magento_Checkout/js/model/step-navigator', - 'Magento_Checkout/js/model/full-screen-loader', - 'text!Magento_Catalog/template/product/image_with_borders.html', - 'text!Magento_Checkout/template/minicart/item/price.html', - 'text!Magento_Tax/template/checkout/minicart/subtotal/totals.html', - 'Payone_Core/js/model/error-processor-mixin', - 'Magento_Checkout/js/model/error-processor', - 'Magento_Ui/js/lib/validation/utils', - 'Magento_Ui/js/lib/validation/rules', - 'Magento_Ui/js/lib/validation/validator', - 'Magento_Ui/js/form/element/abstract', - 'Magento_Ui/js/form/element/select', - 'Magento_Ui/js/form/element/region', - 'Magento_Checkout/js/model/url-builder', - 'Magento_GiftMessage/js/model/url-builder', - 'Magento_GiftMessage/js/action/gift-options', - 'Magento_GiftMessage/js/view/gift-message', - 'Magento_Checkout/js/model/new-customer-address', - 'Magento_Checkout/js/model/address-converter', - 'Magento_Checkout/js/model/cart/cache', - 'Magento_Checkout/js/action/select-payment-method', - 'Magento_Checkout/js/action/create-billing-address', - 'Magento_Checkout/js/model/default-validation-rules', - 'Magento_Checkout/js/model/default-validator', - 'Magento_Checkout/js/model/shipping-rates-validator', - 'Magento_Dhl/js/view/shipping-rates-validation', - 'Magento_Fedex/js/view/shipping-rates-validation', - 'Magento_OfflineShipping/js/view/shipping-rates-validation/freeshipping', - 'Magento_OfflineShipping/js/view/shipping-rates-validation/flatrate', - 'Magento_OfflineShipping/js/view/shipping-rates-validation/tablerate', - 'Magento_Usps/js/view/shipping-rates-validation', - 'Magento_Ups/js/view/shipping-rates-validation', - 'Magento_Checkout/js/action/select-billing-address', - 'Repertus_Packstation/js/action/mixins/select-billing-address-mixin', - 'text!Magento_GiftMessage/template/gift-message-item-level.html', - 'text!Magento_GiftMessage/template/gift-message.html', - 'Aheadworks_Giftcard/js/model/payment/giftcard-messages', - 'Aheadworks_Giftcard/js/model/customer/giftcard', - 'Magento_Checkout/js/model/payment/method-converter', - 'Magento_Checkout/js/model/shipping-rate-registry', - 'Magento_Checkout/js/model/payment/method-list', - 'Magento_Checkout/js/model/payment-service', - 'Magento_Customer/js/model/customer/address', - 'Magento_Customer/js/model/customer-addresses', - 'Magento_Customer/js/model/address-list', - 'Magento_Checkout/js/action/create-shipping-address', - 'Magento_Checkout/js/model/checkout-data-resolver', - 'Magento_Customer/js/model/customer', - 'MageSuite_LoginOrGuestCheckoutStep/js/view/step-navigator-mixin', - 'Magento_Checkout/js/view/summary/abstract-total', - 'Magento_Tax/js/view/checkout/summary/subtotal', - 'Magento_Tax/js/view/checkout/summary/grand-total', - 'Magento_Tax/js/view/checkout/cart/totals/grand-total', - 'Magento_Tax/js/view/checkout/summary/tax', - 'Magento_Tax/js/view/checkout/cart/totals/tax', - 'Magento_SalesRule/js/view/summary/discount', - 'Magento_SalesRule/js/view/cart/totals/discount', - 'Magento_Weee/js/view/checkout/summary/weee', - 'Magento_Weee/js/view/cart/totals/weee', - 'Magento_Checkout/js/view/summary/shipping', - 'Magento_Tax/js/view/checkout/summary/shipping', - 'Magento_Tax/js/view/checkout/cart/totals/shipping', - 'Aheadworks_Giftcard/js/model/resource-url-manager', - 'Aheadworks_Giftcard/js/action/get-customer-giftcards', - 'Magento_Checkout/js/action/get-payment-information', - 'Aheadworks_Giftcard/js/action/remove-giftcard-code', - 'Aheadworks_Giftcard/js/view/checkout/summary/giftcard', - 'Magento_Checkout/js/action/set-billing-address', - 'Repertus_Packstation/js/model/mixins/checkout-data-resolver-mixin', - 'Magento_Checkout/js/model/shipping-service', - 'Magento_Checkout/js/view/cart/shipping-rates', - 'Magento_Checkout/js/view/cart/totals', - 'Magento_Checkout/js/model/resource-url-manager', - 'Magento_Checkout/js/model/shipping-rate-processor/new-address', - 'Magento_Checkout/js/model/cart/totals-processor/default', - 'Magento_Checkout/js/model/cart/estimate-service', - 'Magento_Checkout/js/view/cart/shipping-estimation', - 'text!Magento_Checkout/template/cart/shipping-estimation.html', - 'text!Magento_Checkout/template/cart/totals.html', - 'text!Magento_Checkout/template/cart/shipping-rates.html', - 'text!ui/template/form/field.html', - 'text!Magento_Tax/template/checkout/cart/totals/tax.html', - 'text!Magento_Tax/template/checkout/cart/totals/grand-total.html', - 'text!Magento_Tax/template/checkout/summary/subtotal.html', - 'text!Aheadworks_Giftcard/template/checkout/summary/giftcard.html', - 'text!Magento_SalesRule/template/cart/totals/discount.html', - 'text!Magento_Tax/template/checkout/cart/totals/shipping.html', - 'text!Magento_Weee/template/checkout/summary/weee.html', - 'text!ui/template/form/element/select.html', - 'text!ui/template/form/element/input.html', - 'text!Magento_Tax/template/checkout/shipping_method/price.html', - 'Magento_Checkout/js/checkout-loader', - 'MageSuite_LoginOrGuestCheckoutStep/js/view/shipping-payment-mixin', - 'Magento_Checkout/js/view/summary/cart-items-ext', - 'Magento_CheckoutAgreements/js/view/checkout-agreements-ext', - 'Magento_Checkout/js/view/summary/item/details', - 'Magento_Checkout/js/view/summary/item/details/thumbnail', - 'Magento_Ui/js/form/components/html', - 'Payone_Core/js/view/boni-agreement', - 'Magento_Ui/js/form/components/group', - 'text!Magento_Checkout/template/onepage.html', - 'Repertus_Packstation/js/repertus-packstation', - 'Magento_Checkout/js/view/shipping-information/list', - 'Magento_Checkout/js/view/summary', - 'Magento_Checkout/js/checkout-customizations', - 'Magento_Shipping/js/model/config', - 'Magento_Shipping/js/view/checkout/shipping/shipping-policy', - 'Magento_CheckoutAgreements/js/model/agreements-modal', - 'Magento_CheckoutAgreements/js/view/checkout-agreements', - 'Magento_Ui/js/lib/collapsible', - 'Repertus_Packstation/js/form/components/fieldset', - 'Magento_Checkout/js/model/payment/renderer-list', - 'Magento_Payment/js/view/payment/payments', - 'Magento_Paypal/js/view/payment/paypal-payments', - 'Magento_OfflinePayments/js/view/payment/offline-payments', - 'Magento_Checkout/js/model/payment/additional-validators', - 'Magento_CheckoutAgreements/js/model/agreement-validator', - 'Magento_CheckoutAgreements/js/model/agreement-validator-ext', - 'Magento_CheckoutAgreements/js/view/agreement-validation', - 'Magento_Checkout/js/view/shipping-ext', - 'Repertus_Packstation/js/view/mixins/billing-address-mixin', - 'Magento_Ui/js/form/element/post-code', - 'Magento_SalesRule/js/model/payment/discount-messages', - 'Magento_SalesRule/js/view/payment/discount-messages', - 'Aheadworks_Giftcard/js/view/payment/giftcard-messages', - 'Magento_Checkout/js/model/authentication-messages', - 'Magento_Checkout/js/view/authentication-messages', - 'Magento_Customer/js/action/check-email-availability', - 'Magento_Checkout/js/view/shipping-address/list', - 'Magento_Checkout/js/view/form/element/email', - 'MageSuite_LoginOrGuestCheckoutStep/js/view/login-or-guest', - 'MageSuite_LoginOrGuestCheckoutStep/js/view/continue-as-guest', - 'Magento_Checkout/js/before-place-order', - 'Magento_Checkout/js/place-order', - 'Magento_Checkout/js/view/summary/cart-items', - 'Magento_Checkout/js/view/summary/totals', - 'Magento_Checkout/js/view/summary/item/details/subtotal', - 'Magento_Tax/js/view/checkout/summary/item/details/subtotal', - 'Magento_Weee/js/view/checkout/summary/item/price/weee', - 'Magento_Weee/js/view/checkout/summary/item/price/row_incl_tax', - 'Magento_Weee/js/view/checkout/summary/item/price/row_excl_tax', - 'Magento_Checkout/js/model/customer-email-validator', - 'Magento_Checkout/js/view/payment/email-validator', - 'Magento_SalesRule/js/action/set-coupon-code', - 'Magento_SalesRule/js/action/cancel-coupon', - 'Magento_SalesRule/js/view/payment/discount', - 'Aheadworks_Giftcard/js/action/apply-giftcard-code', - 'Aheadworks_Giftcard/js/view/payment/giftcard', - 'Magento_Checkout/js/model/sidebar', - 'Magento_Checkout/js/view/sidebar', - 'text!MageSuite_LoginOrGuestCheckoutStep/template/login-or-guest.html', - 'text!MageSuite_LoginOrGuestCheckoutStep/template/continue-as-guest.html', - 'Payone_Core/js/action/addresscheck', - 'Payone_Core/js/view/billing-address-mixin', - 'Payone_Core/js/action/edit-address', - 'Payone_Core/js/view/shipping-mixin', - 'text!Magento_Checkout/template/sidebar.html', - 'Magento_Checkout/js/view/authentication', - 'text!Magento_Checkout/template/summary.html', - 'text!Magento_Checkout/template/summary/totals.html', - 'text!Magento_Checkout/template/payment/before-place-order.html', - 'text!Magento_Checkout/template/place-order.html', - 'text!Magento_Checkout/template/summary/cart-items.html', - 'text!Magento_Tax/template/checkout/summary/tax.html', - 'text!Magento_Tax/template/checkout/summary/grand-total.html', - 'text!Magento_CheckoutAgreements/template/checkout/checkout-agreements.html', - 'text!MageSuite_LoginOrGuestCheckoutStep/template/authentication.html', - 'text!Magento_SalesRule/template/summary/discount.html', - 'text!Magento_Tax/template/checkout/summary/shipping.html', - 'text!Magento_Checkout/template/summary/item/details.html', - 'text!Magento_Checkout/template/summary/item/details/thumbnail.html', - 'text!Magento_Tax/template/checkout/summary/item/details/subtotal.html', - 'text!Magento_Weee/template/checkout/summary/item/price/row_excl_tax.html', - 'Magento_Checkout/js/view/payment', - 'Magento_Checkout/js/next-button', - 'Magento_Checkout/js/view/payment/list', - 'Magento_Checkout/js/view/billing-address', - 'Magento_Checkout/js/model/shipping-rate-processor/customer-address', - 'Magento_Checkout/js/model/shipping-rate-service', - 'Magento_Checkout/js/view/estimation', - 'Magento_Checkout/js/model/payment/method-group', - 'Repertus_Packstation/js/shipping-save-processor-default-override', - 'Magento_Checkout/js/model/shipping-save-processor', - 'Magento_Checkout/js/action/set-shipping-information', - 'Magento_Checkout/js/view/shipping', - 'text!Magento_Checkout/template/shipping.html', - 'text!Magento_Checkout/template/estimation.html', - 'text!Magento_Checkout/template/next-button.html', - 'text!Magento_Checkout/template/payment.html', - 'text!Magento_Checkout/template/form/element/email.html', - 'Magento_Checkout/js/view/progress-bar', - 'text!Payone_Core/template/payment/boni-agreement.html', - 'text!Magento_Checkout/template/payment-methods/list.html', - 'text!Magento_SalesRule/template/payment/discount.html', - 'text!Aheadworks_Giftcard/template/payment/giftcard.html', - 'text!Magento_Checkout/template/authentication-tab.html', - 'text!Magento_Checkout/template/shipping-address/list.html', - 'text!Magento_Checkout/template/shipping-address/form.html', - 'text!Magento_Shipping/template/checkout/shipping/shipping-policy.html', - 'Magento_Checkout/js/view/shipping-information', - 'Temando_Shipping/js/model/collection-points', - 'Temando_Shipping/js/model/pickup-locations', - 'Temando_Shipping/js/view/checkout/shipping-information/address-renderer/shipping', - 'text!Repertus_Packstation/template/form/repertus_address_type_fieldset.html', - 'text!ui/template/form/element/helper/tooltip.html', - 'text!ui/template/group/group.html', - 'text!ui/template/content/content.html', - 'mage/dropdowns', - 'text!Magento_Checkout/template/progress-bar.html', - 'text!Magento_Checkout/template/shipping-information.html', - 'text!Magento_Checkout/template/shipping-address/shipping-method-list.html', - 'text!Magento_Checkout/template/shipping-address/shipping-method-item.html', - ], - }, - { - name: 'bundles/cms', - create: true, - exclude: ['requirejs/require'], - include: [ - 'js/cms', - 'text!Magento_Checkout/template/minicart/item/default.html', - 'text!Magento_Catalog/template/product/image_with_borders.html', - 'text!Magento_Checkout/template/minicart/subtotal.html', - 'text!Magento_Checkout/template/minicart/item/price.html', - 'text!Magento_Tax/template/checkout/minicart/subtotal/totals.html', - ], - }, - { - name: 'bundles/customer', - create: true, - exclude: ['requirejs/require'], - include: [ - 'Stickyfill', - 'js/customer', - 'text!Magento_Checkout/template/minicart/subtotal.html', - 'text!Magento_Checkout/template/minicart/item/default.html', - 'text!Magento_Tax/template/checkout/minicart/subtotal/totals.html', - 'text!Magento_Catalog/template/product/image_with_borders.html', - 'text!Magento_Checkout/template/minicart/item/price.html', - ], - }, - { - name: 'bundles/pdp', - create: true, - exclude: ['requirejs/require'], - include: [ - 'Stickyfill', - 'js/pdp', - 'Magento_Review/js/error-placement', - 'Magento_Catalog/js/related-products', - 'Magento_Swatches/js/catalog-add-to-cart', - 'Magento_Review/js/process-reviews', - 'Magento_Catalog/js/product/view/provider-ext', - 'magnifier/magnifier', - 'magnifier/magnify', - 'Magento_Catalog/js/gallery', - 'Magento_ProductVideo/js/load-player', - 'Magento_ProductVideo/js/fotorama-add-video-events', - 'text!mage/gallery/gallery.html', - 'text!Magento_InstantPurchase/template/confirmation.html', - 'fotorama/fotorama', - 'mage/gallery/gallery', - 'Magento_Customer/js/view/customer', - 'Magento_Review/js/view/review', - 'Magento_Catalog/product/view/validation', - 'Magento_Catalog/js/validate-product', - 'Magento_InstantPurchase/js/view/instant-purchase', - 'Magento_Catalog/js/product/view/provider', - 'text!Magento_InstantPurchase/template/instant-purchase.html', - 'text!Magento_Checkout/template/minicart/item/default.html', - 'text!Magento_Catalog/template/product/image_with_borders.html', - 'text!Magento_Checkout/template/minicart/item/price.html', - 'text!Magento_Checkout/template/minicart/subtotal.html', - 'text!Magento_Tax/template/checkout/minicart/subtotal/totals.html', - 'Magento_Catalog/js/upsell-products', - ], - }, - ], - configUrl: 'http://creativeshop.me', -}; diff --git a/cli.js b/cli.js index d275b76..8a7c09e 100755 --- a/cli.js +++ b/cli.js @@ -48,7 +48,7 @@ if (program.generate) { } try { - require('./lib/optimize')(program.config, program.dir); + require('./lib/bundle')(program.config, program.dir); } catch (error) { console.error(error); process.exit(1); diff --git a/config.sample.js b/config.sample.js index cc02fd4..3c93d70 100644 --- a/config.sample.js +++ b/config.sample.js @@ -1,5 +1,5 @@ const category = require('magepack/lib/module/category'); -const checkout = require('magepack/lib/module/checkout'); +// const checkout = require('magepack/lib/module/checkout'); const cms = require('magepack/lib/module/cms'); const customer = require('magepack/lib/module/customer'); const pdp = require('magepack/lib/module/pdp'); @@ -18,28 +18,28 @@ module.exports = { browser => category(browser, { url: `${baseUrl}/women/tops-women/jackets-women.html`, - excludeRegExp: /^\.|amazon|smile|klarna/i, - }), - browser => - checkout(browser, { - url: { - product: `${baseUrl}/overnight-duffle.html`, - cart: `${baseUrl}/checkout/cart/`, - checkout: `${baseUrl}/checkout/`, - }, - excludeRegExp: /^\.|amazon|smile|klarna/i, + excludeRegExp: /^\.|amazon|smile|klarna|Magento_Checkout\/js\/view\/minicart/i, }), + // browser => + // checkout(browser, { + // url: { + // product: `${baseUrl}/overnight-duffle.html`, + // cart: `${baseUrl}/checkout/cart/`, + // checkout: `${baseUrl}/checkout/`, + // }, + // excludeRegExp: /^\.|amazon|smile|klarna/i, + // }), browser => cms(browser, { url: baseUrl, - excludeRegExp: /^\.|amazon|smile|klarna/i, + excludeRegExp: /^\.|amazon|smile|klarna|Magento_Checkout\/js\/view\/minicart/i, }), browser => customer(browser, { url: `${baseUrl}/customer/account/login/`, email: 'test@demo.magesuite.io', password: 'Testing123', - excludeRegExp: /^\.|amazon|smile|klarna/i, + excludeRegExp: /^\.|amazon|smile|klarna|Magento_Checkout\/js\/view\/minicart/i, }), browser => pdp(browser, { @@ -47,7 +47,7 @@ module.exports = { `${baseUrl}/olivia-1-4-zip-light-jacket.html`, `${baseUrl}/overnight-duffle.html`, ], - excludeRegExp: /^\.|amazon|smile|klarna/i, + excludeRegExp: /^\.|amazon|smile|klarna|Magento_Checkout\/js\/view\/minicart/i, }), ], }; diff --git a/lib/baseConfig.js b/lib/baseConfig.js index 0ce0cba..d07d315 100644 --- a/lib/baseConfig.js +++ b/lib/baseConfig.js @@ -1,6 +1,6 @@ module.exports = { optimize: 'uglify2', - inlineText: true, + inlineText: false, logLevel: 2, preserveLicenseComments: false, deps: [], diff --git a/lib/optimize.js b/lib/bundle.js similarity index 93% rename from lib/optimize.js rename to lib/bundle.js index 7a142b5..1c364f2 100644 --- a/lib/optimize.js +++ b/lib/bundle.js @@ -52,8 +52,8 @@ module.exports = async (configPath, dirPath) => { await fs.appendFile(fileName, contents); - console.log('Removing temporary directory for static files...'); - await fs.remove(baseUrl); + // console.log('Removing temporary directory for static files...'); + // await fs.remove(baseUrl); console.log('Finished optimized bundling.'); }, diff --git a/lib/dependencies/collect.js b/lib/dependencies/collect.js index fcbe913..a5cf007 100644 --- a/lib/dependencies/collect.js +++ b/lib/dependencies/collect.js @@ -10,7 +10,10 @@ module.exports = (page, excludeRegExp = /^\./) => window.require.s.contexts._.defined ).filter( dependency => - dependency.indexOf('mixins!') !== 0 + dependency.indexOf('mixins!') === -1 && + dependency.indexOf('text!') === -1 && + dependency !== 'text' && + dependency !== 'mage/gallery/gallery' ); resolve(dependencies); diff --git a/lib/generate.js b/lib/generate.js index 9780016..adb2a40 100644 --- a/lib/generate.js +++ b/lib/generate.js @@ -58,6 +58,6 @@ module.exports = async (outputPath, userConfigPath) => { fs.outputFile( path.resolve(outputPath), - `module.exports = ${stringify(buildConfig)}` + `module.exports = ${stringify(buildConfig, { indent: ' ' })}` ); };