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

[V3 Runtime] Ensure JS package has parity with various node versions #3821

Merged
merged 1 commit into from
Oct 13, 2024

Conversation

atterpac
Copy link
Member

@atterpac atterpac commented Oct 12, 2024

Community member brought up our v3 runtime package not being compatable with various node runtime versions and checking via publint

Current issues can be seen: @wailsio publint

PR Resolves notes given by publint to ensure parity with various node versions.

Summary by CodeRabbit

  • New Features
    • Updated to version 3.0.0-alpha.28 of the Wails runtime, enhancing module compatibility.
    • Introduced a new module type specification for improved functionality.
    • Updated repository URL format for better integration.

These changes aim to streamline the development experience and improve compatibility with modern JavaScript module standards.

Copy link

Copy link
Contributor

coderabbitai bot commented Oct 12, 2024

Walkthrough

The changes involve updates to the package.json file for the @wailsio/runtime package. The version number has been incremented to 3.0.0-alpha.28, and a new "type" field has been added to specify the module type as "module". The previous "main" and "types" fields have been removed and replaced with an "exports" field that defines the module's exports. Additionally, the repository URL format has been modified to a Git URL format.

Changes

File Path Change Summary
v3/internal/runtime/desktop/@wailsio/runtime/package.json - Version updated to 3.0.0-alpha.28
- Added "type": "module"
- Removed "main" and "types" fields
- Added "exports" field
- Changed repository URL format to Git URL

Poem

In the garden of code, where the rabbits play,
A new version hops in, brightening the day.
With exports defined and types now in sight,
Our package is ready, oh what a delight!
So let’s dance in the fields, with joy we proclaim,
For updates and changes, we celebrate the game! 🐇✨


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 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
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)
v3/internal/runtime/desktop/@wailsio/runtime/package.json (1)

6-12: Great implementation of the "exports" field

The addition of the "exports" field is an excellent improvement. It provides clear and precise control over how the package can be imported, which is crucial for maintaining compatibility across different environments. The structure looks correct, specifying separate paths for types and the main module.

One minor suggestion:

Consider adding a "default" export to handle cases where the importing environment doesn't support the conditional exports:

 "exports": {
   ".": {
     "types": "./types/index.d.ts",
     "require": "./src/index.js",
-    "import": "./src/index.js"
+    "import": "./src/index.js",
+    "default": "./src/index.js"
   }
 },

This ensures maximum compatibility while still taking advantage of the more specific import conditions when available.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fc6f6bd and 0744fbb.

📒 Files selected for processing (1)
  • v3/internal/runtime/desktop/@wailsio/runtime/package.json (1 hunks)
🧰 Additional context used
🔇 Additional comments (5)
v3/internal/runtime/desktop/@wailsio/runtime/package.json (5)

3-3: Excellent addition of the "type" field

Adding "type": "module" is a great improvement. It explicitly declares that this package uses ECMAScript modules, which is crucial for modern JavaScript development and ensures better compatibility across different Node.js versions.


4-4: Version bump is appropriate

Incrementing the version to "3.0.0-alpha.28" is correct. It reflects the changes made to the package structure and follows semantic versioning principles for pre-release versions.


15-15: Repository URL format change is fine but optional

Changing the repository URL to use the git+ prefix ("git+https://github.com/wailsapp/wails.git") is acceptable. This format can provide better integration with git-based workflows and is recognized by npm and other tools.

However, it's worth noting that this change is optional, and the previous format was also valid and widely used. Both formats are supported by npm and other package managers.


Line range hint 1-41: Appropriate removal of "main" and "types" fields

The removal of the "main" and "types" fields is correct and aligns with best practices when using the "exports" field. These fields are now effectively replaced by the more precise declarations in the "exports" field. This change helps prevent potential conflicts or confusion that could arise from having both the old fields and the new exports field.


Line range hint 1-41: Overall, excellent improvements to package structure and compatibility

The changes made to this package.json file are well-thought-out and address the PR objectives effectively. By implementing modern package.json features like the "exports" field and explicitly declaring the module type, you've significantly improved the package's compatibility with various Node.js versions.

These modifications align well with current best practices and should resolve the issues identified by publint. The new structure provides clearer guidelines for how the package should be imported and used, which will benefit developers working with this package across different environments.

Great job on enhancing the robustness and usability of the @wailsio/runtime package!

@leaanthony leaanthony merged commit 94e8f8b into wailsapp:v3-alpha Oct 13, 2024
13 of 14 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Dec 23, 2024
4 tasks
@RichardLindhout
Copy link

(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
ModuleNotFoundError: Module not found: Error: Can't resolve './drag' in '/Users/arjendevos/go/src/github.com/half-5/time-app/frontend/node_modules/@wailsio/runtime/src'
Did you mean 'drag.js'?

In react native web

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