Skip to content
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

Build: Shim CJS-only globals in ESM output #29157

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

valentinpalkovic
Copy link
Contributor

@valentinpalkovic valentinpalkovic commented Sep 19, 2024

Closes #29151

What I did

Shim CJS-only globals like __dirname or require in ESM build outputs.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

  1. https://stackblitz.com/edit/sveltejs-kit-template-default-9enxbt?file=.storybook%2Fmain.js
  2. Install Canary
  3. Run Storybook. Storybook should not crash

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli/src/sandbox-templates.ts

  • Make 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 pull request has been released as version 0.0.0-pr-29157-sha-987feb44. Try it out in a new sandbox by running npx [email protected] sandbox or in an existing project with npx [email protected] upgrade.

More information
Published version 0.0.0-pr-29157-sha-987feb44
Triggered by @valentinpalkovic
Repository storybookjs/storybook
Branch valentin/fix-svelte-vite-plugin
Commit 987feb44
Datetime Thu Sep 19 13:24:51 UTC 2024 (1726752291)
Workflow run 10941929965

To request a new release of this pull request, mention the @storybookjs/core team.

core team members can create a new canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=29157

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 77.4 MB 77.4 MB 0 B 3.14 0%
initSize 162 MB 162 MB 0 B -0.22 0%
diffSize 85 MB 85 MB 0 B -0.36 0%
buildSize 7.57 MB 7.57 MB 0 B 0.41 0%
buildSbAddonsSize 1.66 MB 1.66 MB 0 B 0.49 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 2.34 MB 2.34 MB 0 B 0.42 0%
buildSbPreviewSize 352 kB 352 kB 0 B 0.23 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.55 MB 4.55 MB 0 B 0.49 0%
buildPreviewSize 3.02 MB 3.02 MB 0 B -0.52 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 25.3s 23.2s -2s -90ms 1.37 🔰-9%
generateTime 18.9s 20.3s 1.3s -0.15 6.9%
initTime 13.9s 15.8s 1.9s -0.76 12%
buildTime 11.1s 13.7s 2.6s 2.02 🔺19%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 7.8s 6.3s -1s -479ms -0.85 -23.2%
devManagerResponsive 5s 4.2s -798ms -0.57 -18.9%
devManagerHeaderVisible 762ms 705ms -57ms -0.97 -8.1%
devManagerIndexVisible 795ms 738ms -57ms -1 -7.7%
devStoryVisibleUncached 1.5s 1.2s -300ms -0.23 -23.2%
devStoryVisible 792ms 736ms -56ms -1.02 -7.6%
devAutodocsVisible 865ms 655ms -210ms -0.87 -32.1%
devMDXVisible 744ms 641ms -103ms -0.96 -16.1%
buildManagerHeaderVisible 763ms 650ms -113ms -1.31 🔰-17.4%
buildManagerIndexVisible 800ms 656ms -144ms -1.33 🔰-22%
buildStoryVisible 799ms 735ms -64ms -1.05 -8.7%
buildAutodocsVisible 708ms 580ms -128ms -1.36 🔰-22.1%
buildMDXVisible 651ms 598ms -53ms -1.07 -8.9%

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings

Comment on lines 97 to 102
import ESM_COMPAT_Module from "node:module";
import { fileURLToPath as ESM_COMPAT_fileURLToPath } from 'node:url';
import { dirname as ESM_COMPAT_dirname } from 'node:path';
const __filename = ESM_COMPAT_fileURLToPath(import.meta.url);
const __dirname = ESM_COMPAT_dirname(__filename);
const require = ESM_COMPAT_Module.createRequire(import.meta.url);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider using import.meta.url directly instead of creating a __filename variable

Copy link

nx-cloud bot commented Sep 19, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 987feb4. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant