Open benawad opened 4 years ago
From this:
src/
├── index
│ ├── header
│ │ └── button.ts
│ └── header.ts
└── index.ts
to this:
src/
├── header
│ └── button.ts
├── header.ts
└── index.ts
?
I mean, why not. But I think we must implement this under a config option / cli flag and not make it the default.
But I think we must implement this under a config option / cli flag and not make it the default.
How come?
In a single entry point folder (like our src
folder on Destiny's codebase) why not, but I'd be the chaos on a multiple entry points folder. For example, when using Destiny on sub folders of src
this approach may not fit since each folder have multiple entry points (e.g. a components
folder).
I think Destiny should be able to run on any kind of js / js-like codebase without any issue and then be configurable to suit the user's preferences
How does it break down for multiple entry points?
Current output:
components/
├── header
│ ├── wrapper
│ │ └── uniqueButton.js
│ └── wrapper.js
├── footer
│ ├── links
│ │ └── link.js
│ └── links.js
├── header.js
└── footer.js
Your proposal output:
components/
├── wrapper
│ └── uniqueButton.js
├── links
│ └── link.js
├── wrapper.js
├── links.js
├── header.js
└── footer.js
How can you find out which file is dependent on whom?
Also, what if both footer.js
and header.js
has a deps with the same name e.g. layout.js
(not a shared deps, just the same file name). We'd need to rename these two files so they can be in the same folder.
What do you think of collapsing it only if the folders name is index
?
I'm not sure. Some apps name their entry point main.js
, app.js
, server.js
, etc... I don't know if it's a good idea to do something specific based on a file's name (except for ignoring folders / files like node_modules or something).
I still think we should do this as a flag / config option.
We may need something like a destiny init
to ask this kind of questions though.
Or else, we can detect if there's one single file at top level. It seems pretty obvious but it didn't click until now...
src/
├── [name]
└── [name].*
Then why not. But with this, I think we should also give an option to the user so he can disable this feature if he wants to.
But I'm not sure how we'll deal with shared deps. Shall we do this only if there's no shared
folder at top level, or merge it with the one that will be moved to top?
If we merge them, what about duplicated files name? Shall we throw a warning that we can't bring everything to top level because two files have the same name? Or maybe we can rename one of the two?
that's a good point, I think merging is probably the right choice, but I'll think on this.
its weird to have a folder called
index
so just bring up all the files in it one level