question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Improvement] Bundle Config

See original GitHub issue

At this point, Magepack doesn’t support a custom config for bundles. Ideally, it’s needed to be able to define bundles as complex Magento builds have more spaces than CMS, Product, Category and Checkout. With the current config, all those custom pages will be broken which makes Magepack impossible to use on such builds.

I would add a config file where I would define bundles and URLs which are included to them like this:

magepack.config.json:

{
    "bundles": {
        "cms": {
            // possibly other configs
            "urls": [
                "/homepage",
                "/404"
            ]
        },
        "category": {
            //...
        },
        "product": {
            //...
        },
        "checkout": {
            //...
        }
    }
}

As a result, the generate command would take baseUrl, httpAuthUser and httpAuthPass as a param.

The backend part (https://github.com/magesuite/magepack-magento) seems to be flexible enough to support custom bundles. Just need to adjust the generator.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:18

github_iconTop GitHub Comments

11reactions
krzkszcommented, Apr 22, 2020

Alright, so I would like to summarize my take on this request.

First of all, we should be aware that preparing perfect bundles is not possible and there will most likely be modules that are loaded normally via RequireJS and for me that’s OK. The performance improvement of having most of them bundled is enough to get great results anyway.

That said, I think I am comfortable with making Magepack more configurable if somebody wishes to do so while preserving basing CLI usage for a nice baseline. My proposal would be to allow for the configuration that can be stored in the file in shape of:

module.exports = {
  'bundle-name': {
     urls: ['https://example.com'],
     additionalModules: [],
     ignoreModules: /something/,
     extractCommons: true,
 }
}

That way you could:

  • Disable existing bundles, by passing for example 'cms': null in the config.
  • Pass multiple URLs to visit which would solve #16
  • Add additional modules by hand to cover #17
  • Ignore modules when needed through RegExp.
  • Create unlimited additional bundles.
  • Pass custom checkout and cart URLs for checkout bundle to solve #22

The only issue I see, is that I think it would be best for this config to be named magepack.config.js and then Magepack would generate something like magepack.bundles.js with final bundling configuration so it would be a breaking change.

Waiting for your feedback. I think I could tackle this enhancements somewhere around weekend or next week if everyone agrees.

3reactions
roma-glushkocommented, Apr 16, 2020

@krzksz thank you for the replay 🙌

Those pages which don’t have their own bundles should still benefit from common bundle being loaded and all the other modules should be properly loaded via separate files using normal RequireJS mechanism.

Let me show you my real-life example to show the case. On the website, we have a completely custom space called - gallery. It consists of the album listing and album view pages. This is absolutely true, there are using some of the general JS files (collected in the common bundle). However, the crucial JS logic on those pages is unique and includes only there, because it’s not needed on the product, category or CMS pages. Without having an ability to create a separate bundle for this page, I just end up breaking it.

The second possible case here is to create a homepage bundle. The performance of the homepage is usually a big deal from a lot of angles. For example, that would be suboptimal to include relatively heavy lightbox or slider which are not used directly on the homepage, but using somewhere on the about us, how-to or other possible CMS pages.

Just like with the homepage, it’s completely possible to have functionality that is even more valuable for the business than the checkout flow (like forms from where shop leads come from). Naturally, that would be good to have an ability to optimize it or at least keep working.

What do you think about the mentioned cases?

it ended up being very cumbersome and hard to maintain.

What if there would be a possibility to specify bundles as a list of pages to check with CMS-like collection logic? This doesn’t sound like adjustments which are far away from what we have right now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bundle-config - - Set bundler configuration options
This command allows you to interact with Bundler's configuration system. Bundler loads configuration settings in this order:.
Read more >
Bundling and Minification | Microsoft Learn
NET 4.5 to improve request load time. ... Open the App\_Start\BundleConfig.cs file and examine the RegisterBundles method which is used to ...
Read more >
How do you get bundle config to use multiple build options?
In my case ( bundler-1.17.2 , bundler-2.0.2 ) it was passing all the arguments as one: $ bundle config --local build.openssl ...
Read more >
One Weird Trick That Will Speed Up Your Bundle Install
This is a commonly used argument with bundle install to improve ... at least not with our default Rails/MRI setup, and that we're...
Read more >
Improving JavaScript Bundle Performance With Code-Splitting
Improving JavaScript Bundle Performance With Code-Splitting ... on the project configuration and out-of-the-box framework features.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found