Skip to content

Conversation

@compulim
Copy link
Contributor

@compulim compulim commented Sep 21, 2024

Fixes #4847. Fixes #5147. Fixes #5302.

Changelog Entry

Changed

Fixed

  • Fixes #5147. Added punycode to our dependencies as markdown-it requires it but did not have it in their package.json, in PR #5301, by @compulim

Description

Developers who fork and build Web Chat, will need to read CONTRIBUTING.md again for updated/simplified instructions.

Web Chat is on lerna@6. Starting from lerna@7, they are moving to npm workspaces.

We are also moving to npm workspaces. As we don't use many tools of lerna, we no longer install lerna.

Key differences between lerna@6 and npm workspaces:

  • npm workspaces comes with Node.js ecosystem, no additional install
  • Default install strategy in npm is hoisted, we are using non-hoisted for lerna@6
  • Many npm CLI commands recognize package in workspaces, we no longer need tools like lerna or prebump/postbump
  • Single package-lock.json at the project root
  • No lerna exec equivalent in npm
  • npm don't build dependency graph automatically, we need to specify build order ourselves
  • npm works with Windows on ARM
    • lerna@6 depends on nx, which depends on a version of @parcel/watcher that does not offer binaries for Windows on ARM

Design

Moving away from lerna

npm introduced workspaces feature which overlaps with lerna.

We are moving to NPM workspaces feature for a standard approach for maintaining mono repo.

By default, npm workspaces hoist packages (most packages at root /node_modules). Some changes will need to be made in Web Chat for hoisting.

For samples, we are maintaining another npm workspaces under /samples folder.

Moving away from p-defer

When running, it's complaining about "dynamic import" of p-defer. We are moving away from p-defer into Promise.withResolvers via core-js-pure.

We still need core-js-pure ponyfill because Chrome and Node.js in our test infrastructure does not natively support Promise.withResolvers yet.

Specific Changes

  • Updated CONTRIBUTING.md with steps for npm workspaces
    • Now requires npm run build before npm start
  • Updated GitHub workflows
    • PR validation: Use npm clean-install --strict-peer-deps
    • PR validation: Validate samples should built properly
  • Removed prebump and postbump scripts as npm recognizes local peer dependencies automatically
    • bump script will continue skip bumping local peer dependencies
  • Removed auditfix scripts as we can now run npm audit fix --workspaces at root level
  • Prefixed our fork of cldr-data and cldr-data-downloader to prevent name collision
  • Updated bundler configuration to point to correct /node_modules location as all packages are now hoisted
  • Simplified scripts that use concurrently with --prefix-colors "auto" and run as npm:start:*
  • Added punycode to dependencies as it is required by markdown-it by missing in their production dependencies
  • cldr-data: Moved install script to build script as install script no longer run automatically
  • fluent-bundle: Use isomorphic-react to load a common version of React for @fluentui/* and Web Chat
  • Docker: Running npm install instead of npm clean-install because we no longer have a local package-lock.json for the test/harness package
  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

@compulim compulim changed the title [WIP] Move to npm workspaces Move to npm workspaces Sep 21, 2024
@compulim compulim marked this pull request as ready for review September 21, 2024 18:10
@compulim compulim merged commit 9ba786e into microsoft:main Sep 23, 2024
@compulim compulim deleted the feat-npm-workspaces branch September 23, 2024 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move from p-defer to Promise.withResolvers markdown-it is missing deps punycode Migrate from lerna@6 to lerna@7 or pure NPM workspaces

2 participants