Question

I want to merge files using the Require Optimizer, which I'm not able to do because of an error:

Here's the folder structure:

-build
  -r.js
  -build.js
-server
  -app.js
  -src
    -clientConnectivity
      -Upload.js

Here's build.js

({
    baseUrl: "..",
    paths: {
        uploadManager: "./server/src/clientConnectivity/Upload"
    },
    include: uploadManager,
    name: "server/app",
    out: "main-built.js"
})

Here's the command passed and the error received:

C:\Users\Anjan\WebstormProjects\RequireOptimizerTest\build>node r.js -o build.js
Error: Error: Build file C:/Users/Anjan/WebstormProjects/RequireOptimizerTest/build/build.js is malformed: ReferenceError: uploadManager is not defined
    at Function.build.createConfig (C:\Users\Anjan\WebstormProjects\RequireOptimizerTest\build\r.js:26541:23)

Here are the imports in app.js. I expect the Require Optimizer to read these imports in app.js and accordingly merge the called files.

import express = require('express');
import http = require('http');
import path = require('path');
import fs = require('fs');
import uploadModule = require('./src/clientConnectivity/Upload');
Was it helpful?

Solution

Here is a fixed example:

({
    baseUrl: "..",
    name: "server/app",
    out: "main-built.js",
    mainConfigFile : 'path/to/main.js',
    findNestedDependencies: true
})
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top