msurdi / frontend-dependencies

Copies node packages to a directory where your frontend tools will be able to find them
24 stars 5 forks source link

Isomorph #16

Closed FelixFurtmayr closed 4 years ago

FelixFurtmayr commented 4 years ago

@msurdi could you review this pull request? I did several things

FelixFurtmayr commented 4 years ago

yeah - it looks a bit complicated. the thing is the following:

We seem to need this procedure. Thank you very much about your comment. I thought once more about the thing - if there is an easier way:

other options

1) we just could skip the regular npm install

Maybe use "npm run install" - run only our modified script verion of the install, and do only one npm install, that we controll. then we just could use the "dependencies" object and put our additional copy options in. all dependencies can just be stored under node_modules and can be used in the backend as well as the frontend. I don't like the idea so much, since you cannot type then the familiar "npm i".

2) specify only the copy task separate in the frontend dependencies section

Very similar to my current implementation. We put our packages under "dependencies" in the package.json, and specify a copy task in the frontendDependencies section (like I do now for the isomorph option) separate. The bad thing is: we have two places in the package.json for every package. I don't like this idea, since it provokes mistakes.

3) use our current install as "tmp" folder

We just copy our packages from our subfolder back into the node_modules folder. Then the subfolder would be only a temp folder as help to ensure, npm is running correct. All code is then also available in the backend.

I think option three is good. Just copy all our packages back. Sounds easy (easier than what I added) to me. What do you think?

msurdi commented 4 years ago

Honestly, I'd just leave the user to run a regular npm install and have our copy-to-frontend-dir to run as a postinstall task for whatever he wants to use in the frontend dir. I think this was more or less the original idea of the project...a pretty simple copy of files to a custom directory, even if the drawback was that you had to keep in dependencies things not really used for the backend.

Now, you've already worked on this project more than me, and probably nowadays you're also using it more than me too. So feel free to go in any direction that suits your use case better, I'm happy with whatever solves your problem.

Having said that, from your three options I think I lean more towards 2)... 1) just breaks the normal workflow everyone would expect, and in 3) I'm not sure mangling node_modules internals won't cause more troubles and inconsistencies, I think that road might be full of corner cases.

Again, just my opinion/suggestions/feedback, you're leading this nowadays.

Edit: typos...

FelixFurtmayr commented 4 years ago

After rewriting the stuff I'm really for option three: No current changes on how it works for the user - except that all stuff is also available in the backend. Please have a look.