Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

Is RequireJS include: [... list of files, not just one file...] supported? #94

Open
kajmagnus79 opened this issue May 13, 2014 · 2 comments

Comments

@kajmagnus79
Copy link

This works fine for me:

requireJs {
    source = ...
    dest = ...
    requirejs.options = [
        baseUrl: ...
        name: ...
        paths: [
            requireLib: "External/require",
        ],
        include: 'External/require',
        optimize: 'none'
    ]
}

But this fails: (the only difference is the include: part)

requireJs {
    source = ...
    dest = ...
    requirejs.options = [
        baseUrl: ...
        name: ...
        paths: [
            requireLib: "External/require",
        ],
        include: [                  <-- an array causes an error
            'External/require',
            'Some/File',
            'Another/File'
        ],
        optimize: 'none'
    ]
}

With this weird error: (note the [)

java.io.FileNotFoundException: /data/dev/cms-components/resources/js/[External/require.js (No such file or directory)

I'm getting the impression that include: only works with one single file, and that Gradle attempts to convert the array to a string, hence the [. Am I correct that include only works with one file?

((Listing many files is supported with the pure Javascript "version" of RequireJS.))

@venkataraghu
Copy link

I too faced this issue. requireJs gradle task is not handling the conversion from options map to command line arguments properly

I picked this code from GradleJSTask

options.each() { key, value ->
logger.debug("${key} == ${options[value]}")
def keyAlreadyAdded = (key.equalsIgnoreCase("out") && dest) || (key.equalsIgnoreCase("dir") && destDir)
if (!keyAlreadyAdded) {
args.add("${key}=${value}")
}
}

the above code is not handling the array input properly. it should convert the array input to something like this "include=requireLib, anothermodule"

there are other limitations in command line syntax. this is found on requirejs.org
There is a limitation on the command line argument syntax. Dots are viewed as object property separators, to allow something like paths.jquery=lib/jquery to be transformed to the following in the optimizer:
paths: {
jquery: 'lib/jquery'
}

Hence, i preferred to use requirejs.buildProfile options instead of requirejs.options

please refer this link for more information
requirejs/requirejs#369 (comment)

@parthirecipes
Copy link

Hi,

I am trying gradle js plugin for requireJS but it failing.

build.gradle:

requireJs {
source = javascript.source.dev.js.files
dest = file("${buildDir}/portal-all.js")
requirejs.buildprofile = new File("tools/build.js")

}

And my build.js :

({
appDir: '../WebRoot',
dir: '../build',
mainConfigFile: '../WebRoot/application/main.js',
optimizeCss: 'none',
optimize: 'none',
fileExclusionRegExp: /WEB-INF|META-INF|assets|doc|nodejs|bootstrap-sass/,
modules: [
//First set up the common build layer.
{
//module names are relative to baseUrl
name: 'application/main',
excludeShallow: ['angular',
'angular-resource',
'kendo.directives'

        ]
    }

]

})

Error:

:portal:requireJs
Error: Error: Missing either a "name", "include" or "modules" option
:portal:requireJs FAILED

FAILURE: Build failed with an exception.

Any help would be appreciated.

Thanks,
Parthi

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants