Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

188
Visualizações
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 Respostas
Responde à pergunta

0

Try using Webpacker gem or webpack.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda