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

170
Views
jQuery functions not available after compilation

After the compilation of Javascript file with Browserify/Babel (preset-end) or Rollup.js there is not reponse from the script, in the browser. What I want to do is to write a script including node_modules and to transpile it in Javascript browser compatible.

The setup I used with Gulp:

function babel_client() {
    return src('./client/js/Controller_ui.js')
        .pipe(babel({
            presets: [
                [
                    "@babel/preset-env",
                    {
                        "useBuiltIns": "usage",
                        "corejs": "3.10.0"
                    }
                ]
            ]
        }))
        .pipe(dest('build/'));
}

function rollup_client() {
  return src('./client/js/Controller_ui.js')
        .pipe(rollup({
      input: './client/js/Controller_ui.js',
            external: ['jquery'],
            output: {
                format: 'iife',
                globals: {
                    jquery: '$'
                }
            }
    }))
    .pipe(dest('./build'));
}


function lint_client() {
    return src('./client/js/Controller_ui.js')
        .pipe(jshint());
}

function browserify_client() {
    return src('./build/Controller_ui.js')
        .pipe(browserify({
            insertGlobals: true
        }))
        .pipe(rename('Controller_uix.js'))
        .pipe(dest('./public'));
}


exports.browserify = series(lint_client, rollup_client, browserify_client);
exports.build = series(lint_client, rollup_client, node_server, browserify_client);

Controller_ui.js file user by rollup_client or babel_client function

'use strict';

//var $ = require('jquery');
import $ from 'jquery';

window.$ = $;

console.log(window);

$(window).ready(function () {
  console.log('aaäö');
});

the transpile file looks like this

(function ($) {
  'use strict';

  $ = $ && $.hasOwnProperty('default') ? $['default'] : $;

  window.$ = $;

  console.log(window);

  $(window).ready(function () {
    console.log('aaäö');
  });

}($));

looks good, there seems to be wrapped in a function so the browser will not output the content od the function untless it is called. Also if the jquery plugin is included with browserify, there is still no response from the browser.

What will be the best resolution in this regard, Bower?

about 4 years ago · Juan Pablo Isaza
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!