Skip to content

Normalize the output folders to lib-commonjs, lib-dts, and lib-esm for all projects in this repo.#5628

Merged
iclanton merged 43 commits intomicrosoft:mainfrom
iclanton:normalize-build-output
Feb 18, 2026
Merged

Normalize the output folders to lib-commonjs, lib-dts, and lib-esm for all projects in this repo.#5628
iclanton merged 43 commits intomicrosoft:mainfrom
iclanton:normalize-build-output

Conversation

@iclanton
Copy link
Member

@iclanton iclanton commented Feb 17, 2026

Summary

Standardize package output folder naming across all Rush Stack packages to a consistent convention:

  • lib-commonjs/ — CommonJS JavaScript
  • lib-esm/ — ESM JavaScript
  • lib-dts/ — TypeScript declarations

Previously, many packages used lib/ as a catch-all output folder. This change moves to explicit, descriptively-named folders while maintaining backward compatibility: imports to lib/ still resolve correctly via the exports and typesVersions fields in package.json.

Details

Package metadata updates (~65 published packages):

  • Added exports field with conditional import/require/types mappings
  • Added typesVersions to redirect lib/* to lib-dts/* for older TypeScript versions
  • Updated main, module, and types fields to point to new output locations
  • Updated api-extractor.json mainEntryPointFilePath to reference lib-dts/ or lib-commonjs/ as appropriate

Rig configuration updates (local-node-rig, local-web-rig):

  • tsconfig-base.json: Set outDir and declarationDir to the new folder names
  • config/typescript.json: Added additionalModuleKindsToEmit for dual CJS/ESM output

Special handling for rush-lib and rush-sdk:

  • These packages use intermediate build folders (lib-intermediate-commonjs, lib-intermediate-esm) that are processed by API Extractor before producing the final lib-commonjs/ output
  • They do not ship lib-esm/ — only CommonJS and declarations are published

Build test and tutorial fixes:

  • Updated webpack/rspack configs to reference lib-esm/ or lib-commonjs/ entry points
  • Updated heft scriptPath references from lib/ to lib-commonjs/
  • Updated heft-plugin.json entry points from lib/ to lib-commonjs/
  • Updated storybook story globs from lib/ to lib-esm/
  • Fixed sass plugin cssOutputFolders to target lib-esm/ instead of lib/
  • Fixed run-scenarios-helpers to use lib-dts/ for declaration entry points
  • Added additionalModuleKindsToEmit: [] overrides for eslint/localization test projects that set module: "esnext" (to avoid duplicate module kind conflicts with the rig)
  • Fixed eslint-patch exports for the eslint-bulk-suppressions subdirectory entry point

Clean-up:

  • Added old lib/ and new output folders to cleanFiles in heft.json configs so that developers' machines are cleaned of stale output from before this change
  • Updated .prettierignore to include lib-esm/

Backward compatibility: Existing deep imports to <package>/lib/<module> continue to work via the exports wildcard mapping ./lib/*, which redirects to the appropriate output folder. The typesVersions field provides the same mapping for older TypeScript versions that don't support exports.

How it was tested

Ran rush build across all 187 projects and verified all pass (excluding transient Windows filesystem lock errors unrelated to this change). Test suite execution pending final verification.

Impacted documentation

iclanton and others added 27 commits February 17, 2026 13:43
…ugins to support ESM and CommonJS modules

- Updated main entry points to use lib-commonjs and lib-esm for better module resolution.
- Added exports field to package.json for improved compatibility with module systems.
- Adjusted mainEntryPointFilePath in api-extractor.json to point to lib-dts for type definitions.
- Enhanced typesVersions to support lib-dts for type definitions across various plugins.
…rush plugins to support ESM and CommonJS modules
- Consolidate "typings" to "types" for consistency
- Add leading "./" to "main", "types", and "module" paths
- Remove incorrect "main", "module", and "." exports from
  projects that don't have index entrypoints

Co-Authored-By: Claude <noreply@anthropic.com>
…rush plugins to support ESM and CommonJS modules
…rush plugins to support ESM and CommonJS modules
…rush plugins to support ESM and CommonJS modules
…rush plugins to support ESM and CommonJS modules
…rush plugins to support ESM and CommonJS modules
@iclanton iclanton force-pushed the normalize-build-output branch from 10739e8 to 8a10b9e Compare February 17, 2026 21:43
Set "sideEffects" field in package.json across all published packages to
enable webpack tree-shaking optimizations:
- Pure libraries: "sideEffects": false
- Executable apps with start entrypoints: sideEffects array listing
  lib-commonjs/ and lib-esm/ start files
- eslint-patch: sideEffects array listing side-effectful entry points
- webpack4-module-minifier-plugin: updated stale sideEffects path
…ma files

- Expose ./heft-plugin.json in all heft plugin packages (17 projects)
- Expose ./rush-plugin-manifest.json in all rush plugin packages (8 projects)
- Expose ./lib/*.schema.json in all packages with schema files (28 projects)
- Schema export placed before ./lib/* for correct Node.js pattern matching
…rush plugins to support ESM and CommonJS modules
…rush plugins to support ESM and CommonJS modules
…rush plugins to support ESM and CommonJS modules
@iclanton iclanton force-pushed the normalize-build-output branch from d289663 to 8dfe62d Compare February 18, 2026 02:45
@iclanton iclanton moved this from Needs triage to In Progress in Bug Triage Feb 18, 2026
Copy link
Contributor

@dmichon-msft dmichon-msft left a comment

Choose a reason for hiding this comment

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

Couple things caught earlier, otherwise looks good.

…ltiple rush plugins to support ESM and CommonJS modules
…ltiple rush plugins to support ESM and CommonJS modules
@iclanton iclanton enabled auto-merge (squash) February 18, 2026 23:27
@iclanton iclanton merged commit 6d669f1 into microsoft:main Feb 18, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Closed in Bug Triage Feb 18, 2026
@iclanton iclanton deleted the normalize-build-output branch February 18, 2026 23:50
@silverwind
Copy link

Regression: #5644

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

3 participants