From ab5c6c162d168cddd24a06361292e8bd81f265b7 Mon Sep 17 00:00:00 2001 From: Mohataseem Khan Date: Sat, 13 Dec 2025 21:21:21 +0530 Subject: [PATCH] fixs: update import syntax and error handling in publish script correcting the JSON import syntax for ESM. ensuring cleanedPkg.imports exists before assignment. improving spawnSync error handling to exit on failure. Signed-off-by: Mohataseem Khan --- packages/ui-components/scripts/publish.mjs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/ui-components/scripts/publish.mjs b/packages/ui-components/scripts/publish.mjs index 7834b7126be0f..5fa4a492be9b3 100644 --- a/packages/ui-components/scripts/publish.mjs +++ b/packages/ui-components/scripts/publish.mjs @@ -1,7 +1,7 @@ import { spawnSync } from 'node:child_process'; import { writeFile, copyFile } from 'node:fs/promises'; -import pkg from '../package.json' with { type: 'json' }; +import pkg from '../package.json' assert { type: 'json' }; // Strip the devDependencies, since they aren't needed for publish // Strip the exports, since we don't want to reference './src' @@ -9,6 +9,8 @@ import pkg from '../package.json' with { type: 'json' }; const { devDependencies, exports, ...cleanedPkg } = pkg; // Change `#ui` to `./` from `./src`, since we are publishing // from the same directory as the source code (rather, the compiled code). +// to ensure imports exists +cleanedPkg.imports = cleanedPkg.imports || {}; cleanedPkg.imports['#ui/*'] = ['./*']; await writeFile( @@ -25,8 +27,8 @@ const { status, error } = spawnSync('pnpm', ['publish', '--no-git-checks'], { stdio: 'inherit', }); -if (error) { - throw error; -} + +if (error) throw error; +if (status !== 0) process.exit(status); process.exitCode = status;