Duplicate JS files

My project seems to have acquired duplicated (or nearly duplicated) JS files: “migrant.js” and “Migrant-migrant.js”. I know I could delete one and try to find out what breaks, but I’d rather understand what happened so I can proceed more sensibly.

My project orignally contained “migrant.js”. Later, I added a user component (“Migrant”) that contained its own “migrant.js”. My guess is that the latter action resulted in the creation of “Migrant-migrant.js”. Am I on the right track? Does the use of a User component always result in the creation of “Component-script.js” files for each .js in the component?

I did check the documentation and this forum, to no avail.

Did you import HTML at any point? That would be my only guess

Thanks for the reply! No, I didn’t import HTML (unless using a User component counts).

Ok, so if it not imported HTML then it will be the user component, when you save something as a component it asks you which CSS, Images and JS files should be saved with it.

Its likely you saved the JS file as part of the component and so importing it added multiple JS files named this way.

Usually when you import a file with the same name, BSS renames it with a “-1” but maybe it’s different when you import a component? If you open both files in the editor, are the contents identical?

Yeah, this is the behaviour that confuses me, usually it appends a 1, 2, 3 ect to duplicate files with the same name

I stopped being lazy and did some actual “work”. I created a user component called UserComponentName, which contained user-component-styles.css and user-component-script.js. When I used that component in a different project, UserComponentName.css and UserComponentName-user-component-script.js were added to the project. I think that this demonstrates how BSS names CSS and JS imports for user components. Interestingly, the CSS and JS renaming approaches differ from each other, and neither case exactly matches the name of the corresponding file in the project in which the user component was defined.

1 Like

Seems very odd. @martin any thoughts?