Skip to content

Conversation

@iOvergaard
Copy link
Contributor

@iOvergaard iOvergaard commented May 26, 2025

Description

This hoists sub-dependencies found in workspaces to the main distributed package.json file, so that consumers can install all peer dependencies.

Also added some missing package.json and vite.config.ts files, that was found when testing the build.

Fixes #19407

How to test

  1. You need to pack by running npm run build:for:npm and then npm pack
  2. Move the tgz file somewhere else and create a project
  3. Test with the following snippet
import { UmbId } from '@umbraco-cms/backoffice/id';

const id = UmbId.new();

console.log('Generated ID:', id.toString());

It should just log the generated ID and not complain about missing imports.

Copilot AI review requested due to automatic review settings May 26, 2025 07:38
@iOvergaard iOvergaard requested a review from leekelleher May 26, 2025 07:38
@iOvergaard iOvergaard enabled auto-merge (squash) May 26, 2025 07:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the distribution packaging script to correct workspace paths in the generated package.json file by renaming ./src entries to ./dist-cms, ensuring peer dependencies install correctly.

  • Added mapping logic in cleanse-pkg.js to update workspace paths.
  • Renamed workspace path prefixes from ./src to ./dist-cms.
Comments suppressed due to low confidence (2)

src/Umbraco.Web.UI.Client/devops/publish/cleanse-pkg.js:16

  • [nitpick] Add a unit test for cleanse-pkg.js that verifies workspace paths are correctly transformed from './src' to './dist-cms' under various scenarios.
packageJson.workspaces = packageJson.workspaces.map((workspace) => {

src/Umbraco.Web.UI.Client/devops/publish/cleanse-pkg.js:16

  • Add a guard to ensure packageJson.workspaces exists and is an array before calling .map, to prevent runtime errors if workspaces is missing or not an array.
packageJson.workspaces = packageJson.workspaces.map((workspace) => {

@iOvergaard iOvergaard requested a review from madsrasmussen May 26, 2025 07:50
@iOvergaard iOvergaard changed the title V16-RC: Workspaces do not have correct path in distributed package.json file V16-RC: Sub-dependencies from workspaces are missing in the main package.json file May 26, 2025
@iOvergaard iOvergaard requested review from Copilot and nielslyngsoe and removed request for leekelleher and madsrasmussen May 26, 2025 09:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures all sub-dependencies from workspaces are hoisted into the main distributed package.json, and adds missing package manifest and build config files for several workspace packages.

  • Added package.json for translation, settings, and segment workspaces.
  • Added vite.config.ts for the settings workspace.
  • Extended the cleanse-pkg.js script to hoist workspace dependencies to peerDependencies and strip the workspaces field.

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/.../translation/package.json Adds missing package.json for the translation workspace.
src/.../settings/vite.config.ts Adds Vite build configuration for the settings workspace.
src/.../settings/package.json Adds missing package.json for the settings workspace.
src/.../segment/package.json Adds missing package.json for the segment workspace.
src/Umbraco.Web.UI.Client/devops/publish/cleanse-pkg.js Updates publish script to hoist each workspace’s dependencies into the root peerDependencies.
Files not reviewed (1)
  • src/Umbraco.Web.UI.Client/package-lock.json: Language not supported

@iOvergaard iOvergaard added release/16.0.0 category/dx Developer experience labels May 26, 2025
@iOvergaard iOvergaard changed the title V16-RC: Sub-dependencies from workspaces are missing in the main package.json file V16: Sub-dependencies from workspaces are missing in the main package.json file May 26, 2025
@iOvergaard iOvergaard merged commit 290334b into release/16.0 May 26, 2025
22 checks passed
@iOvergaard iOvergaard deleted the v16/bugfix/dist-cms-workspaces-path branch May 26, 2025 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants