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

feat(worker): add swc compiler for the worker service #5375

Open
wants to merge 17 commits into
base: next
Choose a base branch
from

Conversation

abrl91
Copy link

@abrl91 abrl91 commented Apr 7, 2024

What change does this PR introduce?

Adding swc to the Worker

Why was this change needed?

Integrating SWC with the Nest CLI has greatly enhanced the efficiency of the development workflow.

Other information (Screenshots)

Before:

  • on start
    image
  • on change
    image

After:

  • on start
    image
  • on change
    image

Copy link

netlify bot commented Apr 7, 2024

👷 Deploy request for dev-web-novu pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 0807380

Copy link

netlify bot commented Apr 7, 2024

Deploy Preview for novu-design failed. Why did it fail? →

Name Link
🔨 Latest commit 0807380
🔍 Latest deploy log https://app.netlify.com/sites/novu-design/deploys/6628ed1d3195820008293a9e

@scopsy scopsy changed the title Chore/worker add swc feat(worker): add swc compiler for the worker service Apr 8, 2024
@scopsy
Copy link
Contributor

scopsy commented Apr 8, 2024

An interesting find I've noticed, when removing webpack: true from the nest-cli config, and relying only on SWC to compile, the compilation takes 70ms, with the current setup in this branch it takes for me 3000ms which is exactly similar to swc turned off. Which makes me think it's not really taking effect here.

Should we consider just go with plain SWC without webpack? (Some path adjustments need to be done when importing the .env files for it to work, But should be manageable)

CleanShot 2024-04-08 at 11 20 37@2x

@abrl91
Copy link
Author

abrl91 commented Apr 8, 2024

An interesting find I've noticed, when removing webpack: true from the nest-cli config, and relying only on SWC to compile, the compilation takes 70ms, with the current setup in this branch it takes for me 3000ms which is exactly similar to swc turned off. Which makes me think it's not really taking effect here.

Should we consider just go with plain SWC without webpack? (Some path adjustments need to be done when importing the .env files for it to work, But should be manageable)

CleanShot 2024-04-08 at 11 20 37@2x

Well, I am not sure.
As Nest suggested in their docs:
"If your repository is a monorepo, then instead of using swc builder you have to configure webpack to use swc-loader."

Should I try tweaking just the nest-cli.json?
I have already tried and indeed got this error
image

@abrl91 abrl91 requested a review from scopsy April 8, 2024 15:35
@scopsy
Copy link
Contributor

scopsy commented Apr 9, 2024

This is slightly confusing, although we are a monorepo, we don't really have nest setup in a monorepo mode. Each app is treated independently without a centralized nest cli file.

I think worth giving it a go without webpack. With webpack it seems doesn't really affect build time before and after the change. Or maybe i'm missing something. Have you had a chance to compare reaults of 'start:dev' compared to the next branch?

@abrl91
Copy link
Author

abrl91 commented Apr 9, 2024

This is slightly confusing, although we are a monorepo, we don't really have nest setup in a monorepo mode. Each app is treated independently without a centralized nest cli file.

I think worth giving it a go without webpack. With webpack it seems doesn't really affect build time before and after the change. Or maybe i'm missing something. Have you had a chance to compare reaults of 'start:dev' compared to the next branch?

You mean start:dev from the worker dir, right? I'll check.
Just yesterday I realized that I can run the worker from its path :)
I noticed that after removing the changes I have made to the webpack file, and changed the nest-cli configuration
image

it was faster, but I got the error about the .env path.

@scopsy
Copy link
Contributor

scopsy commented Apr 9, 2024

@abrl91 yep! I think that's the way. Fixing the path errors should be relatively simple. It's usually just adding or removing the "../../" in the imports of those files to be relative to their new location in the dist folder.

First one is from the config/index.ts folder I believe

Copy link
Contributor

coderabbitai bot commented Apr 10, 2024

Walkthrough

The recent updates focus on enhancing the build process and environment handling in a worker application. Changes include the integration of SWC for faster builds, adjustments in the output directory for .env files, and a shift in the method for loading environment variables to improve flexibility and adherence to modern JavaScript practices.

Changes

File(s) Summary of Changes
apps/worker/nest-cli.json Updated the output directory to "dist" for .env files, added a new "builder" object with SWC configuration, and enabled type checking.
apps/worker/package.json Added SWC dependencies (@swc/cli and @swc/core).
apps/worker/src/config/index.ts Modified the path configuration to use process.cwd() for loading environment variables, replacing __dirname.

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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@abrl91
Copy link
Author

abrl91 commented Apr 10, 2024

@scopsy I think you can re-review it :)

@scopsy
Copy link
Contributor

scopsy commented Apr 10, 2024

@coderabbitai review

@scopsy
Copy link
Contributor

scopsy commented Apr 10, 2024

@coderabbitai review

@abrl91 abrl91 requested a review from a team as a code owner May 14, 2024 10:44
@abrl91 abrl91 requested review from AliaksandrRyzhou and removed request for a team May 14, 2024 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants