Skip to content

Vite 3 fails on build of module #799

@Halling69

Description

@Halling69

When compiling an old vue 2 project using https://github.com/vuejs/create-vue @legacy
I get the following error with [email protected]

[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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions