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

158
Vistas
Problems with some classes not exporting when it should have arose when porting codebase from Webpack to Rollup

So, I'm porting an old 2017 codebase from Webpack to Rollup for performance and code size reasons, also because of the old dependencies that the codebase used.

Unfortunately, The new Rollup version has a problem that I couldn't figure out a solution for. It doesn't seem to export some classes (In this case Engine and BackgroundLayer), but the Webpack unaltered version does. Is there a reason for this?

The Error in question:

Uncaught ReferenceError: Engine is not defined

Here's my rollup.config.js

import arraybuffer from '@wemap/rollup-plugin-arraybuffer';
import { babel } from "@rollup/plugin-babel";
import commonjs from "@rollup/plugin-commonjs";
import pkg from './package.json';
import resolve from "@rollup/plugin-node-resolve";
// import { terser } from "rollup-plugin-terser";

export default {
    input: "src/index.js",
    output: {
      name: "index",
      file: `dist/${pkg.name}.js`,
      format: "umd",
    },
    external: ['ms'],
    plugins: [
      arraybuffer({ include: '**/*.dat' }), // so Rollup can import .dat files
      resolve(), // so Rollup can find `ms`
      commonjs(), // so Rollup can convert `ms` to an ES module
      // terser(), // minifying
      // babel configuration
      babel({ exclude: 'node_modules/**', babelHelpers: "runtime", skipPreflightCheck: true }),
    ]
}

If anybody requires the full codebase, here are the two versions:

  • Webpack Code: https://github.com/kdex/earthbound-battle-backgrounds
  • Rollup Code: https://github.com/IamRifki/earthbound-battle-backgrounds-rollup
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Figured it out, I had to call my bundle.js inside a module:

index.html

<script type="module">
  import { BackgroundLayer, Engine } from "./bundle.js";

  const engine = new Engine([new BackgroundLayer(153), new BackgroundLayer(298)]);
  engine.animate();
</script>
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