Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lambda file structure #53

Open
ro-savage opened this issue Jan 30, 2018 · 3 comments
Open

Lambda file structure #53

ro-savage opened this issue Jan 30, 2018 · 3 comments

Comments

@ro-savage
Copy link

I recently encountered the issue around the folder structure that optimize creates and trying to access things on the file system (#32).

I was wondering why it makes that structure at all, rather than your function and files being uploaded directly into the root of each lambda?

Is there a specific reason?

@goncaloneves
Copy link
Contributor

Hi @ro-savage.

Reason of doing that is not break usage of fs in code. This plugin doesn't scrape and change file system paths in the code, so one example is that if you would have the function handler deep into a folder and use fs to fetch a file at runtime in the service folder, you wouldn't be able to do that by having it at the same level.

@thebrianbug
Copy link

It's been a long time, but #32 is definitely a wart on an otherwise amazingly pleasant plugin. Is this plugin still maintained?

It would be ideal if static assets could be referenced via require('./relative/path/file.json') as well as import equivalent. I'd rather the file be copied in two places if the concern is to preserve fs access. Needed to rewrite all imports in a large mono-repo is a big letdown. For those who don't want two copies maybe having a new configuration option with the asset copy strategy would be ideal (preserve fs access, preserve relative import access, or both - which would make 2 copies).

Let me know if this might be an acceptable solution!

@goncaloneves

@thebrianbug
Copy link

What I'd consider doing is deploying the function code to the root of the lambda, or in other words not nesting code in the _optimize folder for a deployment. I agree with @ro-savage, needing to use a nested temporary folder is quite strange in the deployment and breaks code from not having the same root directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants