From abe009f4eab677f7a1cf99c502903f860cdd419b Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Fri, 26 Sep 2025 12:52:17 +0000 Subject: [PATCH] feat: move package types under `/types` All package type have been moved into `/types` --- 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, 8 insertions(+), 14 deletions(-) diff --git a/src/ng_package/angular_package_format.bzl b/src/ng_package/angular_package_format.bzl index 1145d04..53d8c97 100644 --- a/src/ng_package/angular_package_format.bzl +++ b/src/ng_package/angular_package_format.bzl @@ -259,8 +259,7 @@ def _angular_package_format_impl(ctx): module_name = module_name, es2022_entry_point = es2022_entry_point, fesm2022_file = "fesm2022/%s.mjs" % 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, + dts_bundle_relative_path = "types/%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 b8f1b30..573fcb6 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,16 +161,13 @@ 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) => - // TODO(devversion): Put all types under `/types/` folder. Breaking change in v20. - copyFile(path.join(metadata.dtsBundlesOut.path, f), f), - ); + dtsFiles.forEach(f => copyFile(path.join(metadata.dtsBundlesOut.path, f), path.join('types', f))); for (const file of staticFiles) { // We copy all files into the package output while preserving the sub-path from @@ -326,10 +323,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. @@ -348,9 +345,7 @@ 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 ad40a55..214630d 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$/, '') + ? info.dtsBundleRelativePath.replace(/\.d\.ts$/, '').replace('types/', '') : info.fesm2022RelativePath.replace(/\.mjs$/, '').replace('fesm2022/', ''); input[chunkName] = entryFile;