A loader for webpack that lets you import asm scripts in async mode to let the browser do async compilation.
npm install --save-dev npm-async-loader
Use the loader either via your webpack config, CLI or inline.
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.js$/,
use: 'asm-async-loader'
}
]
}
}
In your application
import promise from './asm-script.js';
promise
.then(function() {
//your script usage
})
.catch(function(err) {
//script loading failed
});
In your application
import promise from 'asm-async-loader!./asm-script.js';
promise
.then(function() {
//your script usage
})
.catch(function(err) {
//script loading failed
});