Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Advanced JS Bundling examples can lead to problems with JS execution #6025

@k4emic

Description

@k4emic

General issue

Description:

Using the current guide to setup JS bundling can lead to bundles which include domReady! in the bundle.

This results in the main bundle to be included multiple times on the page, which can cause problems with jQuery and other javascript components.

domReady! is included due to the manual writing of the bundle configuration, which doesn't filter out undesireable content (which bundlesConfigOutFile does for some reason).

Possible solutions:

Using bundlesConfigOutFile doesn't exhibit this behavior.

Additional information:

Example config

# build.js

modules: [
    {
        name: 'requirejs/require'
    },
    {
        name: 'mage/bootstrap',
        include: [
            ....
        ]
    }
]
# requirejs-config.js

require.config({
   bundles: {"requirejs/require":[...,"requirejs/domReady","domReady!",...]},
});require.config({
   bundles: {"mage/bootstrap": [....]},
});
....

DOM HTML, after JS has been allowed to run

<head>
...
<script type="text/javascript" src="THEME_URL/da_DK/requirejs/require.js"></script>

...
<script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="domReady!" src="THEME_URL/da_DK/requirejs/require.js"></script>

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions