📦 Using external libraries


I am following the next tutorial https://github.com/OpenZeppelin/defender-autotask-examples/tree/master/rollup.

I have succesfully put the example in my project and is running properly. In the index.js file generated I can see the methods related to is-odd package.

Now I am trying to use Firestore from Google Firebase but unfortunately the methods from the next packages that I call in my index.ts script are not included within the index.js file:

"firebase": "9.14.0",
"firebase-admin": "11.3.0",

Could you help me out?

Thanks in advance.

Best regards,
Pedro Reyes.

Hi @Pedro_Reyes -

I have not used Google Firebase before, but off the cuff it sounds like there it probably some issue with the way your package is being bundled. Perhaps the bundle was not re-built (with that repo you would need to run npm run build) after adding those dependencies? Or maybe there are configuration settings you could change.

Hope that's helpful and best of luck working through these bundling issues.

Dan McKeon

Hello @dan_oz ,

I do execute the next command everytime npm run build && npm run start. Addionally the index.js file generated is executed succesfully and I am able to add some data in Google databases through Firestore from Google Firebase. Here is the rollup output:

$ npm run build && npm run start

> defender-rollup-demo@1.0.0 build
> rollup -c

src/index.ts → dist/index.js...
created dist/index.js in 5.9s

Taking into account the next package.json config file:

  "name": "defender-rollup-demo",
  "version": "1.0.0",
  "main": "dist/index.js",
  "license": "MIT",
  "scripts": {
    "build": "rollup -c",
    "start": "node dist/index.js"
  "devDependencies": {
    "@rollup/plugin-commonjs": "^16.0.0",
    "@rollup/plugin-json": "^4.1.0",
    "@rollup/plugin-node-resolve": "^10.0.0",
    "@rollup/plugin-typescript": "^6.1.0",
    "@types/is-odd": "^3.0.0",
    "builtin-modules": "^3.1.0",
    "rollup": "^2.33.3",
    "tslib": "^2.0.3",
    "typescript": "^4.1.2"
  "dependencies": {
    "@openzeppelin/contracts": "4.7.3",
    "defender-autotask-client": "1.37.0",
    "defender-relay-client": "1.37.0",
    "defender-sentinel-client": "1.37.0",
    "dotenv": "^8.2.0",
    "ethers": "5.0.3",
    "firebase": "9.14.0",
    "firebase-admin": "11.3.0",
    "is-odd": "^3.0.1",
    "web3": "1.2.9"

I have included in the rollup.config.js file the dependencies:

import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import json from "@rollup/plugin-json";
import builtins from "builtin-modules";

export default {
  input: "src/index.ts",
  output: {
    file: "dist/index.js",
    format: "cjs",
  plugins: [
    resolve({ preferBuiltins: true }),
    json({ compact: true }),
  external: [

It seems that these modules are not treated properly by Rollup.js as it states here treating-module-as-externa-dependency and you need to use node-resolve.

Do you guys have an example how to do this or could help me out in this matter? It is a bit limited the number of libraries included by default in Defender so having an example of this would resolve dependencies that might arise between Defender and other API services.

Thanks in advance for any help you can provide @dan_oz .

Best regards,
:fire: Pedro Reyes :fire: