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

fix(shared-utils): process?.env will not transform to env by transcompiler #4327

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

s524797336
Copy link
Contributor

@s524797336 s524797336 commented Dec 11, 2024

When warn message such as button onClick deprecated warn, throw error when there is no global process var, transcompiler will not transform process?.env to env string with ? in it.

📝 Description

The warn method cause page error because process is not defined.

⛳️ Current behavior (updates)

Page break render

🚀 New behavior

Page correct render

💣 Is this a breaking change (Yes/No):

No

📝 Additional Information

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error handling in the warning function to ensure it raises an error if the process object is undefined, improving stability in various environments.

Copy link

changeset-bot bot commented Dec 11, 2024

🦋 Changeset detected

Latest commit: 0b66463

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 57 packages
Name Type
@nextui-org/shared-utils Patch
@nextui-org/accordion Patch
@nextui-org/alert Patch
@nextui-org/autocomplete Patch
@nextui-org/avatar Patch
@nextui-org/badge Patch
@nextui-org/breadcrumbs Patch
@nextui-org/button Patch
@nextui-org/calendar Patch
@nextui-org/card Patch
@nextui-org/checkbox Patch
@nextui-org/chip Patch
@nextui-org/code Patch
@nextui-org/date-input Patch
@nextui-org/date-picker Patch
@nextui-org/divider Patch
@nextui-org/drawer Patch
@nextui-org/dropdown Patch
@nextui-org/form Patch
@nextui-org/image Patch
@nextui-org/input-otp Patch
@nextui-org/input Patch
@nextui-org/kbd Patch
@nextui-org/link Patch
@nextui-org/listbox Patch
@nextui-org/menu Patch
@nextui-org/modal Patch
@nextui-org/navbar Patch
@nextui-org/pagination Patch
@nextui-org/popover Patch
@nextui-org/progress Patch
@nextui-org/radio Patch
@nextui-org/ripple Patch
@nextui-org/scroll-shadow Patch
@nextui-org/select Patch
@nextui-org/skeleton Patch
@nextui-org/slider Patch
@nextui-org/snippet Patch
@nextui-org/spacer Patch
@nextui-org/spinner Patch
@nextui-org/switch Patch
@nextui-org/table Patch
@nextui-org/tabs Patch
@nextui-org/tooltip Patch
@nextui-org/user Patch
@nextui-org/theme Patch
@nextui-org/use-aria-button Patch
@nextui-org/use-aria-link Patch
@nextui-org/use-data-scroll-overflow Patch
@nextui-org/use-infinite-scroll Patch
@nextui-org/use-pagination Patch
@nextui-org/aria-utils Patch
@nextui-org/framer-utils Patch
@nextui-org/react-utils Patch
@nextui-org/react Patch
@nextui-org/system Patch
@nextui-org/use-real-shape Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Dec 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextui-docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2024 5:30am
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2024 5:30am

Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

Walkthrough

The changes involve a modification to the warn function in the console.ts file. The update removes optional chaining from the check for process.env.NODE_ENV, ensuring that if process is undefined, an error will be thrown instead of failing silently. This adjustment enhances the control flow by enforcing a stricter environment check while keeping the rest of the function's logic intact.

Changes

File Path Change Summary
packages/utilities/shared-utils/src/console.ts Modified the warn function to remove optional chaining from the process.env.NODE_ENV check, ensuring an error is thrown if process is undefined.
.changeset/clever-teachers-live.md Introduced a patch for the @nextui-org/shared-utils package to address issues with the process not being defined.

Possibly related PRs

  • fix(deps): overrides RA utils pkg #3537: This PR addresses an issue related to the process not being defined, which is directly relevant to the changes made in the main PR that modifies the warn function to ensure that process is defined before checking process.env.NODE_ENV.

Suggested reviewers

  • jrgarciadev

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

vercel bot commented Dec 11, 2024

@s524797336 is attempting to deploy a commit to the NextUI Inc Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 76a72a9 and e8fc013.

📒 Files selected for processing (1)
  • packages/utilities/shared-utils/src/console.ts (1 hunks)

@jrgarciadev
Copy link
Member

Hey @s524797336 could you add the error your getting? / Replicaton ?

@s524797336
Copy link
Contributor Author

Hey @s524797336 could you add the error your getting? / Replicaton ?

image

A compiler like Webpack automatically replaces process.env.NODE_ENV with a string, such as 'development'. However, if you write it as process?.env?.NODE_ENV, Webpack won’t be able to replace it. This results in the process variable being directly executed in the browser, which is not defined by code, causing an error to be thrown.

@jrgarciadev
Copy link
Member

@wingkwong please check

@wingkwong wingkwong self-assigned this Dec 12, 2024
@wingkwong wingkwong changed the title Fix (console.ts): process?.env will not transform to env by transcompiler fix(shared-utils): process?.env will not transform to env by transcompiler Dec 12, 2024
Copy link
Member

@wingkwong wingkwong left a comment

Choose a reason for hiding this comment

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

Do you have any repo that can show us how you configure or reproduce the issue?

UPD: ok i can reproduce it now.

@wingkwong wingkwong added this to the v2.6.9 milestone Dec 12, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
.changeset/clever-teachers-live.md (1)

5-5: Enhance the change description for better clarity

The current description "fix process is not defined" is too brief. Consider expanding it to better explain the issue and its resolution:

-fix process is not defined
+fix: remove optional chaining from process.env to ensure proper transcompiler transformation

This helps other developers understand:

  • What was changed (removal of optional chaining)
  • Why it was changed (to ensure proper transcompiler transformation)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e8fc013 and 0b66463.

📒 Files selected for processing (1)
  • .changeset/clever-teachers-live.md (1 hunks)
🔇 Additional comments (1)
.changeset/clever-teachers-live.md (1)

1-3: LGTM on the patch version bump

The patch version bump is appropriate as this fixes a bug (process undefined error) without introducing breaking changes.

macci001 pushed a commit that referenced this pull request Dec 17, 2024
…piler (#4327)

* Fix (console.ts): process?.env will not transform to env by transcompiler

* chore(changeset): add changeset

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants