Skip to content
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

systax error and mixins config do not work #57

Open
1 of 4 tasks
zmrdlb opened this issue May 30, 2019 · 1 comment
Open
1 of 4 tasks

systax error and mixins config do not work #57

zmrdlb opened this issue May 30, 2019 · 1 comment

Comments

@zmrdlb
Copy link

zmrdlb commented May 30, 2019

This issue is a:

  • Bug
  • Feature suggestion
  • Documentation issue
  • Other (Please Specify)

Description

The common bundle and a page-special bundle are in front of requirejs-config.js after building. For this situation, there are many systax errors on checkout page, and mixins config of requirejs do not work.

Possible solutions:

Requirejs configuration should be loaded and executed before other modules with AMD by reference to Requirejs API and Require Optimizer. Besides, our code depend on polyfill.js and requirejs-mixins.js and so on. So, a page-special bundle should be placed at the end of head tag.

I modified the function _prepareLayout() in Magento_BundleConfig/Block/Html/Head/Config.php. It works.

if (file_exists($pageSpecificBundleAbsPath)) {
            $assetCollection->add(
                $pageSpecificBundleRelPath,
                $bundleConfig
            );
        }
@kweij
Copy link

kweij commented Jan 23, 2020

The shared bundle should also be loaded after mage/requirejs/mixins.js and requirejs-config.js. So I fixed this in Magento_BundleConfig/Block/Html/Head/Config.php by replacing:

        if (file_exists($sharedBundleAbsPath)) {
            $assetCollection->insert(
                $sharedBundleRelPath,
                $shared,
                RequireJsConfig::REQUIRE_JS_FILE_NAME
            );
        }

by

        if (file_exists($sharedBundleAbsPath)) {
            $assetCollection->add(
                $sharedBundleRelPath,
                $shared
            );
        }

Which places both the shared and the page-specific bundles after the aforementioned JS files.

kweij pushed a commit to kweij/m2-devtools that referenced this issue Jan 23, 2020
Instead of inserting the bundles directly after `requirejs/require`, append the bundles using `add`. This causes the bundles to be loaded after 2 important files that need to be loaded before these bundles: `requirejs-config` and `mage/requirejs/mixins`.

This fixes issue magento#57
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

2 participants