Skip to content

feat: allow wasm in nodejs #253

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

Merged
merged 1 commit into from
Aug 16, 2024
Merged

feat: allow wasm in nodejs #253

merged 1 commit into from
Aug 16, 2024

Conversation

ponderingdemocritus
Copy link
Contributor

@ponderingdemocritus ponderingdemocritus commented Aug 16, 2024

Allows wasm to run in nodejs env

Summary by CodeRabbit

  • New Features

    • Introduced separate build commands for web browsers and Node.js, enhancing the deployment strategy for WebAssembly packages.
    • Added explicit paths for JavaScript and TypeScript definitions in the package configuration to support multiple environments.
  • Improvements

    • Enhanced clarity of build commands with descriptive comments in the build script.
    • Updated package configuration to delineate resources for web and Node.js contexts.

Copy link

coderabbitai bot commented Aug 16, 2024

Walkthrough

The updates to the torii-wasm package enhance its build process and compatibility across different environments. The build script now supports distinct targets for web browsers and Node.js, allowing for tailored WebAssembly outputs. Additionally, the package.json file has been restructured to reflect new paths for JavaScript and TypeScript files and to include variations for both platforms, improving resource management and clarity for developers.

Changes

File Change Summary
packages/torii-wasm/build.sh Added separate build commands for web (--target web) and Node.js (--target nodejs).
packages/torii-wasm/package.json Updated paths for main, module, and types; added a new browser entry; expanded files array for web and node variants; updated sideEffects.

Poem

🐰 In the land where code does play,
New builds emerge, hip-hip-hooray!
Web and Node now stand apart,
Each with paths that warm the heart.
With every change, we hop and cheer,
For better codes, we hold so dear! 🎉


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

Outside diff range, codebase verification and nitpick comments (4)
packages/torii-wasm/build.sh (1)

6-6: Consider adding error handling for git clone.

While the set -ex option will exit on error, it might be useful to provide a more descriptive error message if the clone fails.

git clone --depth 1 https://github.com/dojoengine/dojo.c dojo.c || { echo "Failed to clone repository"; exit 1; }
packages/torii-wasm/package.json (3)

7-8: Files specified in main and browser entries are missing.

The files ./pkg/node/dojo_c.js and ./pkg/web/dojo_c.js do not exist in the specified locations. Please verify the build process to ensure these files are generated correctly, or check the paths in the package.json for accuracy.

  • main: ./pkg/node/dojo_c.js is missing.
  • browser: ./pkg/web/dojo_c.js is missing.
Analysis chain

Verify the main and browser entries.

Ensure that the paths specified in the main and browser entries are correct and that the files exist in the specified locations.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify existence of main and browser entry files.

# Test: Check if the specified files exist.
test -f ./pkg/node/dojo_c.js && echo "Node.js main file exists." || echo "Node.js main file is missing."
test -f ./pkg/web/dojo_c.js && echo "Browser file exists." || echo "Browser file is missing."

Length of output: 188


15-22: Missing Files in files Array

None of the files listed in the files array of packages/torii-wasm/package.json exist in the specified locations. Please verify the build process to ensure these files are correctly generated.

  • ./pkg/web/dojo_c_bg.wasm is missing.
  • ./pkg/web/dojo_c.js is missing.
  • ./pkg/web/dojo_c_bg.js is missing.
  • ./pkg/web/dojo_c.d.ts is missing.
  • ./pkg/node/dojo_c_bg.wasm is missing.
  • ./pkg/node/dojo_c.js is missing.
  • ./pkg/node/dojo_c_bg.js is missing.
  • ./pkg/node/dojo_c.d.ts is missing.
Analysis chain

Ensure all files in the files array exist.

Verify that all the files listed in the files array are correctly generated and exist in the specified locations.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify existence of files listed in the files array.

# Test: Check if each specified file exists.
for file in ./pkg/web/dojo_c_bg.wasm ./pkg/web/dojo_c.js ./pkg/web/dojo_c_bg.js ./pkg/web/dojo_c.d.ts ./pkg/node/dojo_c_bg.wasm ./pkg/node/dojo_c.js ./pkg/node/dojo_c_bg.js ./pkg/node/dojo_c.d.ts; do
  test -f $file && echo "$file exists." || echo "$file is missing."
done

Length of output: 2479


24-25: Missing module and types files in package.json.

The files specified in the module and types entries (./pkg/web/dojo_c.js and ./pkg/web/dojo_c.d.ts) do not exist. Please verify the build process or correct the paths in the package.json.

  • Ensure the build process generates these files.
  • Check if the paths in package.json are correct.
Analysis chain

Verify module and types entries.

Ensure that the paths specified in the module and types entries are correct and that the files exist in the specified locations.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify existence of module and types entry files.

# Test: Check if the specified files exist.
test -f ./pkg/web/dojo_c.js && echo "Module file exists." || echo "Module file is missing."
test -f ./pkg/web/dojo_c.d.ts && echo "Types file exists." || echo "Types file is missing."

Length of output: 173

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0d3fcb3 and 9f1e947.

Files selected for processing (2)
  • packages/torii-wasm/build.sh (1 hunks)
  • packages/torii-wasm/package.json (1 hunks)
Additional comments not posted (1)
packages/torii-wasm/build.sh (1)

11-14: Ensure wasm-pack is installed and compatible.

Make sure that wasm-pack is installed and the version is compatible with your build requirements. Consider adding a version check or installation instructions.

@ponderingdemocritus ponderingdemocritus merged commit e7d393c into main Aug 16, 2024
4 checks passed
@ponderingdemocritus ponderingdemocritus deleted the wasm-node branch August 16, 2024 15:27
@coderabbitai coderabbitai bot mentioned this pull request Oct 23, 2024
@coderabbitai coderabbitai bot mentioned this pull request Mar 19, 2025
5 tasks
@coderabbitai coderabbitai bot mentioned this pull request Apr 17, 2025
5 tasks
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.

1 participant