🐛 dev server vite 2.2.3 dynamic import are not using path aliases
See original GitHub issueCurrent behavior
importsToLoad
dynamic import of the spec file fails because it does not replace the path alias given by vite in the dynamic import.
This results in a TypeError when it resolves.
Desired behavior
When vite is used and path aliases are given, check all kinds of imports or references to files with the according path alias.
Test code to reproduce
src/components/QuasarButton.vue
<template>
<input
data-cy="button"
label="test emit"
@click="$emit('test')"
/>
</template>
<script>
import { defineComponent } from 'vue';
export default defineComponent({
name: 'QuasarButton',
emits: ['test'],
});
src/components/__test__/QuasarButton.spec.ts
// __test__/QuasarButton.spec.ts
and a path alias for src
pointing to src
Cypress Version
10.1.0
Other
The content does not really matter because cypress will not reach any of it because vite has found spec files and is providing the paths with knowing the path alias for it but not resolving it but initCypresssTests is blind to it and will fail trying to dynamically import from the path given by vite.
Issue Analytics
- State:
- Created a year ago
- Comments:28 (12 by maintainers)
Top Results From Across the Web
src alias in vite/vue project with @ symbol not working
Your alias definition is fine, but you are missing a details about importing dynamic assets with Vite. I already explained it in this...
Read more >require is not defined vite | The Search Engine You Control
I need to use the dayjs library in my Vue application but Vite does not allow me to use require as specified in...
Read more >Changelog - Cypress Documentation
The error "Automatic publicPath is not supported in this browser" will no longer be displayed when using Webpack 5 and dynamic imports. Fixes...
Read more >packages/vite/CHANGELOG.md · Gitee 极速下载/ViteJS
renderBuiltUrl will also get called for preload asset paths. And build.modulePreload.resolveDependencies will be called both for JS dynamic imports preload ...
Read more >Building for Production - Vite
In this case, you can use the globally injected import.meta.env.BASE_URL variable which will be the public base path. Note this variable is statically...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/cypress-io/cypress/pull/23605 landed, it’ll be in the next release, I hope this helps!
We can keep working on this, I want to enable third parties as much as possible.
I’m back at it 😁 Seems like the support for async webpack config did the trick, so this issue can be closed We’re now dealing with another problem, but I’ll open a dedicated issue about it