Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d0bea7a

Browse files
alan-agius4alexeagle
authored andcommittedOct 16, 2018
fix(@ngtools/webpack): barrel files fail on windows
Fixes #12035
1 parent 915994d commit d0bea7a

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed
 

‎packages/ngtools/webpack/src/entry_resolver.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import * as fs from 'fs';
9-
import { join } from 'path';
8+
9+
import { Path, join } from '@angular-devkit/core';
1010
import * as ts from 'typescript';
1111
import { TypeScriptFileRefactor } from './refactor';
1212

@@ -54,9 +54,10 @@ function _recursiveSymbolExportLookup(refactor: TypeScriptFileRefactor,
5454
for (const specifier of binding.elements) {
5555
if (specifier.name.text == symbolName) {
5656
// If it's a directory, load its index and recursively lookup.
57-
if (fs.statSync(module).isDirectory()) {
58-
const indexModule = join(module, 'index.ts');
59-
if (fs.existsSync(indexModule)) {
57+
// If it's a file it will return false
58+
if (host.directoryExists && host.directoryExists(module)) {
59+
const indexModule = join(module as Path, 'index.ts');
60+
if (host.fileExists(indexModule)) {
6061
const indexRefactor = new TypeScriptFileRefactor(indexModule, host, program);
6162
const maybeModule = _recursiveSymbolExportLookup(
6263
indexRefactor, symbolName, host, program);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { replaceInFile, writeFile } from '../../utils/fs';
2+
import { ng } from '../../utils/process';
3+
4+
export default async function() {
5+
await writeFile('src/app/index.ts', `export { AppModule } from './app.module';`);
6+
await replaceInFile('src/main.ts', './app/app.module', './app');
7+
await ng('build');
8+
}

0 commit comments

Comments
 (0)
Please sign in to comment.