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

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

0

fixed using global.init = init

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!