AMD module bundler and preloader for Magento 2 stores.

Related tags

Miscellaneous baler
Overview

baler

CircleCI

baler is an AMD module bundler and preloader for Magento 2 stores.

Getting Started (Early Alpha)

If you're willing to test alpha software, please proceed

Docs

Usage

Usage
  $ baler <command> [options]

  Commands
    build --theme Vendor/name
    graph --theme Vendor/name

  Examples
    Optimize all eligible themes
    $ baler build

    Optimize multiple themes
    $ baler build --theme Magento/foo --theme Magento/bar

    Generate Dependency Graph
    $ baler graph --theme Magento/luma

Debugging

node.js debugger

  1. Run node --inspect-brk $(which baler)
  2. In Chrome, visit chrome://inspect
  3. Click Inspect on the pending connection

Tracing

Run the CLI with the --trace flag. An event log will be written to baler-trace-{timestamp}.txt

Comments
  • Is this abandoned?

    Is this abandoned?

    After spending some time to get this up and running locally, found that the only bundle created was the <theme>/balerbundles/core-bundle.js

    Did some digging and found this document, which seems to imply other solutions should be used instead https://github.com/magento/baler/blob/master/docs/WHY_CUSTOM.md#how-are-folks-working-around-this-today

    • hand rolling requirejs optimization config file
    • magepack
    • other similar options..

    I just want to know for definite that this repository is not the intended way to do things.

    Is that correct? Or am I missing something here?

    opened by PivitParkour94 12
  • Any ideas what causes baler build to loop endlessly?

    Any ideas what causes baler build to loop endlessly?

     baler build --trace
    ✔ Collected theme/module data 142ms
    ⠋ (Magento/luma) Create core bundle file⠋ (Etilize/import) Create core bundle file
    Optimization is done, but stats have not been implemented in the CLI yet
    ⠋ (Etilize/import) Create core bundle file
    
    ....
    (2492.643615990877): Preparing to analyze "MutationObserver" for dependencies
    (2496.74079400301): Preparing to analyze "FormData" for dependencies
    (2507.8036310076714): Resolving dependency "jquery/jquery.mobile.custom" from ""
    (2508.143660992384): Resolving dependency "jquery" from ""
    (2508.2522000074387): Resolving dependency "(2482.613610982895): Resolving dependency "jquery" from "jquery-ui-modules/datepicker"
    (2482.7034960091114): Resolving dependency "jquery-ui-modules/core" from "jquery-ui-modules/datepicker"
    (2482.7716360092163): Preparing to analyze "jquery-ui-modules/slider" for dependencies
    (2491.183733999729): Discovered dependencies for "jquery-ui-modules/slider": jquery, jquery-ui-modules/core, jquery-ui-modules/mouse
    (2491.22227999568): Resolving dependency "jquery" from "jquery-ui-modules/slider"
    (2491.291195988655): Resolving dependency "jquery-ui-modules/core" from "jquery-ui-modules/slider"
    (2491.3486459851265): Resolving dependency "jquery-ui-modules/mouse" from "jquery-ui-modules/slider"
    (2492.643615990877): Preparing to analyze "MutationObserver" for dependencies
    (2496.74079400301): Preparing to analyze "FormData" for dependencies
    (2507.8036310076714): Resolving dependency "jquery/jquery.mobile.custom" from ""
    (2508.143660992384): Resolving dependency "jquery" from ""
    (2508.2522000074387): Resolving dependency "ns" from ""
    (2508.3212589919567): Resolving dependency "vmouse" from ""
    (2508.3784649968147): Resolving dependency "support/touch" from ""
    (2508.493703007698): Resolving dependency "mage/common" from ""
    (2508.5813890099525): Resolving dependency "domReady" from ""
    (2508.661637991667): Resolving dependency "mage/dataPost" from ""
    (2508.7471689879894): Resolving dependency "mage/template" from ""
    (2508.830219000578): Resolving dependency "underscore" from ""
    (2508.9048919975758): Resolving dependency "Magento_Ui/js/modal/confirm" from ""
    (2509.0140880048275): Resolving dependency "mage/translate" from ""
    (2509.0956659913063): Resolving dependency "mage/mage" from ""
    (2509.1743820011616): Resolving dependency "mage/apply/main" from ""
    (2509.274531006813): Resolving dependency "mage/apply/scripts" from ""
    (2509.363907009363): Resolving dependency "jquery/jquery-ui" from ""
    (2509.44534099102): Resolving dependency "Magento_Ui/js/modal/modal" from ""
    (2509.5548349916935): Resolving dependency "text!ui/template/modal/modal-popup.html" from ""
    (2509.5758909881115): Resolving dependency "text" from ""
    (2509.7167730033398): Resolving dependency "text" from ""
    (2509.785418987274): Resolving dependency "text!ui/template/modal/modal-slide.html" from ""
    (2509.8036189973354): Resolving dependency "text" from ""
    (2510.175595998764): Resolving dependency "text!ui/template/modal/modal-custom.html" from ""
    (2510.2254819869995): Resolving dependency "text" from ""
    (2510.3711499869823): Resolving dependency "Magento_Ui/js/lib/key-codes" from ""
    (2510.4803000092506): Resolving dependency "mage/bootstrap" from ""
    (2510.565497994423): Resolving dependency "Magento_Ui/js/lib/knockout/bootstrap" from ""
    (2510.691917002201): Resolving dependency "knockoutjs/knockout" from ""
    (2510.7790269851685): Resolving dependency "Magento_Ui/js/lib/knockout/template/engine" from ""
    (2510.903595983982): Resolving dependency "Magento_Ui/js/lib/knockout/template/observable_source" from ""
    

    normally it says unknown source but I changed it to say ""..

    nevermind it was newer version of jquery.mobile.custom.js causing failure

    opened by southerncomputer 12
  • Cannot read property 'area' of undefined

    Cannot read property 'area' of undefined

    After uninstalling the conflicting module for testing purposes (see issue #8) and then running baler again I got the following typeError:

    TypeError: Cannot read property 'area' of undefined
        at Object.bundleThemes ([magento-root]/baler/src/index.ts:24:19)
        at Object.run ([magento-root]/baler/src/cli.ts:23:27)
    

    This leads to the following code:

    export async function bundleThemes(
        magentoRoot: string,
        store: StoreData,
    ): Promise<BundleResult[]> {
        const { components, deployedThemes } = store;
    
        const pendingBundleResults: ReturnType<typeof bundleSingleTheme>[] = [];
        for (const themeID of deployedThemes) {
            const theme = components.themes[themeID]; //<< LEADS TO HERE 2/2
            if (theme.area !== 'frontend' || theme.themeID === 'Magento/blank') {  //<< HERE 1/2
                continue;
            }
    

    I'm not unsure of how to debug this but it seems strange that the theme val is undefined, unless the components.themes array doesn't match IDs with IDs in deployed Themes?

    Also: I'm running this on a dev-server - should that even work, or do i need to test on production mode?

    bug 
    opened by jessetaverne 12
  • Found > 1

    Found > 1 "module.xml" for the module

    These Mirasvit modules are really throwing some curve balls.

    Error: Found > 1 "module.xml" for the module at path "vendor/mirasvit/module-search"
        at findRealModuleRoot (/Users/scottfriend/Sites/baler/src/magentoFS.ts:247:15)
        at processTicksAndRejections (internal/process/task_queues.js:89:5)
        at getModuleConfig (/Users/scottfriend/Sites/baler/src/magentoFS.ts:204:28)
        at async Promise.all (index 151)
        at getComposerComponents (/Users/scottfriend/Sites/baler/src/magentoFS.ts:332:18)
        at async Promise.all (index 0)
        at Object.getComponents (/Users/scottfriend/Sites/baler/src/magentoFS.ts:62:37)
        at async Promise.all (index 1)
        at Object.collectStoreData (/Users/scottfriend/Sites/baler/src/collectStoreData.ts:15:58)
        at Object.run (/Users/scottfriend/Sites/baler/src/cli.ts:20:19)
    

    Here's the abbreviated directory structure of this module: vendor/mirasvit/module-search

    • CHANGELOG.md
    • composer.json
    • src
      • Search
        • ...
        • composer.json
        • etc
          • ...
          • module.xml
        • ...
        • registration.php
      • SearchElasticNative ...
        • composer.json
        • etc
          • ...
          • module.xml
        • ...
        • registration.php

    I'm really not sure why it makes sense to have two Mage modules inside one composer module =/

    opened by friendscottn 7
  • Unable to locate

    Unable to locate "module.xml"

    Hey there, Baler hit the following error on the mirasvit elastic search ultimate module:

    Error: Unable to locate "module.xml" for the module at path "vendor/mirasvit/module-search-elastic-ultimate"
        at findRealModuleRoot (/Users/scottfriend/Sites/baler/src/magentoFS.ts:241:15)
        at processTicksAndRejections (internal/process/task_queues.js:89:5)
        at getModuleConfig (/Users/scottfriend/Sites/baler/src/magentoFS.ts:204:28)
        at async Promise.all (index 154)
        at getComposerComponents (/Users/scottfriend/Sites/baler/src/magentoFS.ts:332:18)
        at async Promise.all (index 0)
        at Object.getComponents (/Users/scottfriend/Sites/baler/src/magentoFS.ts:62:37)
        at async Promise.all (index 1)
        at Object.collectStoreData (/Users/scottfriend/Sites/baler/src/collectStoreData.ts:15:58)
        at Object.run (/Users/scottfriend/Sites/baler/src/cli.ts:20:19)
    

    This composer module doesn't actually contain a Magento Module. It's just a shell of a module to pull in other separate actual Magento modules via the compser.json it contains. Kinda goofy, but I think it allows Mirasvit to sell a module that is really just a bundle of other modules.

    The contents of the directory are:

    • vendor/mirasvit/module-search-elastic-ultimate
      • CHANGELOG.md
      • composer.json

    Maybe baler could just skip over modules that don't contain a valid module.xml file?

    bug 
    opened by friendscottn 6
  • MiniCart, Cart, Checkout Not Working

    MiniCart, Cart, Checkout Not Working

    After setting up baler. I am experiencing the following errors

    • MiniCart not loading [After adding product] Home Page

    • Order Summary not loading in CartPage Cart

    • Checkout page not loading Checkout

    opened by ramesh-durairajaram 5
  • (work-around) Exclude text file 'text!js-translation.json' from bundling

    (work-around) Exclude text file 'text!js-translation.json' from bundling

    This fixes #47.

    Now, I know that this is not the most thorough solution, but this gets my build going again. Feel free to give feedback/merge/decline!

    opened by tdgroot 4
  • Baler finding wrong dirs for files (

    Baler finding wrong dirs for files ("Error: ENOENT: no such file or directory")

    Unsure whether this is or isn't a Baler issue, or something modulemakers could be doing wrong.

    When running 'baler/bin/baler' from the root i get the following message: Error: ENOENT: no such file or directory, open [domain]/vendor/mirasvit/module-helpdesk/etc/module.xml

    My assumption here is that baler is spitting through modules to find dependencies and possible JS files to bundle?

    This is actually correct though, the location it should be looking for is vendor/mirasvit/module-helpdesk/src/Helpdesk/etc/module.xml. I believe the module maps these locations through composer.json:

    image

    It looks like there's an assumption about where baler should find vendor files, based on the generated files? This assumption then doesn't take into account that modulemakers might map their modules in a different way.

    I could be totally off-base here, but hope this helps make baler the tool we'll all be using in a month (or two ;))

    bug 
    opened by jessetaverne 4
  • Create Magento module to load dependencies

    Create Magento module to load dependencies

    baler has 2 pieces that are necessary for bundling to work within Magento.

    • baler - an npm package used to package bundles and generate configuration
    • Magento_Baler - a Magento module that injects necessary <link rel="preload" /> tags into the head of the document

    Requirements

    1. Module must be named Magento_Baler
    2. Module must be published to Magento's composer repository
    3. Module must be compatible with all versions of Magento supported by the Cloud team

    Artifacts made available by baler

    When baler is run, is spits out 2 different types of artifacts

    1. core-bundle.js
    2. baler-preload-map.json (see #3)

    When should Magento_Baler be considered enabled for a given theme?

    1. When Magento_Baler is an enabled module in the store
    2. When the locale folder for the current theme contains a file called requirejs-baler-config.js

    What Work Should Magento_Baler Do?

    Loading of Core Bundle

    On each request:

    1. Replace requirejs-config.js in the head of the document with requirejs-baler-config.js
    2. In the head of the document, add a preload tag that points to balerbundles/core-bundle.js in the root of the current theme's current locale

    Loading of Dynamic Dependencies

    On each request

    1. Collect a list of file paths for all .phtml files being used to render the current request
    2. Read/Parse baler-preload-map.json, which is a sibling of core-bundle.js in the root of the locale.
    3. Create a new list, preloads
    4. For each key in baler-preload-map.json:
      • Check if the .phtml file at that path was used to render
      • If yes, append the dependencies to preloads
    5. De-duplicate the preloads list
    6. For each entry in preloads, add a preload tag to the head of the document

    Disabling Incompatible Features

    The following features should be disabled when Magento_Baler is enabled:

    • JS Bundling
    • JS Minification

    Stretch Goals

    • Make sure the list of .phtml files loaded keeps the order these were loaded on the page. When injecting preload tags in the head, inject them in the same order that the .phtml files were rendered (this effectively prioritizes content higher in the document)
    enhancement 
    opened by DrewML 4
  • is this project still under maintain ?

    is this project still under maintain ?

    I see this reference still mention in magento clould or devdocs but it's not recommended in production. Just wonder adobe/owner/stakeholders still keep funding this or let this die in peace "Because Baler is currently in alpha release, we do not recommend using it in Production environments." https://devdocs.magento.com/cloud/env/variables-build.html#scd_use_baler Seem related with https://github.com/magento/baler/issues/70

    opened by mrtuvn 3
  • Error: ENOTDIR: not a directory, scandir ' .. /app/code/.DS_Store'

    Error: ENOTDIR: not a directory, scandir ' .. /app/code/.DS_Store'

    Then I try to run baler in my root Magento project it stuck with such error: Error: ENOTDIR: not a directory, scandir ' .. /app/code/.DS_Store'

    Yes, I use Mac. To reproduce on Linux try to create the same dir with "."

    opened by EirikSl 3
  • No movement in 7 months. Abandoned?

    No movement in 7 months. Abandoned?

    Hi @DrewML – this repo hasn't seen a commit in over half a year.

    Yet, the DevDocs still has a prominent notice recommending Baler for "Alpha testing."

    Should this notice be removed? Has Baler development been abandoned?

    opened by Leland 4
  • Bump handlebars from 4.1.2 to 4.7.6

    Bump handlebars from 4.1.2 to 4.7.6

    Bumps handlebars from 4.1.2 to 4.7.6.

    Changelog

    Sourced from handlebars's changelog.

    v4.7.6 - April 3rd, 2020

    Chore/Housekeeping:

    Compatibility notes:

    • Restored Node.js compatibility

    Commits

    v4.7.5 - April 2nd, 2020

    Chore/Housekeeping:

    • Node.js version support has been changed to v6+ Reverted in 4.7.6

    Compatibility notes:

    • Node.js < v6 is no longer supported Reverted in 4.7.6

    Commits

    v4.7.4 - April 1st, 2020

    Chore/Housekeeping:

    Compatibility notes:

    • No incompatibilities are to be expected

    Commits

    v4.7.3 - February 5th, 2020

    Chore/Housekeeping:

    • #1644 - Download links to aws broken on handlebarsjs.com - access denied (@Tea56)
    • Fix spelling and punctuation in changelog - d78cc73

    Bugfixes:

    • Add Type Definition for Handlebars.VERSION, Fixes #1647 - 4de51fe
    • Include Type Definition for runtime.js in Package - a32d05f

    Compatibility notes:

    Commits
    Maintainer changes

    This version was pushed to npm by erisds, a new releaser for handlebars since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump lodash from 4.17.15 to 4.17.19

    Bump lodash from 4.17.15 to 4.17.19

    Bumps lodash from 4.17.15 to 4.17.19.

    Release notes

    Sourced from lodash's releases.

    4.17.16

    Commits
    Maintainer changes

    This version was pushed to npm by mathias, a new releaser for lodash since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Cannot generate bundle file when the locale is

    Cannot generate bundle file when the locale is "zh_Hant_HK"

    I have two store view with different languages: en_US and zh_Hant_HK, after I run "baler build" command, I can only find the bundle file in en_US folder. Seems the regex rule in src/magentoFS.ts not support the locale such as "zh_Hant_HK".

    opened by huhu1884 2
Owner
Magento
Magento
Stores the customer_user for WooCommerce orders and subscriptions in the post_author column of posts table.

Post Author Optimization for WooCommerce Requires PHP: 7.0 WP requires at least: 5.7 WP tested up to: 5.7 WC requires at least: 5.6.0 WC tested up to:

Devin Price 9 Apr 2, 2022
Magento 2 Module Experius Page Not Found 404. This module saves all 404 url to a database table

Magento 2 Module Experius Page Not Found 404 This module saves all 404 urls to a database table. Adds an admin grid with 404s It includes a count so y

Experius 28 Dec 9, 2022
Automatically load the next page of products in Magento. Easy to install and configure, this module works 100% out of the box with vanilla Magento 1.9.x and earlier.

Automatically load the next page of products in Magento. Easy to install and configure, this module works 100% out of the box with vanilla Magento 1.9.x and earlier.

Strategery 123 Nov 20, 2021
A tool that allows to quickly export data from Magento 1 and Magento 2 store and import it back into Magento 2

Simple Import / Export tool A tool that allows to quickly export data from Magento 1 and Magento 2 store and import it back into Magento 2. Table data

EcomDev B.V. 51 Dec 5, 2022
❄️ Magento 2 Snowflake module allow you to add snow and even more on your site and make winter fun.

❄️ Magento 2 Snowflake module allow you to add snow and even more on your site and make winter fun.

OpenGento 6 Apr 30, 2022
A Magento 2 module that allows admins to duplicate CMS blocks and pages from their respective grids and en masse.

element119 | CMS Duplicator ?? Features ✔️ Allows merchants to duplicate CMS blocks and pages from the Action column in the admin grid ✔️ Allows merch

Kiel Pykett 13 Oct 13, 2022
The swiss army knife for Magento developers, sysadmins and devops. The tool provides a huge set of well tested command line commands which save hours of work time. All commands are extendable by a module API.

netz98 magerun CLI tools for Magento 2 The n98 magerun cli tools provides some handy tools to work with Magento from command line. Build Status Latest

netz98 758 Dec 28, 2022
Magento 2 module to quickly acces products, orders and customer from admin menu

Magento 2 module to quickly access product, order or customer views Introduction The Magento 2 backend can be sluggish. Ever wanted to access a produc

null 1 Dec 3, 2021
Extract and evolution of the magento2-currency-precision module from the magento2-jp project from @Magento

Currency Precision Module for Magento 2 This module aims to help merchants to manage easily their currency precision in Magento 2. DISCLAIMER Initiall

OpenGento 3 Dec 17, 2021
Mobile detect change theme and redirect based on device type. Magento 2 module.

Magento 2 Mobile Detect Theme Change Magento 2 Mobile detect system can be used to load different themes base on the client device (desktop, tablet, m

EAdesign 27 Jul 5, 2022
Magento 2 Module for parsing xlsx, xlsm and csv files from Excel

Magento 2 Spreadsheet Parser Facts Parse XLSX, XLSM and CSV Files from Excel Requirements PHP >= 7.0.* Magento >= 2.1.* Compatibility Magento >= 2.1 U

Stämpfli AG 9 Sep 24, 2020
Magento 2 Module to add simple image resizing capabilities in all blocks and .phtml templates

Magento 2 Image Resizer Magento 2 Module to add simple image resizing capabilities in all blocks and .phtml templates Installation $ composer require

Stämpfli AG 88 Apr 18, 2022
Magento 2 Debug Helper Module for easy debugging with Xdebug and PHPStorm or any other IDE

Magento 2 Debug Helper Information and Usage Magento 2 Debug Helper Module usage with PHPStorm and Xdebug Installation To install the Magento 2 Debug

Dmitry Shkoliar 13 May 24, 2022
A Magento 2 module that enables configurable CORS Headers on the GraphQL and REST APIs

Magento 2 CORS Magento Version Support Ever try to work with the Magento GraphQL API or REST API from your browser and see the following? Access to XM

Graycore, LLC 62 Dec 8, 2022
A collection of command line scripts for Magento 2 code generation, and a PHP module system for organizing command line scripts.

What is Pestle? Pestle is A PHP Framework for creating and organizing command line programs An experiment in implementing python style module imports

Alan Storm 526 Dec 5, 2022
Magento n98-magerun module for importing and exporting configuration data

Magento n98-magerun module for importing and exporting configuration data. Import supports hierarchical folder structure and of course different environments.

Zookal 61 Apr 1, 2022
Content Fuzzyfyr Module for Magento® 2

Content Fuzzyfyr Module for Magento® 2 The Content Fuzzyfyr module for Magento® 2 fills up empty content fields - and if needed - switches real conten

Hive Commerce 11 Oct 17, 2022