baler
baler copied to clipboard
Define and require Js are not founding with baler
I have installed properly baler module on Magento 2.3.4 and its also working but this is not including define or require in bundles and giving errors
mixins.js:5 Uncaught ReferenceError: define is not defined at mixins.js:5 (anonymous) @ mixins.js:5 jquery.mobile.custom.js:43 Uncaught TypeError: Cannot read property 'event' of undefined at jquery.mobile.custom.js:43 at jquery.mobile.custom.js:37 at jquery.mobile.custom.js:20 at jquery.mobile.custom.js:11 (anonymous) @ jquery.mobile.custom.js:43 (anonymous) @ jquery.mobile.custom.js:37 (anonymous) @ jquery.mobile.custom.js:20 (anonymous) @ jquery.mobile.custom.js:11 (index):740 Uncaught TypeError: require.config is not a function at (index):740 (anonymous) @ (index):740 (index):775 Uncaught TypeError: require is not a function at (index):775 (anonymous) @ (index):775 (index):793 Uncaught TypeError: require is not a function at
(index):793
I have the same issues.
mixins.js:5 Uncaught ReferenceError: define is not defined
at mixins.js:5
(anonymous) @ mixins.js:5
jquery.mobile.custom.js:43 Uncaught TypeError: Cannot read property 'event' of undefined
at jquery.mobile.custom.js:43
at jquery.mobile.custom.js:37
at jquery.mobile.custom.js:20
at jquery.mobile.custom.js:11
(anonymous) @ core-bundle.js:1
(anonymous) @ core-bundle.js:1
(anonymous) @ core-bundle.js:1
(anonymous) @ core-bundle.js:1
(index):609 Uncaught TypeError: require.config is not a function
at (index):609
Dockerfile:
FROM bitnami/magento:2.3.4-debian-10-r12
USER root
RUN apt update
RUN apt install wget -y
RUN apt install rsync -y
RUN apt install vim -y
RUN apt install nodejs -y || exit 1
RUN apt install npm -y || exit 1
RUN apt install git -y || exit 1
ENV COMPOSER_MEMORY_LIMIT -1
# This is the home directory of Magento.
WORKDIR /opt/bitnami/magento/htdocs
# This is required so that composer may download shit from Magento repository.
# Go to your Magento account page to change API keys. Having API keys are free.
# Composer will check whether the stuff you are about to download is available
# to you: you bought it.
ADD auth.json .
RUN chown bitnami:daemon auth.json || exit 1
USER bitnami:daemon
# Installing Baler.
RUN git clone https://github.com/magento/baler.git
WORKDIR /opt/bitnami/magento/htdocs/baler
RUN npm install || exit 1
RUN npm test || exit 1
RUN npm run build || exit 1
USER root
RUN npm link || exit 1
RUN chmod a+x /usr/local/bin/baler
USER bitnami:daemon
WORKDIR /opt/bitnami/magento/htdocs
RUN composer require mageplaza/module-core
RUN composer require mageplaza/module-smtp
RUN composer require mageplaza/module-gdpr
RUN composer require mageplaza/magento-2-social-login
RUN composer require dhl/module-rates-express
RUN composer require mageplaza/magento-2-hungarian-language-pack:dev-master
# Continue installing Baler.
RUN sed -i "s|\"minimum-stability\": \"stable\"|\"minimum-stability\": \"dev\",\n\"prefer-stable\": true|g" composer.json
RUN echo "Composer JSON updated as follows:"
RUN cat composer.json
RUN composer config repositories.magento-baler vcs [email protected]:magento/m2-baler.git
RUN composer require magento/module-baler:dev-master
COPY extensions/geo-ip-redirect-1.3.0-CE/app/code/Amasty /opt/bitnami/magento/htdocs/app/code/Amasty
USER root
RUN chown -R bitnami:daemon app
RUN chown -R bitnami:daemon pub
RUN find /opt/bitnami/magento/htdocs -type d -print0 | xargs -0 chmod 775 && find /opt/bitnami/magento/htdocs -type f -print0 | xargs -0 chmod 664 && chown -R bitnami:daemon /opt/bitnami/magento/htdocs
COPY nami.json /root/.nami/components/com.bitnami.magento/nami.json
COPY registry.json /root/.nami/registry.json
COPY volume-init.sh /volume-init.sh
COPY run.sh /run.sh
# This is a hack against the problem described in
# [https://magento.stackexchange.com/questions/296044/invalid-parameter-given-a-valid-fileidtmp-name-is-expected].
# Changing the file-upload-temporary directory will not fix that.
# RUN sed -i "s|;upload_tmp_dir =|upload_tmp_dir = /opt/bitnami/magento/htdocs/var/tmp|g" /opt/bitnami/php/etc/php.ini
# Somewhere Magento checks the validity of the upload directory, outside of the below file.
# Anyway, patching it works nicely. It may be a security issue, but we are running in a Docker container anyway.
RUN sed -i "s|\$isValid = false;|return;|g" /opt/bitnami/magento/htdocs/vendor/magento/framework/File/Uploader.php
Container kick-off command:
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
_forwardTerm () {
echo "Caught signal SIGTERM, passing it to child processes..."
pgrep -P $$ | xargs kill -15 2>/dev/null
wait
exit $?
}
trap _forwardTerm TERM
echo "Adding Magento core cron entries."
ln -sf /opt/bitnami/magento/conf/cron /etc/cron.d/magento
/usr/sbin/cron
echo "Setting up Baler."
sudo -u bitnami php -d memory_limit=8192M bin/magento module:enable Magento_Baler || true
sudo -u bitnami php bin/magento config:set dev/js/enable_baler_js_bundling 1 || true
# Disable incompatible features as suggested by [https://github.com/magento/baler/blob/master/docs/ALPHA.md#disable-incompatible-features-in-magento].
sudo -u bitnami php bin/magento config:set dev/js/minify_files 0 || true
sudo -u bitnami php bin/magento config:set dev/js/enable_js_bundling 0 || true
sudo -u bitnami php bin/magento config:set dev/js/merge_files 0 || true
echo "Running upgrade on Magento."
sudo -u bitnami php -d memory_limit=8192M /opt/bitnami/magento/htdocs/bin/magento setup:upgrade -vvv || true
echo "Running compile on Magento."
sudo -u bitnami php -d memory_limit=8192M /opt/bitnami/magento/htdocs/bin/magento setup:di:compile -vvv || true
echo "Running deployment on Magento sources."
sudo -u bitnami rm -rf pub/static
sudo -u bitnami php -d memory_limit=8192M /opt/bitnami/magento/htdocs/bin/magento setup:static-content:deploy -f -vvv || true
echo "Install and start Cron."
sudo -u bitnami php bin/magento cron:install || true
echo "Maybe adding custom cron entries."
if [ -f "/opt/bitnami/magento/htdocs/custom-cron-entries" ]; then
echo "Found custom cron entries, so adding it to 'crontab -e'."
echo "Custom cron entries are: "
cat /opt/bitnami/magento/htdocs/custom-cron-entries
runuser -l bitnami -c '(crontab -l 2>/dev/null; cat /opt/bitnami/magento/htdocs/custom-cron-entries) | crontab -'
fi
echo "Setting [php.ini] entires:"
echo " memory_limit = 4096M"
sed -i "s|memory_limit = 128M|memory_limit = 4096M|g" /opt/bitnami/php/etc/php.ini
echo " opcache.memory_consumption = 4096"
sed -i "s|opcache.memory_consumption = 128|opcache.memory_consumption = 4096|g" /opt/bitnami/php/etc/php.ini
echo " opcache.enable_cli = 1"
sed -i "s|opcache.enable_cli = 0|opcache.enable_cli = 1|g" /opt/bitnami/php/etc/php.ini
echo " opcache.max_accelerated_files=100000"
sed -i "s|;opcache.max_accelerated_files=10000|opcache.max_accelerated_files=100000|g" /opt/bitnami/php/etc/php.ini
echo "Starting Apache..."
exec httpd -f /opt/bitnami/apache/conf/httpd.conf -D FOREGROUND
At least something works:

sudo -u bitnami rm -rf pub/static
At the very least this is incorrect (I see it incorrectly stated in the instructions for Baler), this will also remove the .htaccess file which is responsible for rewriting the static file urls with the current version in production mode.
sudo -u bitnami rm -rf pub/static/* is safer, since it will ignore the .htaccess file
Additionally it seems like you never actually ran baler build in magento root directory to generate the bundle.
You may also need to clean magento cache.
I have found out that the .htaccess file is automatically regenerated every time.
You are correct, baler build and php bin/magento cache:clean commands are missing. I have been running them manually, but also included them in the Dockerfile and run.sh later, with no success.
I ended up using an extension for money, which paid for itself since setting up Baler is a mess. As far as Baler's stability, patching and documentation goes, for anyone currently seriously trying to make Magento faster in production would just buy an extension that works. Toying with Baler in development just makes no sense, since speed is really required in production.
The blog post on Baler is not well structured, hard to go over it, and very inaccurate.
@zzvara Thanks for your response. I did as you described but the issue not sloved. if you applied other solution for speed optimization kindly mention here.
There are several tools, one of them is Google Page Speed Optimizer I used. It provided 85 scores.
@zzvara I Installed GPSO but this is not working with Codazone Fastest Theme. giving a lot errors.
You still have to clean cache, deploy static files and set up GPSO correctly to work. I had troubles with it as well.