koenbok / Framer

Framer - Design Everything
https://framer.com
MIT License
5.83k stars 477 forks source link

Support for modules folder containing subdirectories #575

Closed samjt closed 6 years ago

samjt commented 6 years ago

Issue Framer's build scripts do not support subdirectories in the modules folder, meaning all modules have to be at the top level of the folder.

Suggested Behaviour It would be great if we could create subdirectories for modules so that it become easier to manage dependencies and/or collections of classes.

It appears that the bundler does already support subdirectories; but only if using node_modules I realise that some of this might be to avoid naming collisions and circular dependencies but it would be super helpful for us as we build out a fairly extensive library of components and behaviours.

Exploratory Work I had a look in make.pyc (decompiled it) and it seems that it's this function

def should_include(filepath):
    if os.path.splitext(filepath)[1] not in ('.coffee', '.js'):
        return False
    # return None.path.getsize(filepath) > 0 # <-- This Bit!

If I instead do this:

    #splitext doesn't deal with files that start with .
    file_paths = filter(lambda file: not file in ('.DS_Store'), file_paths) 
    file_paths = filter(lambda file: os.path.splitext(file)[1] in ('.coffee', '.js'), file_paths)

then it compiles successfully (using python make.py modules test.js)

I've tried replacing framer.modules.js in a project with my compiled output and it appears to work (in the browser, I can't open it in Framer itself without it getting recompiled I'm guessing).

I'm assuming there's a reason that you decided to exclude paths deeper than the modules directory though?

I would open a PR, but a) this isn't in the public repo and b) I have no idea what I'm doing in Python :)

samjt commented 6 years ago

Ok, so this turns out not to be an issue. There was something odd happening with my project that led me to believe subdirectories didn't work and I appear to have wasted my time...