Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ng_package/angular_package_format.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 11 additions & 6 deletions src/ng_package/packager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);

Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/ng_package/rollup/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down