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

Improve local js dev experience #1914

Open
pascallaliberte opened this issue Apr 20, 2022 · 6 comments
Open

Improve local js dev experience #1914

pascallaliberte opened this issue Apr 20, 2022 · 6 comments
Assignees

Comments

@pascallaliberte
Copy link
Member

Currently, the instructions for local js development instruct to use yarn link.

However, yarn link doesn't install package dependencies like a yarn add does, causing us to require to temporarily yarn add each of the dependencies of an npm package we work on in the parent project from which we test our npm package.

@pascallaliberte
Copy link
Member Author

This problem has been signalled to yarn for a few years now without any movement on the proposal.

The main option is to use yalc as a devDependency, which fakes yarn pack and yarn publish locally, causing the parent project to properly install dependencies of npm packages being worked on.

Since we rely on the parent project (bullet_train) to test out our javascript in system tests, this might be the best way to work.

@pascallaliberte
Copy link
Member Author

yalc adds a bit of complexity to the development process, but that complexity could be abstracted away with bin/release and bin/develop scripts.

However, there doesn't seem to be an automated way to do something like yarn build --watch with yalc (unless maybe wiring into one of --watch's own callbacks).

The other option is to use yarn workspaces for all gem/npm packages. This would mean bringing back into the main repo the separate gems, and host them as sub-directories.

ActionCable (both the actioncable gem and the actioncable npm package) has its source code stored as a workspace under the main rails/rails project. yarn links's limits might just be the reason why they chose to use a workspace instead of a separate repo.

But bringing back all the gems' source code into the bullet_train starter repo just because yarn is broken for properly installing yarn link'ed package dependencies? That seems like a stretch.

So I'll proceed with yalc.

@pascallaliberte
Copy link
Member Author

I tried an alternative: inline all dependencies using microbundle --external none (rationale in microbundle docs) but only in dev, while still using yarn link.

Nope. Still getting this garbage:
CleanShot 2022-05-02 at 16 48 28@2x

@pascallaliberte
Copy link
Member Author

pascallaliberte commented May 2, 2022

As for running yarn build --watch and stringing yalc push after a build, we might want to check out npm-watch.

@pascallaliberte
Copy link
Member Author

pascallaliberte commented May 6, 2022

So I just tested with yalc and it solves the problems with dependencies.

The process (very manual for now):

In the gem/npm package, build and publish locally:

yarn build
yalc push

In the upstream package:

# the first time
yalc link <npm package name>

# subsequent times a call to `yalc push` from the npm package will update all local linked installs of the package.

To automate this all, bin/develop can be setup easily to handle all this.

@jagthedrummer
Copy link
Contributor

I transferred this issue from the old bullet_train-base repo. I'm not sure how many of the finer details here are still relevant, but I do know that developing & testing the JS portion of some of the gems is still not the smoothest experience. It would be nice to make it better.

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