Skip to content

Commit ef03084

Browse files
committed
feat: move package types under /types
All package type have been moved into `/types`
1 parent 2c348bf commit ef03084

3 files changed

Lines changed: 8 additions & 15 deletions

File tree

src/ng_package/angular_package_format.bzl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,14 @@ def _angular_package_format_impl(ctx):
251251
] if _ != ""])
252252

253253
bundle_name_base = primary_bundle_name if is_primary_entry_point else entry_point
254-
dts_bundle_name_base = "index" if is_primary_entry_point else "%s/index" % entry_point
255254

256255
# Store the collected entry point in a list of all entry-points. This
257256
# can be later passed to the packager as a manifest.
258257
collected_entry_points.append(struct(
259258
module_name = module_name,
260259
es2022_entry_point = es2022_entry_point,
261260
fesm2022_file = "fesm2022/%s.mjs" % bundle_name_base,
262-
# TODO(devversion): Put all types under `/types/` folder. Breaking change in v20.
263-
dts_bundle_relative_path = "%s.d.ts" % dts_bundle_name_base,
261+
dts_bundle_relative_path = "types/%s.d.ts" % bundle_name_base,
264262
typings_entry_point = typings_entry_point,
265263
# TODO: Determine if we can just remove this as we are always "guessing" now
266264
guessed_paths = True,

src/ng_package/packager/index.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function main(args: string[]): void {
150150
return getEntryPointSubpath(moduleName) !== '';
151151
}
152152

153-
const crossEntryPointFailures = esm2022.flatMap((file) =>
153+
const crossEntryPointFailures = esm2022.flatMap(file =>
154154
analyzeFileAndEnsureNoCrossImports(file, metadata),
155155
);
156156

@@ -161,16 +161,13 @@ function main(args: string[]): void {
161161

162162
// Copy all FESM files (and their potential shared chunks) into the package output.
163163
const fesmFiles = globSync('**/*', {cwd: metadata.fesmBundlesOut.path});
164-
fesmFiles.forEach((f) =>
164+
fesmFiles.forEach(f =>
165165
copyFile(path.join(metadata.fesmBundlesOut.path, f), path.join('fesm2022', f)),
166166
);
167167

168168
// Copy all dts files (and their potential shared chunks) into the package output.
169169
const dtsFiles = globSync('**/*', {cwd: metadata.dtsBundlesOut.path});
170-
dtsFiles.forEach((f) =>
171-
// TODO(devversion): Put all types under `/types/` folder. Breaking change in v20.
172-
copyFile(path.join(metadata.dtsBundlesOut.path, f), f),
173-
);
170+
dtsFiles.forEach(f => copyFile(path.join(metadata.dtsBundlesOut.path, f), path.join('types', f)));
174171

175172
for (const file of staticFiles) {
176173
// We copy all files into the package output while preserving the sub-path from
@@ -326,10 +323,10 @@ function main(args: string[]): void {
326323

327324
const sideEffects = packageJson.sideEffects as undefined | false | string[];
328325
const neededSideEffects = sideEffectEntryPoints.map(
329-
(entryPointModule) => `./${metadata.entryPoints[entryPointModule].fesm2022RelativePath}`,
326+
entryPointModule => `./${metadata.entryPoints[entryPointModule].fesm2022RelativePath}`,
330327
);
331328
const missingSideEffects = neededSideEffects.filter(
332-
(p) =>
329+
p =>
333330
// It's missing, if the whole package is marked as having no side effects.
334331
sideEffects === false ||
335332
// Alternatively, it's missing if the explicit list doesn't contain the pattern.
@@ -348,9 +345,7 @@ function main(args: string[]): void {
348345
// of the `ng_package` known entry points.
349346
const unexpectedExtra =
350347
sideEffects !== false
351-
? (sideEffects ?? []).filter(
352-
(p) => p.includes('fesm2022') && !neededSideEffects.includes(p),
353-
)
348+
? (sideEffects ?? []).filter(p => p.includes('fesm2022') && !neededSideEffects.includes(p))
354349
: [];
355350
if (unexpectedExtra.length > 0) {
356351
throw Error(

src/ng_package/rollup/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ const input = {};
165165
for (const info of Object.values(entrypointMetadata)) {
166166
const entryFile = dtsMode ? info.typingsEntryPoint.path : info.index.path;
167167
const chunkName = dtsMode
168-
? info.dtsBundleRelativePath.replace(/\.d\.ts$/, '')
168+
? info.dtsBundleRelativePath.replace(/\.d\.ts$/, '').replace('types/', '')
169169
: info.fesm2022RelativePath.replace(/\.mjs$/, '').replace('fesm2022/', '');
170170

171171
input[chunkName] = entryFile;

0 commit comments

Comments
 (0)