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

refactor: add imports recommended in node #45

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

sebastiandotdev
Copy link

πŸ“ Description

Hi team nextui,

In this pr I took the trosxuble to refactor the node module imports according to today's recommended imports

thanks for reading

βœ… Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (improve a current implementation without adding a new feature or fixing a bug)
  • Improvement (non-breaking change which improves an existing feature)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

@winchesHe
Copy link
Member

@castrogarciajs Hi, could you explain what different between two import methods

@sebastiandotdev
Copy link
Author

sebastiandotdev commented Apr 22, 2024

Hi @winchesHe, yes of course,

Since nodejs version 16 it is no longer recommended to call native modules by name

Example (Not recommended)

import path from 'path'

It is recommended to use the node: prefix and it reduces the risk of a module present in node_modules overriding the newer imports.

It is also a more explicit protocol makes it more readable and also makes it clear that you are importing a built-in module. As there are many built-in modules, this extra information is useful for beginners or for someone who does not know some of them.

Resource where I learned what was explained: nodejs/node#38343

Example (Recommended)

import path from 'node:path'

@winchesHe
Copy link
Member

I got thx~ @castrogarciajs

@winchesHe winchesHe merged commit 1b3023f into nextui-org:main Apr 23, 2024
3 checks passed
@sebastiandotdev sebastiandotdev deleted the refactor/imports branch April 24, 2024 02:01
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