-
Notifications
You must be signed in to change notification settings - Fork 63
feat: extract runtime-handler and lazyLoading (#252) #271
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
Conversation
77eefc3
to
981b3b1
Compare
981b3b1
to
f0ac4c0
Compare
- [email protected] - @twilio-labs/[email protected] - @twilio-labs/[email protected] - @twilio/[email protected] - @twilio-labs/[email protected] - @twilio-labs/[email protected] - [email protected]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the most part, this is a copy of twilio-run functionality to runtime-handler and that all seems fine to me. Bringing the lazy loading option in looks just fine to me.
We are duplicating some types, which I wonder if we could bring together somewhere.
And there are some unused dependencies in runtime-handler, which we could remove before publishing.
Otherwise, good lift here!
@@ -0,0 +1,88 @@ | |||
export type SearchConfig = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runtime-handler
is now exporting some duplicate types that also live in serverless-api
or twilio-run
. Should they be consolidated somewhere?
Also in serverless-api
:
SearchConfig
, AccessOptions
, ServerlessResourceConfig
, ServerlessResourceConfigWithFilePath
Also in twilio-run
:
EnvironmentVariablesWithAuth
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is the way the dependency chain works. twilio-run
should rely on serverless-api
and runtime-handler
(at least during compile time) but runtime-handler
shouldn't rely on twilio-run
. And similarly I didn't want runtime-handler
to rely on serverless-api
since runtime-handler
can be different from user to user during runtime so it should be self-contained in general
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact you'll see that runtime-handler is only a devDependency in twilio-run because I do import type
as opposed to import
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could runtime-handler take serverless-api as a devDependency and do import type
too then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately not because some of these are part of ServerConfig
which is exported by runtime-handler
. Realistically the only thing we could do is to move it into a common dependency that all of them consume. But realistically they are all part of ServerConfig
which is basically the "contract" for runtime-handler. So I could see scenarios where they could diverge slightly from the other use cases.
I was able to remove SearchConfig
though since it's not being used anymore.
import { join } from 'path'; | ||
|
||
export function requireFromProject(projectDir: string, packageName: string) { | ||
return createRequire(join(projectDir, 'node_modules'))(packageName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will still fallback to the version installed by twilio-run
if there isn't an explicit dependency on twilio
in the project, right? And that is the intention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the fallback more explicit now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you pushed? The last commits I can see are from 13 days ago.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I was changing around logic afterwards. It's now up-to-date
Replaced with a looser test based on the content at the start of the error message that should be thrown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is looking good!
This change introduces the following features:
@twilio/runtime-handler
@twilio/runtime-handler
to bring parity with the 1.1.0 release in Functionstwilio
package instead of the one from the Serverless ToolkitContributing to Twilio