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

182
Visualizações
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
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