kiliman / remix-flat-routes

Remix package to define routes using the flat-routes convention
MIT License
640 stars 22 forks source link

co-located assets break migrate-flat-routes #124

Closed akomm closed 1 month ago

akomm commented 1 month ago

Made a test run: npx migrate-flat-routes ./app/routes ./app/routes-hybrid --convention=hybrid

Apparently when route folders have co-located assets like for example an svg file, it throws: Invalid route module file: app/routes/some-route/some-asset.svg

remix: 2.9.1 remix-flat-routes: 0.6.5 node: v18.18.2

I might need add some note: I know I could add the file to ignore, but its not some ad-hoc ignored file and can't possibly be confused as a route by remix.

It would also be better if the migration would move files that are not ts/tsx, that are part of the app, not just some generated ad-hoc file, instead of ignoring them.

akomm commented 1 month ago

I take it back, it seems like neither ignoring it via remix's nor flatRoute's or both ignoredRouteFiles avoid the error. Tried both **/*.svg and even explicitly: ./app/routes/some-route/some-asset.svg. The issue persists.

~Seem like the issue comes from the v1-route-convention's createRoutesFromFolders.~

NVM its mapped correctly

Is it possible, that the script does not take remix.config.cjs (commonjs)?

kiliman commented 1 month ago

Sorry. It looks like my script expects it to be remix.config.js

https://github.com/kiliman/remix-flat-routes/blob/59c67f9df83155512eb84b2c872fe14513e627b1/src/migrate.ts#L33-L40

akomm commented 1 month ago

If you don't mind I close it. I've done some quick auto refactor myself of around 300 files/folders but wasn't that hard actually because there was a pattern.