diegoazh / gmap-vue

A wrapper component for consuming Google Maps API built on top of Vue. Fork of the popular vue-google-maps plugin.
https://diegoazh.github.io/gmap-vue/
172 stars 51 forks source link

Vite build error #277

Closed makroxyz closed 1 year ago

makroxyz commented 2 years ago

Describe the bug

running npm run build on vite gives

Could not resolve './node_modules/.pnpm/core-js@3.21.1/node_modules/core-js/internals/window.js' from node_modules/gmap-vue/dist/esm/main.js error during build: Error: Could not resolve './node_modules/.pnpm/core-js@3.21.1/node_modules/core-js/internals/window.js' from node_modules/gmap-vue/dist/esm/main.js at error (/home/vagrant/code/node_modules/rollup/dist/shared/rollup.js:198:30) at ModuleLoader.handleResolveId (/home/vagrant/code/node_modules/rollup/dist/shared/rollup.js:22508:24) at /home/vagrant/code/node_modules/rollup/dist/shared/rollup.js:22471:26

To reproduce

simply run npm run build

Expected behavior

Should compile w/o errors

Current behavior

The error above stops compile

Screenshots

Desktop (please complete the following information)

Smartphone (please complete the following information)

Additional context

This is the only package that fails

Versions

Package manager

Plugin version

Any ideas?

makroxyz commented 2 years ago

I solved by myself... need to remove

define: {
  global: 'window', // fix for packages that support both node and browser
},

from vite.config.js

please close.

mateusmcordeiro commented 2 years ago

im facing the same problem here, but this solution didnt work for me.

exactly same error:

Could not resolve './node_modules/.pnpm/core-js@3.21.1/node_modules/core-js/internals/window.js' from node_modules/gmap-vue/dist/esm/main.js
error during build:
Error: Could not resolve './node_modules/.pnpm/core-js@3.21.1/node_modules/core-js/internals/window.js' from node_modules/gmap-vue/dist/esm/main.js
    at error (file:///home/mateus/workspace/dashboard-frontend/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
    at ModuleLoader.handleResolveId (file:///home/mateus/workspace/dashboard-frontend/node_modules/rollup/dist/es/shared/rollup.js:22332:24)
    at file:///home/mateus/workspace/dashboard-frontend/node_modules/rollup/dist/es/shared/rollup.js:22295:26

My vite.config.js:

import path from 'path';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue2';
import WindiCSS from 'vite-plugin-windicss';
import postcss from './postcss.config';

const config = defineConfig({
    resolve: {
        alias: {
            path: 'path-browserify',
            '@': `${path.resolve(__dirname, 'src')}`
        }
    },
    define: {
        global: 'window'
    },
    build: {
        minify: true
    },

    plugins: [vue(), WindiCSS()],
    css: {
        postcss
    },
    server: {
        port: 8080
    }
});

export default config;
arjendejong12 commented 2 years ago

This should be fixed with the removal of core-js in #273.

diegoazh commented 2 years ago

@mateusmcordeiro, was your issue fixed with the last release?

diegoazh commented 1 year ago

Migrate to the new version of the plugin for Vue v3