Skip to content

Commit faf650c

Browse files
committed
refactor(@angular-devkit/build-angular): remove legacy server bundle guess logic
Closes #16353
1 parent affaabe commit faf650c

File tree

1 file changed

+13
-14
lines changed
  • packages/angular_devkit/build_angular/src/app-shell

1 file changed

+13
-14
lines changed

packages/angular_devkit/build_angular/src/app-shell/index.ts

+13-14
Original file line numberDiff line numberDiff line change
@@ -116,24 +116,23 @@ async function _getServerModuleBundlePath(
116116
) {
117117
if (options.appModuleBundle) {
118118
return path.join(context.workspaceRoot, options.appModuleBundle);
119-
} else {
120-
const { baseOutputPath = '' } = serverResult;
121-
const outputPath = path.join(baseOutputPath, browserLocaleDirectory);
119+
}
122120

123-
if (!fs.existsSync(outputPath)) {
124-
throw new Error(`Could not find server output directory: ${outputPath}.`);
125-
}
121+
const { baseOutputPath = '' } = serverResult;
122+
const outputPath = path.join(baseOutputPath, browserLocaleDirectory);
126123

127-
const files = fs.readdirSync(outputPath, 'utf8');
128-
const re = /^main\.(?:[a-zA-Z0-9]{20}\.)?(?:bundle\.)?js$/;
129-
const maybeMain = files.filter(x => re.test(x))[0];
124+
if (!fs.existsSync(outputPath)) {
125+
throw new Error(`Could not find server output directory: ${outputPath}.`);
126+
}
130127

131-
if (!maybeMain) {
132-
throw new Error('Could not find the main bundle.');
133-
} else {
134-
return path.join(outputPath, maybeMain);
135-
}
128+
const re = /^main\.(?:[a-zA-Z0-9]{20}\.)?js$/;
129+
const maybeMain = fs.readdirSync(outputPath).find(x => re.test(x));
130+
131+
if (!maybeMain) {
132+
throw new Error('Could not find the main bundle.');
136133
}
134+
135+
return path.join(outputPath, maybeMain);
137136
}
138137

139138
async function _appShellBuilder(

0 commit comments

Comments
 (0)