Skip to content

Commit

Permalink
fix(@ngtools/webpack): barrel files fail on windows
Browse files Browse the repository at this point in the history
Fixes #12035
  • Loading branch information
alan-agius4 authored and alexeagle committed Oct 16, 2018
1 parent 5063f8d commit 16d5eac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/ngtools/webpack/src/entry_resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import * as fs from 'fs';
import { join } from 'path';

import { Path, join } from '@angular-devkit/core';
import * as ts from 'typescript';
import { TypeScriptFileRefactor } from './refactor';

Expand Down Expand Up @@ -54,9 +54,10 @@ function _recursiveSymbolExportLookup(refactor: TypeScriptFileRefactor,
for (const specifier of binding.elements) {
if (specifier.name.text == symbolName) {
// If it's a directory, load its index and recursively lookup.
if (fs.statSync(module).isDirectory()) {
const indexModule = join(module, 'index.ts');
if (fs.existsSync(indexModule)) {
// If it's a file it will return false
if (host.directoryExists && host.directoryExists(module)) {
const indexModule = join(module as Path, 'index.ts');
if (host.fileExists(indexModule)) {
const indexRefactor = new TypeScriptFileRefactor(indexModule, host, program);
const maybeModule = _recursiveSymbolExportLookup(
indexRefactor, symbolName, host, program);
Expand Down
8 changes: 8 additions & 0 deletions tests/legacy-cli/e2e/tests/build/barrel-file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { replaceInFile, writeFile } from '../../utils/fs';
import { ng } from '../../utils/process';

export default async function() {
await writeFile('src/app/index.ts', `export { AppModule } from './app.module';`);
await replaceInFile('src/main.ts', './app/app.module', './app');
await ng('build');
}

0 comments on commit 16d5eac

Please sign in to comment.