Durandal.js optimizer not working (empty main-buil

2020-04-14 04:33发布

问题:

I'm trying to get Durandal.js optimizer working on my test project, but it seems to generate nothing to main-built.js. I use the following command from node.js command prompt, in durandal/amd folder:

optimizer.exe --verbose true

Result is

Using default base configuration.
Configuring for deploy with almond (custom).
{
  "name": "durandal/amd/almond-custom",
  "inlineText": true,
  "stubModules": [
    "durandal/amd/text"
  ],
  "paths": {
    "text": "durandal/amd/text"
  },
  "baseUrl": "C:\\Users\\Tommi Gustafsson\\Documents\\Visual Studio 2012\\Projects\\DurandalTests\\DurandalTest1\\TestApp",
  "mainConfigFile": "C:\\Users\\Tommi Gustafsson\\Documents\\Visual Studio 2012\\Projects\\DurandalTests\\DurandalTest1\\TestApp\\main.js",
  "include": [
    "main-built",
    "main",
    "bindings/tinymce-binding",
    "durandal/app",
    "durandal/composition",
    "durandal/events",
    "durandal/http",
    "text!durandal/messageBox.html",
    "durandal/messageBox",
    "durandal/modalDialog",
    "durandal/system",
    "durandal/viewEngine",
    "durandal/viewLocator",
    "durandal/viewModel",
    "durandal/viewModelBinder",
    "durandal/widget",
    "durandal/plugins/router",
    "durandal/transitions/entrance",
    "raphael-amd/eve.0.3.4",
    "raphael-amd/raphael.2.1.0.amd",
    "raphael-amd/raphael.2.1.0.core",
    "raphael-amd/raphael.2.1.0.svg",
    "raphael-amd/raphael.2.1.0.vml",
    "viewmodels/flickr",
    "viewmodels/modal1",
    "viewmodels/myPage",
    "viewmodels/shell",
    "viewmodels/welcome",
    "text!views/detail.html",
    "text!views/flickr.html",
    "text!views/modal1.html",
    "text!views/myPage.html",
    "text!views/shell.html",
    "text!views/welcome.html"
  ],
  "exclude": [],
  "keepBuildDir": true,
  "optimize": "uglify2",
  "out": "C:\\Users\\Tommi Gustafsson\\Documents\\Visual Studio 2012\\Projects\\DurandalTests\\DurandalTest1\\TestApp\\main-built.js",
  "pragmas": {
    "build": true
  },
  "wrap": true,
  "insertRequire": [
    "main"
  ]
}
Deleting old output file.

Tracing dependencies for: durandal/amd/almond-custom

Then, when I check main-built.js, it is empty. Can anyone help me what is the problem? I have several AMD modules in the test project, including Raphael.js AMD modules.

My requirejs configuration looks like this:

requirejs.config({
    paths: {
        'text': 'durandal/amd/text',
        'eve': './raphael-amd/eve.0.3.4',
        'raphael.core': './raphael-amd/raphael.2.1.0.core',
        'raphael.svg': './raphael-amd/raphael.2.1.0.svg',
        'raphael.vml': './raphael-amd/raphael.2.1.0.vml',
        'raphael': './raphael-amd/raphael.2.1.0.amd',
        'tinymce': "../Scripts/tinymce/jquery.tinymce.min"
    }
});

回答1:

In the same amd folder, where optimizer is stored, try running node r.js -o app.build.js. I've seen r.js sometimes choke about some dependencies, which resolves without problem when loading via require.js. For whatever reason the error messages won't show up when using optimizer --verbose. Typically the error message provides enough information to see where this occurs and if you've to update require.contig.paths or a specific define dependency.



标签: durandal