I have a SDK kit that I made. It has a dependency of xmllint which is a wrapper to some C language command line tool and it can work in browser. Now I want to test if it all works in a browser environment. In sdk I had to make custom types for the xmllint since it doesent have its own and im using typescript inside the SDK.
declare module "xmllint"{
var xmllint:any;
export default xmllint;
}
I started with very simple js app that runs on webpack-dev-server
. There I imported my SDK. Created the class instance that uses xmllint and called verify to verify xml with xsd. Works fine.
But since its mostly not gona be used on a plain js, I tryed with bit more complex app. I installed aurelia-cli
and created a project with it (au new and setup with typescript
and npm
) and run it on webpack-dev-server
. Now I use my SDK the same way, but now I get error:
TypeError: xmllint_WEBPACK_IMPORTED_MODULE_0__default.a.validateXML is not a function
My guess is some sort of aurelia or webpack config that the aurelia-cli created is causing this error, but I cant seem to find which config. What is causing this error in aurelia and how can I fix this?
Solved the problem. Issue was that webpack.config was missing a module rule
module:{
rules:[
...,
{test: path.resolve(__dirname, "node-modules/xmllint/xmllint.js"),use:["imports-loader?require=>null", "exports-loader?xmllint"]}
,...
}]}