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

No preview when using custom renderer with --root-dir=... #1633

Open
atrofimov-sc opened this issue Mar 30, 2024 · 5 comments
Open

No preview when using custom renderer with --root-dir=... #1633

atrofimov-sc opened this issue Mar 30, 2024 · 5 comments

Comments

@atrofimov-sc
Copy link

atrofimov-sc commented Mar 30, 2024

What's wrong?

When I use a custom renderer, I see nothing except a message saying it connected. It talks to a window that's in another tab via post-message, but doesn't have an iframe to talk to it!!

Steps to reproduce

Followed custom renderer tutorial. The only thing I changed was adding --root-dir=src/dev because by typescript rules, all *.ts files have to be under root, and the root is src, and I don't want the fixture to be bundled, so it's in src/dev folder. But that breaks the UI!

Screenshots

Screenshot 2024-03-29 at 8 12 22 PM

Useful info

  • Cosmos version. - latest

  • Cosmos config.

 "$schema": "http://json.schemastore.org/cosmos-config",
  "port": 5000,
  "rendererUrl": "http://localhost:5050",
  • Server terminal output.
[Cosmos] Using default cosmos config
[Cosmos] See you at http://localhost:5000
[Cosmos] Generated src/cosmos.imports.ts
[Cosmos] Generated src/cosmos.imports.ts
[Cosmos] Generated src/cosmos.imports.ts
[Cosmos] Generated src/cosmos.imports.ts
[Cosmos] Generated src/cosmos.imports.ts
[Cosmos] Generated src/cosmos.imports.ts
[Cosmos] Generated src/cosmos.imports.ts
  • Browser console output.

Empty

Additional context

N/A

I think it's supposed to open a iframe, but there aren't any iframe at all in the cosmos UI.

@atrofimov-sc atrofimov-sc changed the title No preview when using custom renderer. No preview when using custom renderer with --root-dir=... Mar 30, 2024
@ovidiuch
Copy link
Member

Hi @atrofimov-sc, sorry for all the confusion, I guess the custom bundler guide could be improved but there are so many variations in user setup and this is not a trivial task. The easiest thing to get past this step is if you provided a public repo that reproduces your setup (and the issues you are facing). I'll be able to clone it and tell you exactly what's missing. Let me know if you can provide this, thanks!

@atrofimov-sc
Copy link
Author

I'll try to do a repro, but time is hard to come by right now.

I'll say I'm still able to use the product by specifying "rootDir": "src", in the config. Though the cosmos.imports.ts is still in the wrong folder (would like it to be under src/dev). The erroneous behavior only if the --rootDir setting is set via a flag.

@ovidiuch
Copy link
Member

ovidiuch commented Apr 2, 2024

@atrofimov-sc Did you try setting exposeImports to "dev/cosmos.imports.ts" in your Cosmos config?

https://reactcosmos.org/docs/configuration/cosmos-config#config-options

@atrofimov-sc
Copy link
Author

Yes I have. I'm sorry for still not having done a repro, but the full command was cosmos --expose-imports --rootDir=src. When I specify these in the cosmos.config.json instead of the CLI, it works. That's what I'm doing now.

@ovidiuch
Copy link
Member

ovidiuch commented Apr 2, 2024

If for whatever reason you prefer passing those options via CLI args you can also pass a path to --expose-imports like you do to --rootDir.

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

No branches or pull requests

2 participants