rescript-lang / rewatch

Rewatch is an alternative build system for the Rescript Compiler.
97 stars 13 forks source link

Duplicate files handling #14

Closed fhammerschmidt closed 1 year ago

fhammerschmidt commented 1 year ago

Thank you very much for trying to tackle the ol' ReScript workspace repo problem.

I was excited to try it out, but encountered an error as soon as a ran yarn rewatch build .. It gave me

[2023-03-22T10:38:51Z ERROR rewatch::build] Duplicate files found for module: ChatAttachmentView
[2023-03-22T10:38:51Z ERROR rewatch::build] file 1: /Users/florian-cca/workspace/alert/node_modules/app-web/src/chat/ChatAttachmentView.res
[2023-03-22T10:38:51Z ERROR rewatch::build] file 2: /Users/florian-cca/workspace/alert/node_modules/app-mobile/src/chat/ChatAttachmentView.res

It seems like you still require unique filenames over all packages? It would be cool if that was supported, then rewatch would basically be a drop-in replacement since otherwise our repo structures are pretty similar to your testrepo.

rolandpeelen commented 1 year ago

Could you try enabling namespacing to the packages to see if it works then?

fhammerschmidt commented 1 year ago

Yes, at least it makes some progress.

ReScript (v10.1.3) gives me some other curious errors though:

We've found a bug for you!
/Users/florian-cca/workspace/alert/node_modules/rescript-material-ui/src/Number.res

You referred to the module mui, but we've found one called Mui instead.
Is the name's casing right?

We've found a bug for you!
/Users/florian-cca/workspace/alert/node_modules/rescript-react-native/src/elements/Ref.res

You referred to the module react-native, but we've found one called React-native instead.
Is the name's casing right?
rolandpeelen commented 1 year ago

@fhammerschmidt - Did you get this to work on your side? I think the bits you are referring too may be something orthogonal to the build system. Perhaps Rescripts bs-build is a bit more flexible in this regard?

fhammerschmidt commented 1 year ago

I did not.

But after reading your question I found out that the above error only happens with dependencies that use the namespace field themselves. They all also set the namespace manually as a string. I tried to get rid of those errors by changing the namespace field in the bsconfig of the respective dependencies to the module name that was found. So e.g. in rescript-react-native there is

{
  "namespace": "react-native",
}

which I changed to

{
  "namespace": "React-native",
}

and that got rid of the error.

I feel like rewatch somewhere unnecessarily capitalizes some module/namespace name.

rolandpeelen commented 1 year ago

Ok - check! Thanks for the information. It seems we were handling this case correctly for namespace: true, and capitalised correctly, but not when the names where specified. I'll close this once we push a new release :)

rolandpeelen commented 1 year ago

Should be fixed in: https://github.com/rolandpeelen/rewatch/releases/tag/0.0.10 - please let us know if it work @fhammerschmidt - and thanks for the info :)

fhammerschmidt commented 1 year ago

Thank you for fixing it. Will try again soon.