Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8657993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:39:30+00:00 2026-06-12T15:39:30+00:00

I have code like the following define(ModuleA, [InitialDependency], function (initDep){ return {}; }); define(ModuleB,

  • 0

I have code like the following

define("ModuleA", ["InitialDependency"], function (initDep){
   return {};
});


define("ModuleB", ["ModuleA", "OtherDependency"], function (moduleA, otherDep){
   return {};
});

Each of these modules is defined in separate files “ModuleA.js”, “Moduleb.js”, “InitialDependency.js” and “OtherDependency.js”.

These modules are loaded sequentially in my application. ModuleB is always loaded after ModuleA. this means that in the optimization stage I do not want ModuleA’s script combined in the built script for ModuleB. I want the following

ModuleA.built.js includes

  • InitialDependency
  • ModuleA

ModuleB.built.js includes

  • OtherDependency
  • ModuleB

I don’t want them all in the same file however as ModuleB may never be loaded.

I can do a build script for both modules but this will be time consuming as I have quite a few modules in my project and would like a build script that will build the lot of them at once.

What do I need to know to create a build script for building both of these modules (and more that follow the same dependency pattern)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:39:31+00:00Added an answer on June 12, 2026 at 3:39 pm

    To achieve this, you’d have to play with the modules configuration option.

    It could look like this:

    {
        modules: [
            {
                name: "ModuleA",
                include: [],
                exclude: []
            },
            {
                name: "ModuleB",
                exclude: [
                    "moduleA"
                ]
            }
        ]
    }
    

    There’s a similar example setup by James here: https://github.com/requirejs/example-multipage

    Of course, by building these modules separately, you may end up needing to update paths. If so, the best way then would be to create a file containing a require.config call with special setting for your builded app and including this configuration instead of your usual one. But if you set dependencies in a good separated way, then you’ll probably be fine. By “good separated” way, I mean that if moduleA is the base script, then it shouldn’t have dependencies packed with moduleB – but I guess this is common sense!

    Note about shimmed modules: As shimmed config only work whe files are loaded and by r.js to order plugins, be sure you don’t include a shim module without it’s dependency if you’re not 100% sure these will be loaded before. More info here: https://github.com/requirejs/example-multipage-shim

    Hope this help!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a project where I have code like the following: #define NAME()
I have the following code using require.js. utilities.js: define([thirdparty-script-A.js], function(){ ... }); application.js: define([utilities,
I have code like following: switch(sort.Column) { case code: model = (sort.Direction == SortDirection.Ascending)
I have code like the following... HANDLE event = CreateEvent(NULL, false, false, NULL); //
I have code like the following in a UserControl: Protected Overrides Sub Render(ByVal writer
I have code that looks like the following: //unrelated code snipped resolver.reset(new tcp::resolver(iosvc)); tcp::resolver::query
I have code that looks like the following: <form id=MyForm name=MyForm method=post action=index.php> <input
I quite often have rows of code like the following: UPDATE my_table SET name
I have a simple DOM code like the following <div> <div> </div> </div> I
Imagine you have two views with code like the following: controller_a/a.html.erb <%= content_tag(:div) do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.