Skip to content

Js error in bundle file #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cuong-tran-solteq opened this issue Oct 2, 2020 · 4 comments
Closed

Js error in bundle file #54

cuong-tran-solteq opened this issue Oct 2, 2020 · 4 comments

Comments

@cuong-tran-solteq
Copy link

cuong-tran-solteq commented Oct 2, 2020

First of all thanks a lot for your amazing work, I give a shot for Magepack since I need a solution for bundling and Baler doesn't seem that much mature for me. It does what I need to create a bundle file and reduce payload. However, I got this issue and I haven't got any idea what could cause it

Preconditions

Install Magento2.3.5-p2, applied patch for mixins.js

Steps to reproduce

I installed magepack, run generate command, deployed static content, magepack bundle, clean cache.
One thing I found that there is some error in prod which may affect the crawling of megapack (is it?)
googleads.g.doubleclick.net/pagead/id:1 Failed to load resource: net::ERR_BLOCKED_BY_CLIENT static.doubleclick.net/instream/ad_status.js:1 Failed to load resource: net::ERR_BLOCKED_BY_CLIENT

Expected result

No JS errors

Actual result
bundle-common.js:formatted:65103 Uncaught TypeError: define(...) is not a function from this part

`(function(factory) {
if (typeof define === 'function' && define.amd) {
define('jquery/jquery.metadata', ["jquery"], factory);
} else {
factory(jQuery);
}
}(function($) {

$.extend({
    metadata: {
        defaults: {
            type: 'class',
            name: 'metadata',
            cre: /({.*})/,
            single: 'metadata',
            meta: 'validate'
        },
        setType: function(type, name) {
            this.defaults.type = type;
            this.defaults.name = name;`
@krakencorals
Copy link

I tried magepack today also, i got the same error as above. coupled with a checkout that didnt work as compareVersions wasnt defined

@cuong-tran-solteq
Copy link
Author

@krzksz Could you please have a look at that issue if it is possible to workaround?

@gwharton
Copy link

gwharton commented Oct 9, 2020

I had to patch with magento/magento2#27690 aswell as the main mixins patch. This is merged into 2.4-develop, but is not in 2.4.0. I had some third party scripts that used define in a non standard way that borked without this additional patch. Since then I've had problems with other code, also to do with requirejs and the way the modules were "defined", but I ended up refactoring the code to work. Its a shame we don't have a paid for slack plan, as there were some good conversations in the past regarding issues such as this.

@cuong-tran-solteq
Copy link
Author

cuong-tran-solteq commented Oct 13, 2020

Thanks, @gwharton I will check that patch also. Let's see if that works in my case.

It seems that patch fix my issue, close ticket.

huge thank @gwharton.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants