[*] Chore: Refactor CommonJS scripts to ESM modules#8355
Merged
etrepum merged 13 commits intofacebook:mainfrom Apr 17, 2026
Merged
[*] Chore: Refactor CommonJS scripts to ESM modules#8355etrepum merged 13 commits intofacebook:mainfrom
etrepum merged 13 commits intofacebook:mainfrom
Conversation
Convert all remaining CommonJS scripts (.js) to ESM modules (.mjs): - scripts/shared/ (packagesManager, PackageMetadata, childProcess, etc.) - scripts/error-codes/ (transform-error-messages, ErrorMap, evalToString, etc.) - scripts/www/ (npmToWwwName, rewriteImports, transformFlowFileContents) - scripts/npm/ (release, prepare-release, increment-version, etc.) - Root-level scripts (clean, build-types, flow, lint-flow, etc.) - Root config files (babel.config.js -> .mjs, playwright.config.js -> .mjs) - packages/lexical-website/docusaurus.config.js -> .mjs - packages/lexical-website/plugins/package-docs/index.js -> .mjs Replace require()/module.exports with import/export, __dirname with import.meta.dirname, __filename with import.meta.filename. Update all cross-references in build.mjs, vite configs, wxt config, eslint config, package.json scripts, CI workflows, and AGENTS.md. https://claude.ai/code/session_01XHQmKstRXm1aqpPi9Zg9jE
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Update import paths from .js to .mjs in files that were already ESM but still referenced the old filenames: - scripts/update-tsconfig.mjs - scripts/update-examples.mjs - scripts/build.mjs (JSDoc type import) - scripts/__tests__/integration/setup.mjs - scripts/__tests__/integration/utils.mjs - scripts/__tests__/integration/ascii-only.test.mjs - scripts/__tests__/integration/prepare-release.test.mjs https://claude.ai/code/session_01XHQmKstRXm1aqpPi9Zg9jE
jiti v1 (used by Docusaurus to load configs) crashes on import.meta syntax. Fix by: - Keeping docusaurus.config.js as CJS (jiti resolves extensionless require() to .mjs files and transpiles them) - Removing import.meta.dirname from packagesManager.mjs, using process.cwd()-relative path.resolve() instead (scripts always run from repo root) - PackageMetadata.mjs and npmToWwwName.mjs never used import.meta, so they work under jiti as-is https://claude.ai/code/session_01XHQmKstRXm1aqpPi9Zg9jE
import.meta.dirname is a Node 20.11+ addition that jiti v1 doesn't transform. Use the classic fileURLToPath(import.meta.url) polyfill instead, which jiti does handle. This ensures packagesManager works correctly regardless of cwd (e.g. when loaded via viteModuleResolution from packages/lexical-playground). https://claude.ai/code/session_01XHQmKstRXm1aqpPi9Zg9jE
ceeff9f to
58779fe
Compare
Keep package-docs plugin as ESM (.mjs) and use the explicit path './plugins/package-docs/index.mjs' in docusaurus config so that Docusaurus's plugin resolver (which only looks for .js by default) can find it. jiti transpiles the ESM import/export to CJS. Verified with `pnpm run --filter @lexical/website build`. https://claude.ai/code/session_01XHQmKstRXm1aqpPi9Zg9jE
75b1fbe to
32c66f4
Compare
Replace findMonorepoRoot() + dynamic import() with a simple static import from the known relative path to PackageMetadata.mjs. https://claude.ai/code/session_01XHQmKstRXm1aqpPi9Zg9jE
The file is already excluded from the root tsconfig. Remove @ts-nocheck, redundant JSDoc type annotations, and the unnecessary _pm alias for packagesManager (it's always imported). https://claude.ai/code/session_01XHQmKstRXm1aqpPi9Zg9jE
Add @docusaurus/types and @docusaurus/plugin-content-docs as devDeps and use their exported types (Config, SidebarItemsGenerator, NormalizedSidebarItem, ParseFrontMatter) instead of any. Remove all eslint-disable comments for no-explicit-any. https://claude.ai/code/session_01XHQmKstRXm1aqpPi9Zg9jE
zurfyx
approved these changes
Apr 17, 2026
etrepum
pushed a commit
to etrepum/lexical
that referenced
this pull request
Apr 19, 2026
…ePostCss synchronous Docusaurus calls `configurePostCss` synchronously and does not await the return value (see applyConfigurePostCss in packages/docusaurus/src/webpack/configure.ts), so an async hook returns a Promise that is assigned to `postcssOptions` and the Tailwind plugin never makes it into the PostCSS pipeline. This regressed when the config was refactored to ESM in facebook#8355. Switch to a top-level `import` of `@tailwindcss/postcss` and drop the `async`/`await` from the hook. https://claude.ai/code/session_01SoJjmweDQQhEvnFepoP4X5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Convert all remaining CommonJS scripts (.js) to ESM modules (.mjs):
Replace require()/module.exports with import/export, __dirname with import.meta.dirname, __filename with import.meta.filename. Update all cross-references in build.mjs, vite configs, wxt config, eslint config, package.json scripts, CI workflows, and AGENTS.md.
Test plan
All of the tests/infrastructure/etc. should be changed to work with the new file extensions