vastec / ember-unused-components

Search for unused components in your Ember project
51 stars 12 forks source link

No output for pods components #14

Closed richard-viney closed 4 years ago

richard-viney commented 5 years ago

Hi,

Just trying out this neat addon and so far all I can get out of it are zeros!

The app has ~100 components under ./app/components, which use the pods structure. The rest of the app uses the classic layout for routes, controllers, and so on, i.e. it only use the pod structure for components.

config/environment.js sets podModulePrefix to an empty string.

Running yarn ember-unused-components --pods gives:

 No. of components: 0
 No. of unused components: 0 

 Congratulations! No unused components found in your project.

I'll try to find some time to troubleshoot the problem next week. My understanding is that this is expected tot be supported already, is that correct?

Many thanks.

tniezurawski commented 5 years ago

I thought I handled that case by giving --pods argument which tells my script that PODs structure is in use. Because there is no way I can understand that PODs are used if there is nothing I can handle on (like podModulePrefix in config/environment.js).

But unfortunately, that didn't work! :( I still made some wrong assumptions.


Anyway, I think I have a fix that will make it work. In case of lack of podModulePrefix I'll try to guess based on app/components content 😄 I managed to replicate your issue and it seems that new strategy works.

Expect a new version tomorrow.

tniezurawski commented 5 years ago

@richard-viney Checkout version 1.0.3. I hope it's fine now :)

richard-viney commented 5 years ago

Thanks for the update!

Unfortunately, running 1.0.3 I still get zero components reported. The command being run is yarn ember-unused-components --pods. The component templates are all found at app/components/<component-name>/template.hbs.

Route templates are all still in the 'classic' location, i.e. app/templates/....

Thanks.

tniezurawski commented 5 years ago

@richard-viney Hmm... could you do me a favor and visualize the structure of your app? You can do it with tree tool. It should be available in any OS.

So if you run tree in your-app-name/app/ you should see something like this: pods-structure-example.txt

I'll add missing cases to tests and fix it.

richard-viney commented 5 years ago

Thanks, this is the abbreviated app structure:

app
├── adapters
│   ├── application.ts
│   ├── ...
├── app.ts
├── components
│   ├── sign-in
│   │   ├── component.ts
│   │   ├── styles.scss
│   │   └── template.hbs
│   ├── ...
├── config
│   └── environment.d.ts
├── controllers
│   └── ...
├── helpers
│   ├── ...
├── index.html
├── resolver.ts
├── router.ts
├── routes
│   ├── ...
├── styles
│   ├── ...
├── templates
│   ├── application.hbs
│   ├── ...
jkeen commented 4 years ago

Ah, there's the problem. Typescript. We're not looking at typescript right now.

richard-viney commented 4 years ago

Closing this old issue.

Jut a note though that v1.2.0 does appear to find components written in TypeScript, however the app I'm testing on uses the new Octane component file layout which appears not to be supported?

In this case the tree structure is:

── components
│   ├── sign-in
│   │   ├── index.ts
│   │   ├── styles.scss
│   │   └── index.hbs
...

Running ember-unused-components finds the components but incorrectly reports almost all of them as being unused.

eliel-jr commented 3 years ago

Today i'm installed and running ember-unused-compoents with --pods, but gives:

[1/3] �️ Mapping the project... [2/3] � Looking for components usage... [3/3] ✔️ Done

No. of components: 0 No. of unused components: 0

Congratulations! No unused components found in your project.

i'm have podModulePrefix config in config/environment.js.

this is my project structure: pods-structure.txt

tniezurawski commented 3 years ago

@eliel-jr That's odd 🤔 I hope to find some time this week to tackle that. Thanks for uploading the structure. It will help me a lot 🙌

eliel-jr commented 3 years ago

news for this? please re-open issue