Skip to content

Commit 2e1e170

Browse files
committed
ACP2E-4058: Not minified JS sometimes loads ignoring 'enable js minifications'
1 parent 0a8d6e0 commit 2e1e170

File tree

5 files changed

+19
-156
lines changed

5 files changed

+19
-156
lines changed

app/code/Magento/Deploy/Service/DeployRequireJsConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function deploy($areaCode, $themePath, $localeCode)
110110
]
111111
);
112112

113-
$fileManager->createRequireJsConfigAsset();//see here
113+
$fileManager->createRequireJsConfigAsset();
114114

115115
$fileManager->createMinResolverAsset();
116116

app/code/Magento/Theme/view/frontend/requirejs-config-minify.js

Lines changed: 0 additions & 78 deletions
This file was deleted.

lib/internal/Magento/Framework/RequireJs/Config.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright 2014 Adobe
4-
* All Rights Reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
55
*/
66
namespace Magento\Framework\RequireJs;
77

@@ -20,32 +20,27 @@ class Config
2020
*
2121
* @deprecated since 2.2.0 RequireJS Configuration file is moved into package directory
2222
*/
23-
public const DIR_NAME = '_requirejs';
23+
const DIR_NAME = '_requirejs';
2424

2525
/**
2626
* File name of RequireJs config
2727
*/
28-
public const CONFIG_FILE_NAME = 'requirejs-config.js';
29-
30-
/**
31-
* File name of minified RequireJs config
32-
*/
33-
public const CONFIG_FILE_NAME_MIN = 'requirejs-config-minify.js';
28+
const CONFIG_FILE_NAME = 'requirejs-config.js';
3429

3530
/**
3631
* File name of RequireJs mixins
3732
*/
38-
public const MIXINS_FILE_NAME = 'mage/requirejs/mixins.js';
33+
const MIXINS_FILE_NAME = 'mage/requirejs/mixins.js';
3934

4035
/**
4136
* File name of RequireJs
4237
*/
43-
public const REQUIRE_JS_FILE_NAME = 'requirejs/require.js';
38+
const REQUIRE_JS_FILE_NAME = 'requirejs/require.js';
4439

4540
/**
4641
* File name of StaticJs
4742
*/
48-
public const STATIC_FILE_NAME = 'mage/requirejs/static.js';
43+
const STATIC_FILE_NAME = 'mage/requirejs/static.js';
4944

5045
/**
5146
* File name of minified files resolver
Lines changed: 8 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
<?php
22
/**
3-
* Copyright 2014 Adobe
4-
* All Rights Reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
55
*/
66

77
namespace Magento\Framework\RequireJs\Config\File\Collector;
88

99
use Magento\Framework\App\Filesystem\DirectoryList;
10-
use Magento\Framework\Filesystem;
11-
use Magento\Framework\RequireJs\Config as RequireJsConfig;
12-
use Magento\Framework\View\Asset\Minification;
1310
use Magento\Framework\View\Design\ThemeInterface;
1411
use Magento\Framework\View\File\CollectorInterface;
15-
use Magento\Framework\View\File\Factory;
1612

1713
/**
1814
* Source of RequireJs config files basing on list of directories they may be located in
@@ -46,37 +42,29 @@ class Aggregated implements CollectorInterface
4642
protected $libDirectory;
4743

4844
/**
49-
* @var Factory
45+
* @var \Magento\Framework\View\File\Factory
5046
*/
5147
protected $fileFactory;
5248

5349
/**
54-
* @var Minification
55-
*/
56-
private Minification $minification;
57-
58-
/**
59-
* @param Filesystem $filesystem
60-
* @param Factory $fileFactory
50+
* @param \Magento\Framework\Filesystem $filesystem
51+
* @param \Magento\Framework\View\File\Factory $fileFactory
6152
* @param CollectorInterface $baseFiles
6253
* @param CollectorInterface $themeFiles
6354
* @param CollectorInterface $themeModularFiles
64-
* @param Minification $minification
6555
*/
6656
public function __construct(
67-
Filesystem $filesystem,
68-
Factory $fileFactory,
57+
\Magento\Framework\Filesystem $filesystem,
58+
\Magento\Framework\View\File\Factory $fileFactory,
6959
CollectorInterface $baseFiles,
7060
CollectorInterface $themeFiles,
71-
CollectorInterface $themeModularFiles,
72-
Minification $minification
61+
CollectorInterface $themeModularFiles
7362
) {
7463
$this->libDirectory = $filesystem->getDirectoryRead(DirectoryList::LIB_WEB);
7564
$this->fileFactory = $fileFactory;
7665
$this->baseFiles = $baseFiles;
7766
$this->themeFiles = $themeFiles;
7867
$this->themeModularFiles = $themeModularFiles;
79-
$this->minification = $minification;
8068
}
8169

8270
/**
@@ -104,47 +92,6 @@ public function getFiles(ThemeInterface $theme, $filePath)
10492
$files = array_merge($files, $this->themeModularFiles->getFiles($currentTheme, $filePath));
10593
$files = array_merge($files, $this->themeFiles->getFiles($currentTheme, $filePath));
10694
}
107-
//return $files;
108-
return $this->adjustMinification($theme, $files, $filePath);
109-
}
110-
111-
/**
112-
* @param ThemeInterface $theme
113-
* @param array $files
114-
* @param string $filePath
115-
* @return array
116-
*/
117-
private function adjustMinification(ThemeInterface $theme, array $files, string $filePath): array
118-
{
119-
if ($this->minification->isEnabled('js') && $filePath === RequireJsConfig::CONFIG_FILE_NAME) {
120-
$minifiedConfigurations = $this->baseFiles->getFiles($theme, RequireJsConfig::CONFIG_FILE_NAME_MIN);
121-
foreach ($theme->getInheritedThemes() as $currentTheme) {
122-
$minifiedConfigurations = array_merge(
123-
$minifiedConfigurations,
124-
$this->themeModularFiles->getFiles($currentTheme, RequireJsConfig::CONFIG_FILE_NAME_MIN)
125-
);
126-
$minifiedConfigurations = array_merge(
127-
$minifiedConfigurations,
128-
$this->themeFiles->getFiles($currentTheme, RequireJsConfig::CONFIG_FILE_NAME_MIN)
129-
);
130-
}
131-
if (!empty($minifiedConfigurations)) {
132-
/* @var \Magento\Framework\View\File $file */
133-
foreach ($files as $key => $file) {
134-
foreach ($minifiedConfigurations as $minifiedConfiguration) {
135-
$replacedFilename = str_replace(
136-
RequireJsConfig::CONFIG_FILE_NAME_MIN,
137-
RequireJsConfig::CONFIG_FILE_NAME,
138-
$minifiedConfiguration->getFilename()
139-
);
140-
if ($file->getFilename() === $replacedFilename) {
141-
$files[$key] = $minifiedConfiguration;
142-
}
143-
}
144-
}
145-
}
146-
}
147-
14895
return $files;
14996
}
15097
}

lib/web/mage/requirejs/mixins.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Copyright © Magento, Inc. All rights reserved.
3-
* See COPYING.txt for license details.
2+
* Copyright 2015 Adobe
3+
* All Rights Reserved.
44
*/
55
define('mixins', [
66
'module'
@@ -17,8 +17,7 @@ define('mixins', [
1717
paths: defaultConfig.paths,
1818
shim: defaultConfig.shim,
1919
config: defaultConfig.config,
20-
map: defaultConfig.map,
21-
nameToUrl: defaultConfig.nameToUrl,
20+
map: defaultConfig.map
2221
},
2322
rjsMixins;
2423

0 commit comments

Comments
 (0)