m2-devtools icon indicating copy to clipboard operation
m2-devtools copied to clipboard

systax error and mixins config do not work

Open zmrdlb opened this issue 6 years ago • 1 comments

This issue is a:

  • [x] 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
            );
        }

zmrdlb avatar May 30 '19 09:05 zmrdlb

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 avatar Jan 23 '20 09:01 kweij