Skip to content

Fix flag for generating userdeps in custom build setup guide#1450

Merged
ovidiuch merged 1 commit intoreact-cosmos:mainfrom
lr0pb:main
Apr 21, 2023
Merged

Fix flag for generating userdeps in custom build setup guide#1450
ovidiuch merged 1 commit intoreact-cosmos:mainfrom
lr0pb:main

Conversation

@lr0pb
Copy link
Contributor

@lr0pb lr0pb commented Apr 21, 2023

I tried to use Cosmos with custom bundler setup and run into issue that --generate-userdeps flag mentioned in customBundlerSetup.md does not generate file. Later I find in Troubleshooting section of readme, that same behavior mentioned to fix with --external-userdeps flag. Tried this one and it works, so I filled this PR to fix flag name in custom bundler setup guide :)

Btw, overall experience in using it with custom bundler goes smooth, I used it with Parcel. Thanks for your awesome work! 🥇

@ovidiuch
Copy link
Member

@lr0pb Awesome, thanks for this! :)

I've been thinking about renaming the --external-userdeps flag lately to something simpler but I haven't reached a conclusion yet (ideas welcome). In any case if I do rename it in a future release I'll send you a mention to let you know.

Btw, overall experience in using it with custom bundler goes smooth, I used it with Parcel. Thanks for your awesome work! 🥇

🤘

@ovidiuch ovidiuch enabled auto-merge (squash) April 21, 2023 10:54
@ovidiuch ovidiuch merged commit 799e71f into react-cosmos:main Apr 21, 2023
@lr0pb
Copy link
Contributor Author

lr0pb commented Apr 21, 2023

@skidding Well, if I right understand - without this flag same userdeps file or something related generated under the hood? In this case, it could be like --expose-userdeps or --export-userdeps or really --generate-userdeps ><
If flag mainly suited to use with custom bundler, it could be --custom-bundler / --custom-renderer or same variants with with- prefix (--with-custom-renderer)

@ovidiuch
Copy link
Member

@skidding Well, if I right understand - without this flag same userdeps file or something related generated under the hood? In this case, it could be like --expose-userdeps or --export-userdeps or really --generate-userdeps >< If flag mainly suited to use with custom bundler, it could be --custom-bundler / --custom-renderer or same variants with with- prefix (--with-custom-renderer)

Yeah, that's correct. When you use a plugin like the Vite or Webpack ones they call generateUserDepsModule() directly and inject it as a module under the hood, so no need to write the module on disk anymore.

Thanks for the suggestions!

@ovidiuch
Copy link
Member

@lr0pb Got around to refactoring the "userdeps" module and flag.

  • I liked your "expose" suggestion and decided to call it --expose-imports.
  • Also renamed the file from cosmos.userdeps.js to cosmos.imports.js. I think the new name is more intuitive.
  • If you have TypeScript installed a TS module will be generated instead as cosmos.imports.ts.
  • You can override the path under exposeImports cosmos config option or by passing a value to the CLI arg: cosmos --expose-imports custom-imports-file.js.

Already changed in 6.0.0-alpha.17 or react-cosmos@next.

@lr0pb
Copy link
Contributor Author

lr0pb commented Apr 27, 2023

Thank you, got it!
I am also found several other things today, will file issues for them

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.

2 participants