Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
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 answers
Answer question

0

Try using Webpacker gem or webpack.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!