Skip to content

question #3

Description

@ORESoftware

hey there, thanks for this example project, I am trying to follow along

one thing I am confused about, is that there seems to be a "bundles" property in the requirejs.config({}) object...but there is also a "modules" property in the build.js file for the r.js optimizer

my goal is to create 5 or 6 separate bundles for my SPA

I assume I need to use r.js to create the bundles/modules, but my question is - what is the purpose of the "bundles" property in requirejs.config({})? What is the relationship between the bundles property and the modules property in the build file?

in other words, when I use the following configuration, and run r.js, it says

Error: Error: ERROR: module path does not exist: /Users/amills001c/WebstormProjects/ORESoftware/sc-admin-ui-express/public/static/shared.js for module named: shared. Path is relative to: /Users/amills001c/WebstormProjects/ORESoftware/sc-admin-ui-express
    at /usr/local/lib/node_modules/requirejs/bin/r.js:28051:35

but I don't know why r.js is looking for shared.js? I would assume r.js would be creating shared.js, not reading from it...

really confusing

here is the configuration (I am just using a basic build file to do a proof of concept)

build.modules.js:

({
    "allowSourceOverwrites": false,
    "preserveLicenseComments": false,
    "findNestedDependencies": false,
    "optimizeAllPluginResources": true,
    "dir":"../public/bundles",
    "baseUrl": "../public/static",
    "optimize":"none",
    "mainConfigFile": "../public/static/app/js/main.js",
    "normalizeDirDefines": "all",
    "paths" :{
        requireLib : 'vendor/require',
        jqueryUI: "empty:",
        jqueryUICSS: "empty:"
    },
    "modules": [
        {
            name: "shared",
            include: [
                'jquery',
                'async',
                'backbone'
            ],
            exclude:[]
        }
    ],
    "stubModules":['text']
})

main.js:

    requirejs.config({
        enforceDefine: false,
        waitSeconds: 7,
        baseUrl: '/static',
        bundles: {
            'shared': [],
            'secondary': []
        },
        paths: {

            'async': 'vendor/async',
            'jquery': 'vendor/jquery',
            'util(NPM)': 'vendor/util',
            'ejs': 'vendor/ejs',
            'flux': 'vendor/Flux',
            'text': 'vendor/text',
            'form2js': 'vendor/form2js',
            'underscore': 'vendor/underscore-min',
            'ijson': 'vendor/idempotent-json',
            'backbone': 'vendor/backbone',
            'bootstrap': 'vendor/bootstrap',
            'backbone-validation': 'vendor/backbone-validation-amd',
            'observe': 'vendor/observe',
            'react': 'vendor/react-with-addons',
            'socketio': 'vendor/socketio',
            'events': 'vendor/events-amd',
            '@eventBus': 'app/js/eventBuses/routerEventBus',
            '#Adhesive': 'app/js/adhesive/Adhesive',
            '@hotReloader': 'app/js/hot-reloading/hotReloader',
            '*jsPatches': 'app/js/patches/jsPatches',
            '*backbonePatches': 'app/js/patches/backbonePatches',
            '*windowPatches': 'app/js/patches/windowPatches',
            '+appState': 'app/js/state/appState',
            '+viewState': 'app/js/state/viewState',
            '#allTemplates': 'app/js/meta/allTemplates',
            '#allViews': 'app/js/meta/allViews',
            '#allModels': 'app/js/meta/allModels',
            '#allCollections': 'app/js/meta/allCollections',
            '#allControllers': 'app/js/meta/allControllers',
            '#allDispatchers': 'app/js/meta/allDispatchers',
            '#allCSS': 'app/js/meta/allCSS',
            '#allFluxActions': 'app/js/meta/allFluxActions',
            '#allFluxConstants': 'app/js/meta/allFluxConstants',
            '@oplogSocketClient': 'app/js/oplogSocketClient',
            '@BaseCollection': 'app/js/collections/BaseCollection',
            '@SuperController': 'app/js/controllers/SuperController',
            '@AppDispatcher': 'app/js/flux/dispatcher/AppDispatcher',
            '@Router': 'app/js/routers/router'

        },

        'shim': {

            'underscore': {
                'exports': '_'
            },

            'backbone': {
                'deps': ['jquery', 'underscore'],
                'exports': 'Backbone'
            },

            ejs: {
                exports: "ejs"
            }
        }

    });

    define('///START///', ['backbone'], function () {  

        require(['app/js/application'], function (Application) {

            Application.start();

        });
    });

    require(['///START///']);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions