async pack() {
    // Save the shim package in .serverless just like the service package
    const zipFilePath = path.join(
      this.serverless.serviceDir,
      '.serverless',
      `${this.serverless.service.service}.zip`,
    )

    logger.debug(`Packing shim file into ${zipFilePath}`)

    let shimFileContents
    try {
      /**
       * The shim.min.js file is built when the binary is built
       */
      shimFileContents = await fs.promises.readFile(
        path.join(__dirname, 'shim.min.js'),
      )
    } catch (e) {
      console.error(e)
      throw new ServerlessError(
        'Failed to build dev mode shim',
        'BUILD_SHIM_FAILED',
        { stack: false },
      )
    }

    try {
      const zip = archiver.create('zip')

      // Create the directory structure if it doesn't exist
      fs.mkdirSync(path.dirname(zipFilePath), { recursive: true })
      const output = fs.createWriteStream(zipFilePath)

      return new Promise(async (resolve, reject) => {
        output.on('close', () => {
          return resolve(zipFilePath)
        })

        output.on('error', (err) => {
          logger.debug('Output file error')
          return reject(err)
        })

        zip.on('error', (err) => {
          logger.debug('Zipper error')
          return reject(err)
        })

        output.on('open', async () => {
          zip.pipe(output)

          // Add the bundled shim file contents to the zip file
          zip.append(shimFileContents, {
            name: 'index.js', // This is the name expected by the handler. If you change this, you must change the handlers config below.
            date: new Date(0), // necessary to get the same hash when zipping the same content
          })

          logger.debug('Finalizing zip file')

          await zip.finalize()
          this.serverless.service.package.artifact = zipFilePath

          this.serverless.service.getAllFunctions().forEach((functionName) => {
            const functionConfig =
              this.serverless.service.getFunction(functionName)
            functionConfig.package = {
              artifact: zipFilePath,
            }
          })
        })
      })
    } catch (e) {
      logger.error(e)
      throw new ServerlessError(
        'Failed to zip dev mode shim',
        'ZIP_SHIM_FAILED',
      )
    }
  }
Build, bundle and package the dev mode shim responsible for routing events to the local machine..

The method performs the following operations:
- Generates the path for the zip file based on the service's name and directory.
- Bundles and minifies the "shim.js" file using esbuild.
- Creates a zip file and writes the bundled "shim.js" contents to it as "index.js".
- Sets the modification date of "index.js" to Unix epoch to ensure consistent
  zip file hashing for identical contents.
- Set the shim package as the deployment artifact for the service, essentially overwriting the original service package.

If errors occur during the bundling or zipping process, the method throws a
ServerlessError with appropriate messaging to indicate the failure reason.

@async
@returns {Promise<string>} A promise that resolves with the path to the created
zip file upon successful completion of the packaging process.
@throws {ServerlessError} Throws an error if bundling the "shim.js" file or
creating the zip file fails, with a specific error code for easier debugging.