Using Webpack with Foxx

    Because the ArangoDB JavaScript environment is largely compatible with Node.js,the starting point looks fairly similar:

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

    1. const { context } = require("@arangodb/locals");

    This object is identical to module.context and can be used asa drop-in replacement:

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

    1. // ...
    2. externals: [/^@arangodb(\/|$)/]
    3. };

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

    As far as Webpack is concerned, scripts are additional entry points:

    1. const path = require("path");
    2. context: path.resolve(__dirname, "src"),
    3. entry: {
    4. main: "./index.js",
    5. setup: "./scripts/setup.js"
    6. }