Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@angular-devkit/build-angular): ensure directories are properly ignored in esbuild builder #24974

Merged
merged 1 commit into from Apr 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -36,17 +36,18 @@ export async function normalizeOptions(
) {
const workspaceRoot = context.workspaceRoot;
const projectMetadata = await context.getProjectMetadata(projectName);
const projectRoot = path.join(workspaceRoot, (projectMetadata.root as string | undefined) ?? '');
const projectSourceRoot = path.join(
workspaceRoot,
(projectMetadata.sourceRoot as string | undefined) ?? 'src',
const projectRoot = normalizeDirectoryPath(
path.join(workspaceRoot, (projectMetadata.root as string | undefined) ?? ''),
);
const projectSourceRoot = normalizeDirectoryPath(
path.join(workspaceRoot, (projectMetadata.sourceRoot as string | undefined) ?? 'src'),
);

const cacheOptions = normalizeCacheOptions(projectMetadata, workspaceRoot);

const mainEntryPoint = path.join(workspaceRoot, options.main);
const tsconfig = path.join(workspaceRoot, options.tsConfig);
const outputPath = path.join(workspaceRoot, options.outputPath);
const outputPath = normalizeDirectoryPath(path.join(workspaceRoot, options.outputPath));
const optimizationOptions = normalizeOptimization(options.optimization);
const sourcemapOptions = normalizeSourceMaps(options.sourceMap ?? false);
const assets = options.assets?.length
Expand Down Expand Up @@ -222,3 +223,18 @@ function findTailwindConfigurationFile(

return undefined;
}

/**
* Normalize a directory path string.
* Currently only removes a trailing slash if present.
* @param path A path string.
* @returns A normalized path string.
*/
function normalizeDirectoryPath(path: string): string {
const last = path[path.length - 1];
if (last === '/' || last === '\\') {
return path.slice(0, -1);
}

return path;
}