Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite import-analysis error when using vite-plugin-cypress-esm #28301

Closed
ryany338 opened this issue Nov 9, 2023 · 2 comments
Closed

Vite import-analysis error when using vite-plugin-cypress-esm #28301

ryany338 opened this issue Nov 9, 2023 · 2 comments
Labels
stale no activity on this issue for a long period

Comments

@ryany338
Copy link

ryany338 commented Nov 9, 2023

Current behavior

Copied from this discussion post.

I'm trying to get the vite-plugin-cypress-esm working in my component tests. When I run a test with the plugin enabled, the vite:import analysis plugin throws an error. It seems like the entries that I've added to ignoreModuleList are not being honored. Here's a stack trace:

2:08:03 PM [vite] Internal server error: Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension.
  Plugin: vite:import-analysis
  File: /Users/dev/node_modules/.vite/deps/@remix-run_react.js?v=70f1f4b7:2239:3
  2237|        await routeModulePromise;
  2238|      }
  2239|    };
     |    ^
  2240|  }
  2241|  function getRedirect(response) {
      at formatError (file:///Users/dev/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44062:46)
      at TransformContext.error (file:///Users/dev/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44058:19)
      at TransformContext.transform (file:///Users/dev/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:41784:22)
      at async Object.transform (file:///Users/dev/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44352:30)
      at async loadAndTransform (file:///Users/dev/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:55026:29)
      at async viteTransformMiddleware (file:///Users/dev/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:64430:32)

Here's a snippet from the cypress config. I'm not sure what I'm missing.

export default defineConfig({
  component: {
    devServer: {
      framework: 'react',
      bundler: 'vite',
      viteConfig: defineViteConfig({
        plugins: [
          react(),
          CypressEsm({
            ignoreModuleList: ['*react*', '*remix*', '@remix-run*'],
            ignoreImportList: ['*react*', '*remix*', '@remix-run*']
          }),
          nodePolyfills({
            exclude: ['fs'],
          }),
        ],
        resolve: {
          alias: {
            '~': path.resolve(__dirname, './src'),
          },
        },
      }),
    },
    viewportHeight: 1200,
    viewportWidth: 1440,
  },

Has anyone else run into this?
Cypress - v12.4.1
Vite - v4.5.0
@cypress/vite-plugin-cypress-esm - v1.1.0

Desired behavior

No response

Test code to reproduce

Cypress config info posted above. I'm not sure that it's even reaching the test code. It seems that vite is trying to analyze it's own dependencies?

Cypress Version

v12.4.1

Node version

v18.15

Operating System

macOs 14.1

Debug Logs

No response

Other

No response

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label May 8, 2024
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale no activity on this issue for a long period
Projects
None yet
Development

No branches or pull requests

2 participants