Open LizGabriela-RY opened 6 months ago
Start a new pull request in StackBlitz Codeflow.
I opened the reproduction but no error happened.
Hello @LizGabriela-RY. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs reproduction
will be closed if they have no activity within 3 days.
Describe the bug
We are migrating our UI from webpack": "4.41.2" ("node": "^16") to use "vite": "~5.1.4" ("node": "^20",). We have migrated almost all the functionality and components without any issue except "graphql-voyager", we use this as schema visualizer tool running with version "graphql-voyager": "1.0.0-rc.31" however in the vite version we cant make this tool to run due to message mentioned above. In first instance we tried importing module directly in the component:
import {Voyager} from 'graphql-voyager';
This makes the all app to failed as it did not find a specific library: http://localhost:3000/node_modules/.vite/deps/graphql-voyager.js?v=5ad894e5After some investigation we try an workaround using vite-plugin-legacy. Adding the following configuration to vite:
import legacy from '@vitejs/plugin-legacy' export default { plugins: [ legacy({ targets: ['defaults', 'not IE 11'] }) ] }
And using dynamic import:import('graphql-voyager').then((Voyager) => { // Use Voyager here })
This solved the issue of the all app failing however still thrown similar imessage when trying to navigate to the specific component that use Voyager. Message in this case will be: Uncaught (in promise) TypeError: Failed to fetch dynamically imported module: http://localhost:3000/node_modules/.vite/deps/graphql-voyager.js?v=488bd6e1Note in both cases file and folder exist in node_modules but it seems it is not recognise or process by vite. We have tried from "graphql-voyager": "1.0.0-rc.31" to lates available "graphql-voyager": "^2.0.0".
Reproduction
https://stackblitz.com/edit/vitejs-vite-uvwuz8?file=main.js
Steps to reproduce
Try adding directly the import to the graphql-voyager or import dynamically after setting vite-plugin-legacy
System Info
Used Package Manager
npm
Logs
No response
Validations