Skip to content

Add support for app-level code #576

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 2 commits into from
Apr 22, 2022
Merged

Add support for app-level code #576

merged 2 commits into from
Apr 22, 2022

Conversation

ejizba
Copy link
Contributor

@ejizba ejizba commented Apr 15, 2022

Users can specify an entry point file as the main field in their package.json and we will load the file during worker initialization. The file can be used to run any arbitrary app-level code (as opposed to function-level code), but I expect the most common scenario is to register hooks and eventually functions.

A few notes:

  • I handle commonjs vs es6 the exact same way we already do it for function-level files
  • The npm docs say "If main is not set it defaults to index.js in the package's root folder.", but I worry users may have a random "index.js" field in the root of their app already because it's such a common name. Instead, I decided to make the feature opt-in only, meaning users have to explicitly add the main field if they want the entry point file to be loaded

Fixes #537

@ejizba ejizba requested review from alrod and hossam-nasr April 15, 2022 22:45
Copy link
Contributor

@hossam-nasr hossam-nasr left a comment

Choose a reason for hiding this comment

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

Looks good! Just left a few comments/questions

@ejizba ejizba merged commit 5acb352 into v3.x Apr 22, 2022
@ejizba ejizba deleted the ej/entryPoint branch April 22, 2022 20:31
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.

Add entrypoint for app-level code
2 participants