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

231
Vistas
How to call a function bundled with webpack with external javascript?

How to call a function bundled with webpack with external javascript?

The webpack.js file consists of:

const init = (inputUrl) => {
    // window.onload = function(){
    init.loadMap = function(inputUrl){
        const wrap = document.querySelector('#px');
        Px.Core.Initialize(wrap, function(){
          Px.Loader.LoadFbx({
          // url: '../src/model/Bumma_004/Bumma_004.FBX',
          url: inputUrl,
            onLoad: function(){
              console.log("FBX Loading Complete");
              console.log(inputUrl);
            }
          })
        })
    }
    init.getconfig = function getconfig(){
        return url;
    }
    // init.getconfig = getconfig;

    function test(msg){
        return console.log('test function completed ' + msg);
    }
    init.test = test;
// }
}
export default init;

The index.js file is composed as follows.

import init from './temp.js'

init.loadMap('abc');

After bundling webpack.js, I want to put another url in index.js in init.loadMap and output to html.

However, in the index.js file, Cannot use import statement outside a module occurs on the first line.

How can I solve this problem?

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

0

fixed using global.init = init

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