Skip to content

Use the site's Functions directory #39

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

Merged
merged 1 commit into from
Nov 16, 2020
Merged

Use the site's Functions directory #39

merged 1 commit into from
Nov 16, 2020

Conversation

ehmicky
Copy link

@ehmicky ehmicky commented Nov 16, 2020

Fixes #27.

We just released in production the possibility for Build plugins to create a Functions directory even if the site does not have one.
Thanks to this, we can now use constants.FUNCTIONS_SRC in order to use the site's Functions directory.

It none was configured, the default Functions directory is used: this is named netlify-automatic-functions for the moment, but we will probably eventually rename it to netlify-functions (see issue).

@ehmicky ehmicky added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Nov 16, 2020
@ehmicky ehmicky self-assigned this Nov 16, 2020
index.js Outdated
// cpx.copySync('out_functions/**/*', FUNCTIONS_SRC);
cpx.copySync('out_publish/**/*', PUBLISH_DIR)
await makeDir(PUBLISH_DIR)
await Promise.all([pCopy('out_functions/**/*', FUNCTIONS_SRC), pCopy('out_publish/**/*', PUBLISH_DIR)])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parallelizing for better performance.

},
}

const DEFAULT_FUNCTIONS_SRC = 'netlify-automatic-functions'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to change this value once the final filename has been decided.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait does this need to be defined before FUNCTIONS_SRC is defaulted to it on 76? 🤔

Copy link
Author

@ehmicky ehmicky Nov 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because default parameters are evaluated when the function is executed, and onPostBuild() is executed after the top-level scope has been executed.

Copy link

@lindsaylevine lindsaylevine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇 ⭐ ❗

test/index.js Outdated
},
})

expect(await pathExists(`${resolvedFunctions}/function/index.js`)).toBeTruthy()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huge nit but could possibly be helpful for any devs new to the project:

could be helpful to have the fixture functions_copy_files be

out_functions/next_random/next_random.js
and
out_functions/next_random/nextJsPage.js

just to mimic exactly what NoN generates

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Fixed.

@ehmicky ehmicky merged commit 4b7208b into main Nov 16, 2020
@ehmicky ehmicky deleted the feat/functions-dir branch November 16, 2020 19:29
ascorbic pushed a commit that referenced this pull request Oct 14, 2021
serhalp pushed a commit that referenced this pull request Apr 5, 2024
* test: blob storage set and get

* feat: add test and update the handler

* chore: add some retry as it might get flaky through the stale thing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not configure to set build.command, build.functions and build.publish
2 participants