-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Core: ESM-only-fi server-related entry points #31831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core: ESM-only-fi server-related entry points #31831
Conversation
| "./internal/builder-manager": { | ||
| "types": "./dist/builder-manager/index.d.ts", | ||
| "import": "./dist/builder-manager/index.js", | ||
| "require": "./dist/builder-manager/index.cjs" | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is no longer exported but referenced directly within storybook core. I don't see any reason to "expose" this to the outside.
|
View your CI Pipeline Execution ↗ for commit b06aecc.
☁️ Nx Cloud last updated this comment at |
| // TODO: test this in Yarn PnP | ||
| const parsedBuilderPackage = parseNodeModulePath(builderName); | ||
| if (!parsedBuilderPackage.name) { | ||
| console.error(parsedBuilderPackage); | ||
| throw new Error('Invalid builder package'); | ||
| } | ||
| builderPackage = parsedBuilderPackage.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to test this in Yarn PnP before merging
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 46 | 46 | 0 |
| Self size | 28.68 MB | 23.83 MB | 🎉 -4.85 MB 🎉 |
| Dependency size | 17.17 MB | 17.17 MB | 0 B |
| Bundle Size Analyzer | Link | Link |
sb
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 47 | 47 | 0 |
| Self size | 1 KB | 1 KB | 0 B |
| Dependency size | 45.86 MB | 41.00 MB | 🎉 -4.85 MB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 215 | 215 | 0 |
| Self size | 582 KB | 582 KB | 🎉 -19 B 🎉 |
| Dependency size | 91.52 MB | 86.87 MB | 🎉 -4.65 MB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 184 | 184 | 0 |
| Self size | 31 KB | 31 KB | 0 B |
| Dependency size | 75.66 MB | 70.80 MB | 🎉 -4.85 MB 🎉 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 1 | 1 | 0 |
| Self size | 12.46 MB | 12.67 MB | 🚨 +203 KB 🚨 |
| Dependency size | 98 KB | 98 KB | 0 B |
| Bundle Size Analyzer | Link | Link |
…s/storybook into jeppe/migrate-core-esm-only-4
There was a problem hiding this 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 converts several server‐related entry points to use an ESM-only bundling pipeline by updating module resolution, packaging utilities, and exports. Key changes include:
- Transitioning getModulePackageJSON methods across package manager proxies to async/await.
- Replacing legacy resolution utilities with mlly’s resolveModule and resolvePathSync.
- Updating exports in package.json to align with an ESM-only strategy.
Reviewed Changes
Copilot reviewed 20 out of 50 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| code/core/src/common/utils/glob-to-regexp.ts | Minor documentation (comment) update for consistency. |
| code/core/src/common/utils/get-storybook-refs.ts | Updated comment wording for fetching stories.json. |
| code/core/src/common/utils/get-addon-annotations.ts | Switched from require.resolve to resolveModule. |
| code/core/src/common/utils/cli.ts | Changed synchronous package JSON retrieval to async. |
| code/core/src/common/presets.ts | Revised preset resolution logic with inline safeResolve and mlly resolution enhancements. |
| code/core/src/common/js-package-manager/* | Converted getModulePackageJSON methods to async for various package managers. |
| code/core/src/builder-manager/* | Replaced legacy safeResolve usage with resolvePathSync and resolveModule. |
| code/core/scripts/* | Updated entry definitions and formatting in helper scripts. |
| code/core/package.json | Updated exports mapping to support the ESM-only approach. |
| code/addons/vitest/src/postinstall.ts | Minor adjustment in config loading options. |
Comments suppressed due to low confidence (2)
code/core/src/common/presets.ts:71
- [nitpick] Consider renaming the inline 'safeResolve' function to avoid confusion with the previously removed safeResolve utility.
const safeResolve = (path: string) => {
code/core/package.json:59
- Ensure the updated exports mapping—particularly for './internal/common'—has no duplicate or conflicting entries, and verify that the removal of traditional keys like 'main' and 'module' aligns with the intended ESM-only design.
"./internal/core-server": {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
48 files reviewed, 6 comments
Edit PR Review Bot Settings | Greptile
…ckage manager's getModulePackageJSON
…etect and compatibility checks
…s/storybook into jeppe/migrate-core-esm-only-4
… of @storybook/test-runner
…orybookjs/storybook into jeppe/migrate-core-esm-only-4
…s/storybook into jeppe/migrate-core-esm-only-4
…orybookjs/storybook into jeppe/migrate-core-esm-only-4
… for Jest in Next.js projects. Update Jest setup and package.json for compatibility with ESM modules. Introduce .swcrc for SWC settings in Next.js. Adjust transform settings in Jest config for both React and Next.js projects.
…st canary version of @storybook/test-runner
…orybookjs/storybook into jeppe/migrate-core-esm-only-4
| exportPath?: string; | ||
| customSuffix?: string; | ||
| }) => { | ||
| const modulePath = join(pkg, exportPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this join does not work on windows as expected:
https://github.com/storybookjs/storybook/actions/runs/15858047768/job/44711738366?pr=31831
b3c6ebd
into
jeppe/migrate-core-esm-only-3
Works on #31817
What I did
This PR continues the work of #31825 , converting the server-related entry points to the new ESM-only bundling pipeline.
I added
mllyas a utility to parse paths to module as well as resolve modules extensionless a couple of places.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake sure this PR contains one of the labels below:
Available labels
bug: Internal changes that fixes incorrect behavior.maintenance: User-facing maintenance tasks.dependencies: Upgrading (sometimes downgrading) dependencies.build: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup: Minor cleanup style change. Will not show up in release changelog.documentation: Documentation only changes. Will not show up in release changelog.feature request: Introducing a new feature.BREAKING CHANGE: Changes that break compatibility in some way with current major version.other: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/coreteam here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>Greptile Summary
Major refactoring to migrate server-related entry points to ESM-only bundling pipeline, replacing CommonJS-style imports with modern ESM patterns and utilities.
mllypackage to handle module path parsing and resolution, replacingrequire.resolveand custom utilities across multiple filesgetModulePackageJSONasync in all package manager proxies (NPM, Yarn, PNPM, BUN) for better ESM compatibilityloader.mjsandsafeResolve.ts, introducing newloader.tswith esbuild for TypeScript to ESM conversioncode/core/scripts/entries.tsby organizing them into platform-specific ESM-only sections (node, browser, runtime)resolveModuleutility incode/core/src/shared/utils/resolve.tsto handle ESM-compatible path resolution