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

Update Vite's Node API to ESM from CJS build #155

Merged
merged 2 commits into from
Jun 25, 2024
Merged

Update Vite's Node API to ESM from CJS build #155

merged 2 commits into from
Jun 25, 2024

Conversation

chacha912
Copy link
Contributor

@chacha912 chacha912 commented Jun 25, 2024

What this PR does / why we need it?

This PR resolves the warning message that occurs when running npm run dev or npm run build in Vite.
The warning message states that the CJS build of Vite's Node API is deprecated and provides instructions on how to address the issue by switching to ESM.

Any background context you want to provide?

What are the relevant tickets?

Fixes #154

Checklist

  • Added relevant tests or not required
  • Didn't break anything

Summary by CodeRabbit

  • New Features

    • Converted the project to use ES modules for a more modern JavaScript experience.
  • Chores

    • Updated import statements and dependencies to support ES module syntax.
    • Included a "type": "module" field in package.json to specify module type.

Copy link

coderabbitai bot commented Jun 25, 2024

Walkthrough

The codebase has transitioned from CommonJS to ES modules across multiple files, addressing deprecation warnings related to Vite's CJS build. The buf.gen.yaml configuration was updated for js_import_style, the package.json file now specifies "type": "module", and export default syntax replaced module.exports in JavaScript configurations. Dependencies and import paths were also updated where necessary.

Changes

File Path Change Summary
buf.gen.yaml Updated js_import_style from legacy_commonjs to module.
package.json Added "type": "module" and a new dependency.
postcss.config.js Switched from module.exports to export default.
src/api/converter.ts Updated the import path for BadRequest.
src/api/.../admin_connect.d.ts Updated protoc-gen-connect-es version and js_import_style.
src/api/.../admin_connect.js Changed import statements to ES modules and updated declarations.
src/api/.../admin_pb.d.ts Updated tool version and js_import_style parameter.
src/api/.../admin_pb.js Transitioned to ES module syntax.
src/api/.../resources_pb.d.ts Updated tool version and js_import_style parameter.
src/api/.../resources_pb.js Transitioned to ES module syntax.

Sequence Diagram(s)

(Not applicable – changes are straightforward and pertain to module syntax conversion rather than control flow modifications)

Assessment against linked issues

Objective (Issue #154) Addressed Explanation
Switch from CJS build to ESM to eliminate deprecation warnings

Poem

In the code where changes gleam,
From CommonJS to ES module dream,
Vite's warnings now no more,
We've aligned with modern lore.
Modules fresh, our paths anew,
With better code, we start anew. 🚀


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e79e391 and 67333cc.

Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
Files selected for processing (10)
  • buf.gen.yaml (1 hunks)
  • package.json (1 hunks)
  • postcss.config.js (1 hunks)
  • src/api/converter.ts (1 hunks)
  • src/api/yorkie/v1/admin_connect.d.ts (1 hunks)
  • src/api/yorkie/v1/admin_connect.js (2 hunks)
  • src/api/yorkie/v1/admin_pb.d.ts (1 hunks)
  • src/api/yorkie/v1/admin_pb.js (22 hunks)
  • src/api/yorkie/v1/resources_pb.d.ts (1 hunks)
  • src/api/yorkie/v1/resources_pb.js (48 hunks)
Files skipped from review due to trivial changes (5)
  • buf.gen.yaml
  • src/api/yorkie/v1/admin_connect.d.ts
  • src/api/yorkie/v1/admin_connect.js
  • src/api/yorkie/v1/admin_pb.d.ts
  • src/api/yorkie/v1/resources_pb.d.ts
Additional comments not posted (6)
postcss.config.js (1)

1-4: Approved: Transition to ES Module syntax.

The update from module.exports to export default aligns with modern JavaScript module practices and the PR's objectives to move to ESM. This change should be checked for compatibility with the rest of the project's module system.

package.json (2)

5-5: Approved: Configuration update to support ES modules.

Adding "type": "module" in the package.json is essential for enabling ES module syntax across the project.


8-8: Approved: Addition of new dependency.

The new dependency @buf/googleapis_googleapis.connectrpc_es is added presumably to support the updated ES module system. Ensure compatibility and integration testing with the project.

src/api/converter.ts (1)

27-27: Approved: Updated import path for BadRequest.

The import path change to @buf/googleapis_googleapis.bufbuild_es/google/rpc/error_details_pb aligns with the transition to ES modules. Verify that this path is correctly resolving and the module is accessible.

src/api/yorkie/v1/admin_pb.js (1)

16-16: Approved: Conversion to ES module exports and imports.

The updates to use ES module syntax for exports and imports are well-executed and align with modern JavaScript practices. Ensure that these changes integrate smoothly with the rest of the application, particularly in areas where these modules are consumed.

Also applies to: 21-22, 27-38, 48-59, 69-79, 89-99, 109-117, 127-138, 148-162, 172-183, 193-205, 213-225, 236-248, 259-273

src/api/yorkie/v1/resources_pb.js (1)

16-16: Approved: Comprehensive update to ES module syntax.

The conversion of module exports and the introduction of new ES module imports are consistent with the project's transition to a modern JavaScript module system. Perform a comprehensive integration test to ensure that all components interact correctly under the new system.
[APROVED]

Also applies to: 21-21, 26-49, 66-80, 95-108, 121-140, 154-168, 182-195, 217-231, 247-260, 277-294, 308-323, 337-351, 366-380, 395-409, 420-431, 443-457, 468-485, 495-506, 517-529, 547-560, 571-586, 597-610, 620-631, 643-655, 666-666

Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution.

@hackerwins hackerwins merged commit aa81c24 into main Jun 25, 2024
2 checks passed
@hackerwins hackerwins deleted the esm-build branch June 25, 2024 09:17
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.

Deprecation warning for Vite's CJS build of Node API
2 participants