Code Monkey home page Code Monkey logo

Comments (12)

smellyshovel avatar smellyshovel commented on May 28, 2024 1

@narduin Solved.

Screenshot_20220627_151008

As I thought, an issue on the side of Nuxt/Webpack.

from maplibre-gl-directions.

narduin avatar narduin commented on May 28, 2024 1

Thanks a lot!!

from maplibre-gl-directions.

smellyshovel avatar smellyshovel commented on May 28, 2024

Hi @narduin, thanks for opening the issue.

It seems really wierd to me. Are you sure the package is added to your package.json? Which version do you use?

from maplibre-gl-directions.

smellyshovel avatar smellyshovel commented on May 28, 2024

There's also a problem with your code (I doubt it has anything to do with the issue, but still).

You invoke this.initDirections() when the map is not yet ready. Change it to

this.map.on("load", () => this.initDirections())

from maplibre-gl-directions.

narduin avatar narduin commented on May 28, 2024

From package.json: "@maplibre/maplibre-gl-directions": "^0.1.6"
I'm using yarn v3.2.1

Thanks for the correction on the initDirections, I think I've tried this but it did not fix the error so I reverted back.

from maplibre-gl-directions.

smellyshovel avatar smellyshovel commented on May 28, 2024

@narduin yeah, it has nothing to do with the issue for sure, just let you know that it won't work the way you did it when the issue will be resolved.

Don't you by any chance have a deployed reproduction of your environment?

from maplibre-gl-directions.

narduin avatar narduin commented on May 28, 2024

I'm creating a codesandbox, I'll post it once its ready :)

from maplibre-gl-directions.

smellyshovel avatar smellyshovel commented on May 28, 2024

@narduin thank you! Please, ping me when it's done.

from maplibre-gl-directions.

narduin avatar narduin commented on May 28, 2024

It seems the problems comes from another dependency.
I was able to create a working codesandbox example but as soon as I added my other two dependencies it broke (see sandbox 2 with core-js and @nuxtjs/axios).
Removing them does not fix anything…

from maplibre-gl-directions.

smellyshovel avatar smellyshovel commented on May 28, 2024

@narduin trying to fix your issue...
I'm thinking of default Nuxt's import-aliases that treat the @ symbol as an alias for /src. Though I'm not entirely sure. Investigating.

from maplibre-gl-directions.

narduin avatar narduin commented on May 28, 2024

Thank you, if you need anything else just ask!
In another branch I'm able to import import { GeocoderAutocomplete } from '@geoapify/geocoder-autocomplete' without problem.

from maplibre-gl-directions.

smellyshovel avatar smellyshovel commented on May 28, 2024

@narduin I've been able to narrow it down to this:

Must use import to load ES Module: /sandbox/node_modules/@maplibre/maplibre-gl-directions/dist/maplibre-gl-directions.es.js require() of ES modules is not supported. require() of /sandbox/node_modules/@maplibre/maplibre-gl-directions/dist/maplibre-gl-directions.es.js from /sandbox/node_modules/vue-server-renderer/build.dev.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules. Instead rename maplibre-gl-directions.es.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /sandbox/node_modules/@maplibre/maplibre-gl-directions/package.json.

Related issue: nuxt/nuxt#9223

Seems to me like the nuxt's/webpack's issue, though it still may require me to build a CJS version of the lib. I don't want to do so though, because it's a somewhat legacy stuff.

I'll try to find a workaround for Nuxt now.

from maplibre-gl-directions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.