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?
fixed using global.init = init