Forum Stats

  • 3,824,874 Users
  • 2,260,435 Discussions
  • 7,896,336 Comments

Discussions

Having issues with build for release with two Packs with bundles

Nathan Zentner
Nathan Zentner Member Posts: 30 Green Ribbon
edited Jun 24, 2022 12:08AM in Oracle JET

I have two packs with Bundles defined in each. When I build for "release" I get the following error:

The following modules share the same URL. This could be a misconfiguration if that URL only has one anonymous module in it

It does not fail when I only include a common-library, but when I include web components then it does fail. Below is the full error with first line in the stack trace. I have looked up this error on the web and they are talking about anonymous modules

  • If you manually code an HTML script tag, be sure it only includes named modules, and that an anonymous module that will have the same name as one of the modules in that file is not loaded.


Error: Error: Module loading did not complete for: bundle-temp, root, appController, hrt-accomm/common-libraries/index, hrt-osc/common-libraries/index, hrt-accomm/incident-detail/incident-detail-viewModel, hrt-accomm/incident-detail/loader, hrt-accomm/incident-timeoff/incident-timeoff-viewModel, hrt-accomm/incident-timeoff/loader, hrt-osc/simple-nav/loader, hrt-osc/router-nav/loader, hrt-osc/employee-lookup/loader

The following modules share the same URL. This could be a misconfiguration if that URL only has one anonymous module in it:

C:/ClientWork/Azure/ojet-core/web/js/jet-composites/hrt-accomm/1.0.0/min/hrt-accomm-bundle.js: hrt-accomm/common-libraries/index, hrt-accomm/incident-detail/loader, hrt-accomm/incident-timeoff/loader, hrt-accomm/common-libraries/index, hrt-accomm/incident-detail/loader, hrt-accomm/incident-notices/loader, hrt-accomm/incident-timeoff/loader

C:/ClientWork/Azure/ojet-core/web/js/jet-composites/hrt-osc/1.0.0/min/hrt-osc-bundle.js: hrt-osc/common-libraries/index, hrt-osc/simple-nav/loader, hrt-osc/router-nav/loader, hrt-osc/employee-lookup/loader

C:/ClientWork/Azure/ojet-core/web/js/root.js: root, root

C:/ClientWork/Azure/ojet-core/web/js/appController.js: appController, appController

C:/ClientWork/Azure/ojet-core/web/js/jet-composites/hrt-accomm/1.0.0/min/incident-detail/incident-detail-viewModel.js: hrt-accomm/incident-detail/incident-detail-viewModel, hrt-accomm/incident-detail/incident-detail-viewModel

C:/ClientWork/Azure/ojet-core/web/js/jet-composites/hrt-accomm/1.0.0/min/incident-timeoff/incident-timeoff-viewModel.js: hrt-accomm/incident-timeoff/incident-timeoff-viewModel, hrt-accomm/incident-timeoff/incident-timeoff-viewModel

  at Function.build.checkForErrors (C:\ClientWork\Azure\ojet-core\node_modules\requirejs\bin\r.js:29878:19)

  at C:\ClientWork\Azure\ojet-core\node_modules\requirejs\bin\r.js:28332:19

Best Answer

  • Duncan Mills-Oracle
    Duncan Mills-Oracle Member Posts: 4,078 Employee
    Answer ✓

    I am wrapped up for the day and heading out but something to try would be to edit your scripts/build/before_optimize.js hook to something like this which will exclude the packs from the main component bundle so that they don't get double-bundled so to speak

    'use strict'

    module.exports = function (configObj) {

      return new Promise((resolve, reject) => {

        console.log("Running before_optimize hook.");

        configObj.requireJs.paths['hrt-accomm'] = 'empty:';

        configObj.requireJs.paths['hrt-osc'] = 'empty:';

     resolve(configObj); });

    };     

Answers

  • Hi Nathan, I'll try and get someone to help on this as quickly as possible. I don't know the answer myself and the person I would normally run to, is out on vacation for all of next week. I'll see if I can grab him before he is really "gone". :-)

  • Duncan Mills-Oracle
    Duncan Mills-Oracle Member Posts: 4,078 Employee
    Answer ✓

    I am wrapped up for the day and heading out but something to try would be to edit your scripts/build/before_optimize.js hook to something like this which will exclude the packs from the main component bundle so that they don't get double-bundled so to speak

    'use strict'

    module.exports = function (configObj) {

      return new Promise((resolve, reject) => {

        console.log("Running before_optimize hook.");

        configObj.requireJs.paths['hrt-accomm'] = 'empty:';

        configObj.requireJs.paths['hrt-osc'] = 'empty:';

     resolve(configObj); });

    };     

  • Nathan Zentner
    Nathan Zentner Member Posts: 30 Green Ribbon
    edited Jun 24, 2022 7:03PM

    You can forget this, I resolved the issue myself. In a previous help request, I was asking about building two packs and having the one set of objects in a child pack reference objects in a parent pack. You had me add a line to the "before_component_optimize" hook, that that sets the path to "empty". The only thing was the if statement was not excluding the bundle. Small adjustment and now everything appears to be working correctly. I will push to server and see how it works.


    Seems to allow the process to keep flowing, but the second bundle does not seem to be building correctly.

    The first bundle starts with "define" and has a define for all files within each of the components.


    The second bundle only has a require within and pointers to all the components defined within the bundles.

    hrt-osc-bundle.js

    require(["hrt-osc/common-libraries/index","hrt-osc/simple-nav/loader","hrt-osc/router-nav/loader"],(function(){})),define("hrt-osc-bundle",(function(){}));