xkjyeah / vue-google-maps

Google maps component for vue with 2-way data binding
https://xkjyeah.github.io/vue-google-maps/
1.88k stars 474 forks source link

Vite 3 fails on build of module #799

Open Halling69 opened 2 months ago

Halling69 commented 2 months ago

When compiling an old vue 2 project using https://github.com/vuejs/create-vue @legacy I get the following error with vue2-google-maps@0.10.7

[vite:vue2] Could not load /node_modules/vue2-google-maps/dist/components/placeInputImpl.js?vue&type=script&src=true&lang.js?commonjs-exports (imported by node_modules/vue2-google-maps/dist/components/placeInputImpl.js?vue&type=script&src=true&lang.js): The argument 'path' must be a string, Uint8Array, or URL without null bytes. Received '\x00/node_modules/vue2-google-maps/dist/components/pl... error during build: TypeError [PLUGIN_ERROR]: Could not load /node_modules/vue2-google-maps/dist/components/placeInputImpl.js?vue&type=script&src=true&lang.js?commonjs-exports (imported by node_modules/vue2-google-maps/dist/components/placeInputImpl.js?vue&type=script&src=true&lang.js): The argument 'path' must be a string, Uint8Array, or URL without null bytes. Received '\x00/node_modules/vue2-google-maps/dist/components/pl... at Object.readFileSync (node:fs:440:14) at Object.load (C:\projects\sanistaal\Webshop-v4\src\Sanistaal.Website\client-vite\Ahlsell\node_modules\@vitejs\plugin-vue2\dist\index.cjs:3217:30) at file:////node_modules/rollup/dist/es/shared/rollup.js:22748:40 ERROR: "build-only" exited with 1.

I have identified the root cause being in placeInput.vue

<template>
    <label>
        <span v-text="label"></span>
        <input type="text" :placeholder="placeholder" :class="className"
          ref="input"/>
    </label>
</template>

<script src="./placeInputImpl.js">
</script>

The other vue components use function based require inclusion of the corresponding backend code so this code works:

<template>
    <label>
        <span v-text="label"></span>
        <input type="text" :placeholder="placeholder" :class="className"
          ref="input"/>
    </label>
</template>

<script>
export default (function (x) { return x.default || x })(require('./placeInputImpl.js'))
</script>
aroy314 commented 2 weeks ago

Please let us know when this is fixed so we can close https://github.com/vitejs/vite-plugin-vue2/issues/63