Skip to content

Crawl up directories to find config, to support monorepos #92

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

Closed
wants to merge 1 commit into from

Conversation

chrbala
Copy link

@chrbala chrbala commented Jan 1, 2019

This change will crawl up the directories to find the first netlify.toml relative to the current working directory, instead of just testing the current directory. This is important for monorepos because the netlify servers expect the netlify.toml in the root directory. If the command is run with the current working directory set to monorepo package like packages/my-package, the command will currently fail to find a config file.

It's possible that the .babelrc portion of this change could break existing workflows where there are environments with an incompatible .babelrc file in a parent directory.

@swyxio
Copy link
Contributor

swyxio commented Jan 1, 2019

thanks for filing this! next time file an issue first so that you dont do unnecessary work :)

i like this myself, however netlify-lambda's goal is to serve as local emulation of Netlify Functions, and they don't do the crawl yet. Monorepo support is a highly requested topic for our Platform team and I'm sure they are considering it. I would love to merge this as soon as that is done.

cc @fool @bcomnes

@chrbala
Copy link
Author

chrbala commented Jan 1, 2019

So actually in my setup, this would closer emulate the Netlify Function build servers. I have been using a bit of a workaround thus far because of this.

# netlify.toml
[build]
  # other parms omitted
  functions = "packages/lambda/build"

[context.deploy-preview]
  environment = { API_INTROSPECTION = "true" }

[context.branch-deploy]
  environment = { API_INTROSPECTION = "true" }
# packages/lambda/netlify.toml
[build]
  functions = "build"

In my case right now, the netlify-lambda build command is run in packages/lambda, so I have to create a dummy netlify.toml file that is never seen by the build server.

If you're particularly opposed to crawling up the file structure, we could use an environment variable that specifies the root where config.js should look for the config file. But in that case, people would have to figure out how to provide the root path to the environment when running locally. I personally have a way of doing this, but it will be inconvenient for those who don't already have a setup that allows this.

@swyxio
Copy link
Contributor

swyxio commented Jan 2, 2019

yeah. thats what i do too. i'm not opposed to crawling up the file structure, i'm just trying not to add functionality in netlify-lambda that isn't replicated in production Netlify Functions. lets see what the support/product team says if anything.

@schiehll

This comment has been minimized.

@swyxio

This comment has been minimized.

@schiehll

This comment has been minimized.

@swyxio

This comment has been minimized.

@schiehll

This comment has been minimized.

@swyxio
Copy link
Contributor

swyxio commented Jan 10, 2019

ok so we have merged the babel crawling in #98 but NOT the netlify.toml crawling for reasons discussed above. closing for now, but further debate still welcome if you disagree/have more solutions.

@swyxio swyxio closed this Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants