From d443f9ebba6b496c90b7fc446d11f5f02c175d22 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 4 Feb 2023 17:59:02 +0100 Subject: [PATCH] cli: always make package.json available in exports in published packages Signed-off-by: Patrik Oldsberg --- packages/cli/src/lib/packager/productionPack.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/lib/packager/productionPack.ts b/packages/cli/src/lib/packager/productionPack.ts index 3a74b68257..b91112216a 100644 --- a/packages/cli/src/lib/packager/productionPack.ts +++ b/packages/cli/src/lib/packager/productionPack.ts @@ -128,7 +128,7 @@ export async function revertProductionPack(packageDir: string) { // Remove any extra entrypoint backwards compatibility directories const entryPoints = readEntryPoints(pkg); for (const entryPoint of entryPoints) { - if (entryPoint.mount !== '.') { + if (entryPoint.mount !== '.' && SCRIPT_EXTS.includes(entryPoint.ext)) { await fs.remove(resolvePath(packageDir, entryPoint.name)); } } @@ -244,7 +244,11 @@ async function prepareExportsEntryPoints( } } - pkg.exports = outputExports; + if (pkg.exports) { + pkg.exports = outputExports; + // We treat package.json as a fixed export that is always available in the published package + pkg.exports['./package.json'] = './package.json'; + } if (compatibilityWriters.length > 0) { return async (targetDir: string) => {