From 81d400d526556f39246832cce48f2dac8ce9a609 Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Fri, 26 Sep 2025 19:21:11 +0200 Subject: [PATCH] Revert "feat: move package types under `/types`" This reverts commit ccc29858902743325700b182992789e3b346658b. --- src/ng_package/angular_package_format.bzl | 3 ++- src/ng_package/packager/index.ts | 17 +++++++++++------ src/ng_package/rollup/rollup.config.js | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/ng_package/angular_package_format.bzl b/src/ng_package/angular_package_format.bzl index 53d8c97..1145d04 100644 --- a/src/ng_package/angular_package_format.bzl +++ b/src/ng_package/angular_package_format.bzl @@ -259,7 +259,8 @@ def _angular_package_format_impl(ctx): module_name = module_name, es2022_entry_point = es2022_entry_point, fesm2022_file = "fesm2022/%s.mjs" % bundle_name_base, - dts_bundle_relative_path = "types/%s.d.ts" % dts_bundle_name_base, + # TODO(devversion): Put all types under `/types/` folder. Breaking change in v20. + dts_bundle_relative_path = "%s.d.ts" % dts_bundle_name_base, typings_entry_point = typings_entry_point, # TODO: Determine if we can just remove this as we are always "guessing" now guessed_paths = True, diff --git a/src/ng_package/packager/index.ts b/src/ng_package/packager/index.ts index 573fcb6..b8f1b30 100644 --- a/src/ng_package/packager/index.ts +++ b/src/ng_package/packager/index.ts @@ -150,7 +150,7 @@ function main(args: string[]): void { return getEntryPointSubpath(moduleName) !== ''; } - const crossEntryPointFailures = esm2022.flatMap(file => + const crossEntryPointFailures = esm2022.flatMap((file) => analyzeFileAndEnsureNoCrossImports(file, metadata), ); @@ -161,13 +161,16 @@ function main(args: string[]): void { // Copy all FESM files (and their potential shared chunks) into the package output. const fesmFiles = globSync('**/*', {cwd: metadata.fesmBundlesOut.path}); - fesmFiles.forEach(f => + fesmFiles.forEach((f) => copyFile(path.join(metadata.fesmBundlesOut.path, f), path.join('fesm2022', f)), ); // Copy all dts files (and their potential shared chunks) into the package output. const dtsFiles = globSync('**/*', {cwd: metadata.dtsBundlesOut.path}); - dtsFiles.forEach(f => copyFile(path.join(metadata.dtsBundlesOut.path, f), path.join('types', f))); + dtsFiles.forEach((f) => + // TODO(devversion): Put all types under `/types/` folder. Breaking change in v20. + copyFile(path.join(metadata.dtsBundlesOut.path, f), f), + ); for (const file of staticFiles) { // We copy all files into the package output while preserving the sub-path from @@ -323,10 +326,10 @@ function main(args: string[]): void { const sideEffects = packageJson.sideEffects as undefined | false | string[]; const neededSideEffects = sideEffectEntryPoints.map( - entryPointModule => `./${metadata.entryPoints[entryPointModule].fesm2022RelativePath}`, + (entryPointModule) => `./${metadata.entryPoints[entryPointModule].fesm2022RelativePath}`, ); const missingSideEffects = neededSideEffects.filter( - p => + (p) => // It's missing, if the whole package is marked as having no side effects. sideEffects === false || // Alternatively, it's missing if the explicit list doesn't contain the pattern. @@ -345,7 +348,9 @@ function main(args: string[]): void { // of the `ng_package` known entry points. const unexpectedExtra = sideEffects !== false - ? (sideEffects ?? []).filter(p => p.includes('fesm2022') && !neededSideEffects.includes(p)) + ? (sideEffects ?? []).filter( + (p) => p.includes('fesm2022') && !neededSideEffects.includes(p), + ) : []; if (unexpectedExtra.length > 0) { throw Error( diff --git a/src/ng_package/rollup/rollup.config.js b/src/ng_package/rollup/rollup.config.js index 214630d..ad40a55 100644 --- a/src/ng_package/rollup/rollup.config.js +++ b/src/ng_package/rollup/rollup.config.js @@ -165,7 +165,7 @@ const input = {}; for (const info of Object.values(entrypointMetadata)) { const entryFile = dtsMode ? info.typingsEntryPoint.path : info.index.path; const chunkName = dtsMode - ? info.dtsBundleRelativePath.replace(/\.d\.ts$/, '').replace('types/', '') + ? info.dtsBundleRelativePath.replace(/\.d\.ts$/, '') : info.fesm2022RelativePath.replace(/\.mjs$/, '').replace('fesm2022/', ''); input[chunkName] = entryFile;