Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

@alan-agius4 alan-agius4 Oct 12, 2018 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paths here are not FS, they are normalized for virtual host

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');
}