map-promisified icon indicating copy to clipboard operation
map-promisified copied to clipboard

Npm package need update, which don't have esm format

Open Gtanghaibo opened this issue 4 years ago • 3 comments

Gtanghaibo avatar Feb 20 '21 06:02 Gtanghaibo

Hi there,

Running the library in Vue3 I get : Uncaught SyntaxError: The requested module '/node_modules/map-promisified/dist/mapPromisify.js?v=ef5eaebc' does not provide an export named 'default'

<template>
  <div id="mapMain" ref="mapContainer" class="absolute top-0 bottom-0 left-0 right-0">
    <MglMap :accessToken="accessToken" />
  </div>
  <!-- <router-view /> -->
</template>

<script lang="ts">
import { computed, defineComponent, onMounted, reactive, ref } from "vue";

import Mapbox from "mapbox-gl";
import { MglMap } from "vue-mapbox";
export default defineComponent({
  components: { MglMap },
  setup() {
    const mapContainer = ref();
    const mapbox = ref(null);

    let accessToken = "pk.eyJ1IjoidHJvb3AiLCJhIjoiY2txdXNrcnMyMDducTJucnk4dmE0d2V1byJ9.CpmXTiNQDQGPzqQ6K2SfwQ";

    onMounted(() => {
      mapbox.value = Mapbox;
    });
    

    return { mapContainer, accessToken, mapbox };
  },
});
</script>

Your assistance is appreciated :)

thespacedeck avatar Jul 08 '21 12:07 thespacedeck

Same here, how can we workaround this?

Using it with vite and Vue3

TheJoeSchr avatar Jul 27 '21 15:07 TheJoeSchr

Ok, in my case I "fixed" it by putting this into vite.config.js

export default defineConfig({
  define: { "process.env": {} },
  plugins: [vue()],
  // added this -->
  optimizeDeps: {
    include: ['map-promisified']
  },
  // <-- added this 
}

TheJoeSchr avatar Jul 27 '21 16:07 TheJoeSchr