Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
rollup js to include NodeJS core library

I was deploying something onto an akamai edgeworker and hence was using the node package rollup. One of the packages i have uses require('crypto') which causes issues for me as i cant seem to get the rollup to include the code. I was able to work around and get it so i dont have the import at the top but now getting TypeError: crypto.randomFillSync is not a function. just wondering how i can deploy something that requires crypto onto edgeworker. my current rollup.config file is:

banner.js

var window = {};
var TextDecoder = function() {};
var setTimeout = function(callback) { callback(); };

rollup.config.js

import * as fs from "fs";
import resolve from "@rollup/plugin-node-resolve";
import json from "@rollup/plugin-json";
import commonjs from "@rollup/plugin-commonjs";
import nodePolyfills from 'rollup-plugin-node-polyfills';
import { babel } from '@rollup/plugin-babel';


const BANNER = fs.readFileSync("./src/banner.js").toString();

function getPlugins(babelConfig) {
  return [
    // Convert CommonJS modules to ES6
    commonjs(),
    nodePolyfills(),
    // Resolve modules from node_modules
    resolve({
      // use the "browser" property in package.json
      browser: true,
      preferBuiltins: false
    }),
    babel(babelConfig),
    // Package json data as an ES6 module
    json()
  ];
}

export default [
  {
    input: "src/index.js",
    output: {
      banner: BANNER,
      name: "main",
      file: "dist/main.js",
      format: "esm",
      sourcemap: false
    },
    external: ['cookies', 'http-request', 'log', 'create-response'],
    plugins: getPlugins(
      {
        inputSourceMap: true,
        sourceMaps: true,
        exclude: ["node_modules/**", /\/core-js\//],

        presets: [
          [
            "@babel/preset-env",
            {
              useBuiltIns: "usage",
              corejs: 3,
              modules: false,
              targets: {
                browsers: [
                  "last 2 Chrome versions",
                  "last 2 Firefox versions",
                  "last 2 Safari versions"
                ]
              }
            }
          ]
        ],
        plugins: []
      }
    )
  }
];

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

the crypto module relies on having either a Node.js or a browser environment, as it provides the implementation by wrapping the underlying platform APIs. Akamai EdgeWorkers does not yet provide a native crypto functionality, so you would need to use a JS library which provides a pure JS implementation.

I have had success with using crypto-es (https://www.npmjs.com/package/crypto-es) as long as you are careful to watch CPU limits.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda