How can I get requirejs modules to compile as expected?

Refresh

November 2018

Views

65 time

0

Below is an experimental build.js file I am creating to test compiling a multi-module application with require.js. When I run the following it builds, but the resulting ./scripts/main.js does not have require.js inlined into it as would be expected.

If I remove the 2nd module definition, it will then compile as expected. I've read the docs and looked Burke's multi-page example here -> https://github.com/requirejs/example-multipage/tree/master/www all to no avail. I have tried various permutations of the include/exclude settings all to no avail.

Any pointers on what I may be doing wrong would be appreciated.

var requirejs = require('requirejs');

var config = {
    appDir: './app',
    baseUrl: './',
    paths: {
        requireLib: './scripts/require'
    },
    optimize: false,
    modules: [
        {
            name: './scripts/main',
            include: ['requireLib']
        }
    ,
        {
            name: './scripts/moduleA/main',
            include: ['./scripts/moduleA/main'],
            exclude: ['./scripts/main',
                      'requireLib']
        }
    ],
    dir: 'app-debug'
}

requirejs.optimize(config, function(buildResponse) {
    var contents = fs.readFileSync(config.out, 'utf8');
}, function(err) {
});

1 answers

0

В этом случае requireLib должно быть избыточным, как загружается независимо друг от друга require.js