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

Maintenance: Prep for ESM #25884

Closed
wants to merge 18 commits into from
Closed

Maintenance: Prep for ESM #25884

wants to merge 18 commits into from

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Feb 2, 2024

What I did

  • use node:path over path
  • use node:fs over fs
  • use named exports of fs and path, where possible.
  • replace/split fs-extra use into @ndelangen@fs-extra-unified and node:fs/promise

@ndelangen@fs-extra-unified has an export map in it's package.json, and is explicit about which exports it has.

fs-extra does have ESM support, but to need to explicitly import fs-extra/esm to get it, which is a problem when generating dist code that needs to run in both CJS & EMS environments.
fs-extra/esm only exports a subset of methods, because most can be imported from node:fs/promise.

I'd be great if we cleaned up the mocking situation a bit..

Manual testing

  • We should be able to run any script we're used to running in the monorepo during development.
  • Creating sandboxes should be unchanged
  • Running sandboxes should be unchanged.

I tested the above on my local machine ☝️

These changes should not have any impact on browser code, AFAICS

🦋 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/core team 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>

@ndelangen ndelangen self-assigned this Feb 2, 2024
@ndelangen ndelangen added maintenance User-facing maintenance tasks ci:normal labels Feb 2, 2024
Copy link

socket-security bot commented Feb 2, 2024

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@ndelangen/[email protected] Transitive: environment, filesystem +8 4.12 MB ndelangen

View full report↗︎

@ndelangen ndelangen requested a review from JReinhold February 2, 2024 21:39
@ndelangen ndelangen requested a review from shilman February 5, 2024 14:35
Copy link
Contributor

@JReinhold JReinhold left a comment

Choose a reason for hiding this comment

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

This looks like a great improvement, but I think we want ESLint's help to keep this from rotting.

I still see a couple of instances not using 'node:X' yet:

image

image

code/addons/links/scripts/fix-preview-api-reference.ts Outdated Show resolved Hide resolved
code/lib/core-common/src/utils/cli.ts Show resolved Hide resolved
@ndelangen ndelangen marked this pull request as draft February 9, 2024 10:19
@ndelangen ndelangen closed this Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:normal maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants