diff --git a/packages/@ngtools/webpack/src/entry_resolver.ts b/packages/@ngtools/webpack/src/entry_resolver.ts index 32430d7e6961..c8ba5a7d786e 100644 --- a/packages/@ngtools/webpack/src/entry_resolver.ts +++ b/packages/@ngtools/webpack/src/entry_resolver.ts @@ -97,6 +97,8 @@ function _symbolImportLookup(refactor: TypeScriptFileRefactor, (decl.moduleSpecifier as ts.StringLiteral).text, refactor.fileName, program.getCompilerOptions(), host); if (!resolvedModule.resolvedModule || !resolvedModule.resolvedModule.resolvedFileName) { + throw new Error('Could not resolve module name. Is ' + + (decl.moduleSpecifier as ts.StringLiteral).text + ' installed?'); return null; } @@ -134,6 +136,7 @@ export function resolveEntryModuleFromMain(mainPath: string, .map(node => node as ts.CallExpression) .filter(call => { const access = call.expression as ts.PropertyAccessExpression; + return access.kind == ts.SyntaxKind.PropertyAccessExpression && access.name.kind == ts.SyntaxKind.Identifier && (access.name.text == 'bootstrapModule' @@ -145,7 +148,7 @@ export function resolveEntryModuleFromMain(mainPath: string, if (bootstrap.length != 1) { throw new Error('Tried to find bootstrap code, but could not. Specify either ' + 'statically analyzable bootstrap code or pass in an entryModule ' - + 'to the plugins options.'); + + 'to the plugins options. I has ' + bootstrap.length + ' bootstraps muahahaha'); } const bootstrapSymbolName = bootstrap[0].text; const module = _symbolImportLookup(source, bootstrapSymbolName, host, program); @@ -156,5 +159,5 @@ export function resolveEntryModuleFromMain(mainPath: string, // shrug... something bad happened and we couldn't find the import statement. throw new Error('Tried to find bootstrap code, but could not. Specify either ' + 'statically analyzable bootstrap code or pass in an entryModule ' - + 'to the plugins options.'); + + 'to the plugins options. fell out'); } diff --git a/packages/angular-cli/lib/config/schema.json b/packages/angular-cli/lib/config/schema.json index c8626d1aac1d..6bb54cb5b528 100644 --- a/packages/angular-cli/lib/config/schema.json +++ b/packages/angular-cli/lib/config/schema.json @@ -65,6 +65,9 @@ "prefix": { "type": "string" }, + "app": { + "type": "string" + }, "mobile": { "type": "boolean" }, diff --git a/packages/angular-cli/utilities/dynamic-path-parser.js b/packages/angular-cli/utilities/dynamic-path-parser.js index e362da26f864..8d5444d34fec 100644 --- a/packages/angular-cli/utilities/dynamic-path-parser.js +++ b/packages/angular-cli/utilities/dynamic-path-parser.js @@ -5,19 +5,21 @@ var fs = require('fs'); module.exports = function dynamicPathParser(project, entityName) { var projectRoot = project.root; var sourceDir = project.ngConfig.apps[0].root; - var appRoot = path.join(sourceDir, 'app'); + + var appPart = project.ngConfig.apps[0].app || 'app' + var appRoot = path.join(sourceDir, appPart); var cwd = process.env.PWD; var rootPath = path.join(projectRoot, appRoot); var outputPath = path.join(rootPath, entityName); - + if (entityName.indexOf(path.sep) === 0) { outputPath = path.join(rootPath, entityName.substr(1)); } else if (cwd.indexOf(rootPath) >= 0) { outputPath = path.join(cwd, entityName); } - + if (!fs.existsSync(outputPath)) { // Verify the path exists on disk. var parsedOutputPath = path.parse(outputPath); @@ -33,12 +35,12 @@ module.exports = function dynamicPathParser(project, entityName) { } else if (fs.existsSync(withPlus)) { return withPlus; } - + throw `Invalid path: "${withoutPlus}"" is not a valid path.` }, parsedOutputPath.root); outputPath = path.join(newPath, parsedOutputPath.name); } - + if (outputPath.indexOf(rootPath) < 0) { throw `Invalid path: "${entityName}" cannot be ` + `above the "${appRoot}" directory`; @@ -47,7 +49,7 @@ module.exports = function dynamicPathParser(project, entityName) { var adjustedPath = outputPath.replace(projectRoot, ''); var parsedPath = path.parse(adjustedPath); - + if (parsedPath.dir.indexOf(path.sep) === 0) { parsedPath.dir = parsedPath.dir.substr(1); } diff --git a/packages/angular-cli/utilities/find-parent-module.ts b/packages/angular-cli/utilities/find-parent-module.ts index 7a2273e19068..d638a26a6707 100644 --- a/packages/angular-cli/utilities/find-parent-module.ts +++ b/packages/angular-cli/utilities/find-parent-module.ts @@ -3,10 +3,11 @@ import * as path from 'path'; const SilentError = require('silent-error'); export default function findParentModule(project: any, currentDir: string): string { - const sourceRoot = path.join(project.root, project.ngConfig.apps[0].root, 'app'); + const appPart = project.ngConfig.apps[0].app ? project.ngConfig.apps[0].app : 'app'; + const sourceRoot = path.join(project.root, project.ngConfig.apps[0].root, appPart); // trim currentDir - currentDir = currentDir.replace(path.join(project.ngConfig.apps[0].root, 'app'), ''); + currentDir = currentDir.replace(path.join(project.ngConfig.apps[0].root, appPart), ''); let pathToCheck = path.join(sourceRoot, currentDir);