Good morning everybody.
I’m trying to test the “parse-kml” package but I receive several errors when bundling the script.
I tried with Webpack v5, but I had some problems due to a lot of missing polyfilss, so I’m getting back to Webpack v4.
Here’s some code
webpack.config.js
const path = require("path");
module.exports = {
externals: ["fs", "net", "tls"],
mode: "development",
}
package.json
{
"name": "kmltest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1",
"build": "webpack --config webpack.config.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"webpack": "^4.47.0",
"webpack-cli": "^3.3.12"
},
"dependencies": {
"fs": "0.0.1-security",
"net": "^1.0.2",
"parse-kml": "^1.0.1",
"tls": "0.0.1"
}
}
index.js
const parseKML = require("parse-kml");
// Read KML From File
parseKML
.readKml("./test.kml")
.then((res) => console.log("Loaded"))
.catch((err) => console.error("error"));
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="description" content="test content" />
</head>
<body>
<h1>Testing KML/h1>
<script src="main.js"></script>
</body>
</html>
As you can see, there’s nothing so complicated, but once I bundle the script and open the webpage, my console shows this error:
It’s my very first time I configure webpack on my own, so I’m sure I made some mistakes.
Could you help me?
Thank you!
1