Skip to content

Conversation

@Zn4rK
Copy link
Contributor

@Zn4rK Zn4rK commented Nov 28, 2025

This PR makes two improvements to RedwoodSDK:

  1. Removed the node_modules exclusion guard in the entry-resolution logic
    The SDK previously had an if statement that stopped the branching logic from running whenever the resolved entry path contained node_modules. This prevented RedwoodSDK from handling entries that legitimately resolve to packages.

    I removed this node_modules check so that the branching logic always runs, regardless of where the entry is located. This makes the behavior consistent and fixes cases where code inside node_modules should still be treated as an entry point.

    (Note: in the new playground example, the client entry is not in node_modules; it resides in the playground src due to a symlinking limitation.)

  2. Added a new playground example
    I added a minimal example to the playground/ directory based on the existing “Hello World” example. This provides a simple, reproducible environment to test the updated entry-resolution behavior.

**/worker-configuration.d.ts

# Webstorm
.idea/
Copy link
Contributor Author

@Zn4rK Zn4rK Nov 28, 2025

Choose a reason for hiding this comment

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

I can remove this if needed. I didn't find any obvious place for IDEs to place this under

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can keep it!

@Zn4rK Zn4rK force-pushed the entrypoint-from-node_modules branch from 4e7c6e1 to 2f89162 Compare December 1, 2025 07:51
@@ -0,0 +1,3 @@
import { initClient } from "rwsdk/client";

initClient();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok so this is what was needed for now - for the monorepo's playground example case because of workspace links - right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it would've been possible to change Document.tsx to link to it via packages/entrypoint/src/client.tsx, but I felt like this illustrated the flow better, since the idea was to use a file in node_modules as the worker entry.

@justinvdm
Copy link
Collaborator

Thank you for working on this @Zn4rK! Appreciate you taking time on the E2E test - I know it was a can of worms.

Will keep an eye out for when CI is green, let me know if it'd help for me to take a look as well.

"./worker": "./src/worker.tsx"
},
"dependencies": {
"react": "19.3.0-canary-fd524fe0-20251121",
Copy link
Contributor Author

@Zn4rK Zn4rK Dec 1, 2025

Choose a reason for hiding this comment

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

There should be a dependency to rwsdk in a "real" package.json, but in this monorepo it was very hard to get the e2e test suite to play along. TypeScript doesn't care, because the playground package entrypoint-from-node_modules has that dependency. And vite resolves the packages relative to the (playground) project, so it works without this.

Copy link
Collaborator

@justinvdm justinvdm Dec 1, 2025

Choose a reason for hiding this comment

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

I see. I guess its because in our e2e test setup, we create an isolated directory for the project and install rwsdk as a tarball there. We kind of need this to mimic users' application setup, rather than test in the less realistic scenario where rwsdk is a workspaced-linked package in the same monorepo. I can see why this makes it difficult to set up this playground's example though. It makes sense to leave it out here given this, thanks @Zn4rK

@justinvdm
Copy link
Collaborator

Update for posterity:

We're skipping the e2e test for this playground example. Our e2e infrastructure runs tests in isolated directories with rwsdk as a tarball (not workspace-linked), which makes testing node_modules scenarios in playground examples difficult. The change works in real-world usage (as confirmed by @Zn4rK), and the e2e tests pass locally, but testing it in our playground setup on CI requires workarounds that aren't worth the rabbit hole to get working right now. We'll revisit e2e testing for monorepo/package scenarios when we have more of these use cases.

For context, see the discussion on discord: https://discord.com/channels/679514959968993311/1443579628760334516/1445048899675885608

@justinvdm justinvdm merged commit c1033f6 into redwoodjs:main Dec 1, 2025
4 checks passed
@justinvdm
Copy link
Collaborator

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.

2 participants