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: Add node:-prefix to node core-modules #28860

Merged
merged 3 commits into from
Aug 10, 2024

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Aug 10, 2024

What I did

Node core modules (fs, path, etc) should be imported with a node: prefix to ensure the modules isn't accidentally resolve from node_modules, or a local file.

Besides getting the intent clear, it also means the formatting (order of imports) is best.

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!

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 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>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 76.3 MB 76.3 MB 0 B -0.3 0%
initSize 167 MB 167 MB -1.31 kB -0.62 0%
diffSize 91.1 MB 91.1 MB -1.31 kB -0.62 0%
buildSize 7.42 MB 7.42 MB 0 B 1.01 0%
buildSbAddonsSize 1.61 MB 1.61 MB 0 B -2 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 2.29 MB 2.29 MB 0 B 2 0%
buildSbPreviewSize 351 kB 351 kB 0 B -2 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.45 MB 4.45 MB 0 B 2 0%
buildPreviewSize 2.97 MB 2.97 MB 0 B -0.49 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 8.1s 22.3s 14.2s 0.61 63.7%
generateTime 19.6s 18.2s -1s -446ms -1.1 -7.9%
initTime 16s 16.1s 122ms -1.2 0.8%
buildTime 11.8s 11.5s -288ms -0.85 -2.5%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 8.3s 7.4s -839ms -0.99 -11.2%
devManagerResponsive 4.8s 4.5s -323ms -1.29 🔰-7.1%
devManagerHeaderVisible 986ms 803ms -183ms -0.19 -22.8%
devManagerIndexVisible 1s 833ms -186ms -0.2 -22.3%
devStoryVisibleUncached 1.2s 1.3s 99ms 0.58 7.2%
devStoryVisible 1s 847ms -188ms -0.27 -22.2%
devAutodocsVisible 865ms 743ms -122ms -0.11 -16.4%
devMDXVisible 798ms 664ms -134ms -0.98 -20.2%
buildManagerHeaderVisible 768ms 853ms 85ms 0.67 10%
buildManagerIndexVisible 776ms 858ms 82ms 0.64 9.6%
buildStoryVisible 820ms 897ms 77ms 0.61 8.6%
buildAutodocsVisible 748ms 958ms 210ms 2.92 🔺21.9%
buildMDXVisible 789ms 767ms -22ms 1.04 -2.9%

Greptile Summary

The pull request updates Node.js core module imports to use the 'node:' prefix across various files, ensuring compatibility with modern Node.js versions and aligning with best practices.

  • code/addons/controls/src/preset/checkDocsLoaded.ts: Updated path module imports to node:path.
  • code/addons/docs/src/plugins/mdx-plugin.ts: Changed dirname and join imports to node:path.
  • code/addons/essentials/src/index.ts: Replaced path module imports with node:path.
  • code/builders/builder-vite/src/codegen-importfn-script.ts: Added node: prefix to path module import.
  • code/core/src/cli/angular/helpers.ts: Updated fs and path imports to node:fs and node:path.

These changes ensure explicit recognition of core modules, avoiding potential conflicts and maintaining consistency.

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

nx-cloud bot commented Aug 10, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 0edd826. 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.

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.

LGTM

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

@ndelangen ndelangen merged commit 1caffa8 into next Aug 10, 2024
53 checks passed
@ndelangen ndelangen deleted the norbert/add-node-prefix-to-core-modules branch August 10, 2024 20:12
@github-actions github-actions bot mentioned this pull request Aug 10, 2024
29 tasks
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.

1 participant