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

[Discussion] Absolute vs relative paths #20

Closed
radex opened this issue Sep 10, 2018 · 2 comments
Closed

[Discussion] Absolute vs relative paths #20

radex opened this issue Sep 10, 2018 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@radex
Copy link
Collaborator

radex commented Sep 10, 2018

Currently, most imports in 🍉 are absolute (i.e. import from 'Query'). This is mostly an artifact of the fact that it was extracted from a codebase of an app. But it's also very convenient when working on Watermelon.

But it adds A LOT of complexity, because every tool that has to understand the codebase has to be (often separately) configured:

  • Babel (for building) - [Discussion] Better dist format #22
  • Jest
  • Eslint (via eslint-babel)
  • Flow
  • Metro (for integration tests)
  • the app and Jest in an app importing Watermelon (we use Babel to rewrite for dist)
  • Flow in the app importing Watermelon (also using Babel but have to write a separate copy with Flow annotations — which has its own problems… - see [Discussion] Better Flow setup #21 )

I see 3 options:

  1. We keep the current setup (This is a big PITA)
  2. We give up and just change the absolute paths to relative paths.
  3. We meet halfway and change all paths to something like ~/blah or src/blah. I think it's not much better than 1. We still have to configure the same number of tools, it's just that there's one item in the config.

Personally I think it's easiest to go with (2). It's a little less convenient when refactoring, but I think overall a smaller maintenance burden. But I don't have experience with shipping NPM packages, and I don't know what other larger JS libraries do.

@radex radex added the help wanted Extra attention is needed label Sep 10, 2018
@satya164
Copy link

Facebook uses this kind of module system, haste? IMO relative paths are better, no confusion about where the module is, no configuration needed for tools etc.

@radex
Copy link
Collaborator Author

radex commented Sep 10, 2018

Facebook uses this kind of module system, haste?

Yeah, but haste is not exactly absolute paths, I think it searches the whole tree to find the right package. And haste is specific to Facebook tools, isn't universal

This was referenced Sep 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants