The service context

Foxx extends the module object with a special context property that
reflects the current service context.
As Webpack compiles multiple modules into a single file your code will
not be able to access the real module object provided by ArangoDB.

Externals

By default Webpack will attempt to include any dependency your code imports.
This makes it easy to use third-party modules without worrying about
filtering devDependencies
but causes problems when importing modules provided by ArangoDB.

Most modules that are specific to ArangoDB or Foxx reside in the @arangodb
namespace. This makes it fairly straightforward to tell Webpack to ignore
them using the externals option:

module.exports={// ...externals:[/^@arangodb(\/|$)/]};

You can also use this to exclude other modules provided by ArangoDB,
like the joi validation library:

Note: If your scripts are sharing a lot of code with each other or
the rest of the service this can result in some overhead as the shared code
will be included in each output file. A possible solution would be to
extract the shared code into a separe bundle.