Estoy tratando de crear un proyecto webpack 5 muy simple en el que sirvo un HTML y trato de cargar un mapa HERE. Es un proyecto mecanografiado.
Mi archivo ts es:
const main = async () => { const H = await import("@here/maps-api-for-javascript"); console.log(H); //this prints the module object console.log(H.service); //this prints undefined var platform = new H.service.Platform({ apikey: "{YOUR_API_KEY}", }); // Obtain the default map types from the platform object var maptypes = platform.createDefaultLayers(); // Instantiate (and display) a map object: var map = new H.Map( document.getElementById("mapContainer"), maptypes.vector.normal.map, { zoom: 10, center: { lng: 13.4, lat: 52.51 }, } ); }; main(); El error, como puede imaginar, es: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'Platform')
Mi tsconfig.json es:
{ "compilerOptions": { "outDir": "./dist/", "sourceMap": true, "noImplicitAny": true, "module": "esnext", "target": "es5", "jsx": "react", "allowJs": true, "moduleResolution": "node" } }Mi archivo webpack.common.js es:
const path = require("path"); const TerserPlugin = require("terser-webpack-plugin"); module.exports = { entry: "./src/index.ts", mode: "production", devtool: "source-map", optimization: { usedExports: true, }, output: { filename: "[name].[contenthash].js", path: path.resolve(__dirname, "dist"), }, module: { rules: [ { test: /\.tsx?$/, exclude: /node_modules/, use: { loader: "ts-loader", options: { // disable type checker - we will use it in fork plugin transpileOnly: true, }, }, }, ], }, optimization: { minimizer: [ new TerserPlugin({ exclude: "mapsjs.bundle.js", }), ], }, resolve: { extensions: [".tsx", ".ts", ".js"], }, plugins: [], node: { global: false, }, };¿Qué me falta para que esto funcione? Gracias