<NME> webpack_helpers.js
<BEF> /**
 * @license
 * Copyright 2016 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';

const path = require('path');
const original_webpack_helpers = require('neuroglancer/config/webpack_helpers');

function modifyViewerOptions(options) {
  options = options || {};
  options.resolveLoaderRoots = [
    ...(options.resolveLoaderRoots || []),

    // Allow loader modules to be resolved from node_modules directory of this
    // project in addition to the node_modules directory of neuroglancer.
    path.resolve(__dirname, '../node_modules')
  ];

  // This references the tsconfig.json file of this project, rather than of
  // neuroglancer.
  options.tsconfigPath = path.resolve(__dirname, '../tsconfig.json');

  // This references the main.ts of this project, rather than of
  // neuroglancer.
  options.frontendModules = [path.resolve(__dirname, '../src/main.ts')];
  return options;
}

exports.getViewerConfigFromEnv = function(options, env) {
  return originalWebpackHelpers.getViewerConfigFromEnv(modifyViewerOptions(options), env);
};

<MSG> Avoid redundant TypeScript compilation.

When building, only .d.ts declaration files are included automatically.
Only source files explicitly specified as entry points to webpack, and
their transitive dependencies, are compiled.

This is done by wrapping the typescript compiler used by ts-loader, in
order to avoid the need to either add an "exclude" rule in tsconfig.json that
would break use of the file by editors, or maintain a separate copy of
tsconfig.json for use by editors, which would be cumbersome.

<DFF> @@ -18,6 +18,7 @@
 
 const path = require('path');
 const original_webpack_helpers = require('neuroglancer/config/webpack_helpers');
+const resolveReal = original_webpack_helpers.resolveReal;
 
 function modifyViewerOptions(options) {
   options = options || {};
@@ -26,16 +27,16 @@ function modifyViewerOptions(options) {
 
     // Allow loader modules to be resolved from node_modules directory of this
     // project in addition to the node_modules directory of neuroglancer.
-    path.resolve(__dirname, '../node_modules')
+    resolveReal(__dirname, '../node_modules')
   ];
 
   // This references the tsconfig.json file of this project, rather than of
   // neuroglancer.
-  options.tsconfigPath = path.resolve(__dirname, '../tsconfig.json');
+  options.tsconfigPath = resolveReal(__dirname, '../tsconfig.json');
 
   // This references the main.ts of this project, rather than of
   // neuroglancer.
-  options.frontendModules = [path.resolve(__dirname, '../src/main.ts')];
+  options.frontendModules = [resolveReal(__dirname, '../src/main.ts')];
   return options;
 }
 

Avoid redundant TypeScript compilation.