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

192
Vistas
Using ES6 module with asset pipeline of ruby on rails

I am converting old functional-based syntax Javascript to ES6 classes . Previously code was like this :

var SW;
if(SW.app === undefined) SW.app = {};
SW.app.NullLicense = (function () {
    "use strict";

    var NullLicense;
    NullLicense = function () { };
    NullLicense.prototype.handleLicense = function () {
        var t1 = new SW.app.Utility();
        return t1;
    };
    return NullLicense;
}());

Now with ES6 modules the code is like this

import {Utility} from './Utility.js'
export class NullLicense  {
    "use strict";
    constructor(){ };
   handleLicense  () {
        var t1 = new Utility();
        return t1;
    }
};

Since previously every module was concatenated to global SW variable we didn't have to worry about the dependencies issue. In app/asset we have our manifest file application.js . It loads all the js files in the code base. Now since we have export and import commands in every file , I am getting this error that export declarations may only appear at top level of a module. I want to know what can be the workaround for this .

Thanks

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

0

Try using Webpacker gem or webpack.

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