FriendsOfShopware / shopware-cli

CLI for Shopware Account and Shopware 6
MIT License
84 stars 32 forks source link

all.js problem with packed plugins when override Shopware core functionality #430

Open arthur-ditegra opened 2 weeks ago

arthur-ditegra commented 2 weeks ago

PHP Version

8.1

Shopware Version

6.5.8.10

Plugin Version

0.4.54

Actual behaviour

The Problem happens when installing the Plugin in an excising or newly created Shopware system. In this example, we override the off canvas cart: PluginManager.override('OffCanvasCart', OverOffcanvasCart, '[data-offcanvas-cart]'); An Error is thrown when the packet part reaches o = l.Z.serialize(t); l should be the off canvas cart or an Object. I am not sure there. This is not the first time it has happened, somehow the packet all.js has some wrong Id's set.

Expected behaviour

The packed all.js should behave the same when packing a Plugins JavaScript into an all.js file.

Steps to Reproduce?

For this example, you can use this:

main.js

import TestOffcanvasCart from './plugin/test-offcanvas-cart/test-offcanvas-cart.plugin';

const PluginManager = window.PluginManager;
PluginManager.override('OffCanvasCart', TestOffcanvasCart, '[data-offcanvas-cart]');

test-offcanvas-cart.plugin.js.js

import OffcanvasCartPlugin from 'src/plugin/offcanvas-cart/offcanvas-cart.plugin';

export default class TestOffcanvasCartPlugin extends OffcanvasCartPlugin {

    _onChangeProductQuantity(event) {
        const select = event.target;
        const form = select.closest('form');
        const selector = this.options.cartItemSelector;
        this.$emitter.publish('onChangeProductQuantity');
        //
        const url = window.router['frontend.cart.offcanvas'];
        const _callback = () => {
            this.client.get(url, response => {
                this._updateOffCanvasContent(response);
                this._registerEvents();
            }, 'text/html');
        };
        this._fireRequest(form, selector, _callback);
    }
}

I hope this is enough information to reproduce.

shyim commented 2 weeks ago

what did you specified in the plugin as compatiblity for shopware version? By default it takes the oldest shopware version to build it with could break it

arthur-ditegra commented 1 week ago

Thanks for the reply @shyim.

This is in our compose.json:

    "shopware/core": "~6.6.0",
    "shopware/storefront": "~6.6.0"

This means the CLI tool will use SW 6.6.0. What we found out in the docs.

For this reason, we fixed the used CLI version in our Pipeline to the current Shopware version:

 - name: Install shopware-cli
        uses: FriendsOfShopware/shopware-cli-action@v1
        with:
          version: ${{ env.SHOPWARE_CLI_VERSION }}

Some additional information: We use the GitHub Actions version of the CLI tool.

PS.: I hope you will find a good replacement name for shopware-cli ;)

shyim commented 1 week ago

Can you maybe provide the zip file of the plugin?

arthur-ditegra commented 1 week ago

Yes, sure, I got the permission to do so. Can I DM you with the ZIP in Slack or via E-Mail?

shyim commented 1 week ago

yes slack is fine :)