question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problems caused by using alisaes and omitting file suffixes at the same time

See original GitHub issue

Describe the bug

If a specific file suffix is added as the resolve.extension field, vite allows its users to ignore the file suffix. However, when the user ignores the file suffix and uses the alias (@) to refer to a file in the project, an internal server error will occur. This error indicates that the file whose suffix is omitted does not exist. For example, if you add the .vue field in resolve.extension, you can omit the.vue suffix when referencing a vue file. However, in the case where we use @/path to refer to a file in the project, the project does not work properly. I will submit a PR to fix this problem!

Reproduction

https://github.com/ygj6/vite-issue-investigative/tree/alias_bug

In the main.js file, if user uses import App from '@/App' to refer to the App.vue. An error appears which indicates No loader is configured for ".vue" files: src/App.vue. However, there are two cases which can work as normal. For example, import App from './App or import App from '@/App.vue.

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

  System:
    OS: Windows 10 10.0.19041
    CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
    Memory: 15.51 GB / 23.74 GB
  Binaries:
    Node: 12.16.3 - D:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.4 - D:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 90.0.4430.212
    Edge: Spartan (44.19041.964.0), Chromium (90.0.818.66)
    Internet Explorer: 11.0.19041.1

Used package manager:

Logs

image


Before submitting the issue, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
  • Provide a description in this issue that describes the bug.
  • Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
ygj6commented, May 27, 2021

okay, we have also taken note of the community’s suggestions on the file suffixes. However, this usage has been widely used in many of our existing projects, so if we want to maintain the consistency of the projects, we have no choice but to omit the file suffix. In addition, since the community allows users to omit the file suffix, i think it is necessary to ensure the correctness of this function.

0reactions
ikeqcommented, Jun 28, 2021

A temporary workaround vite-plugin-resolve-extension-vue.

// vite.config.js
import resolveExtensionVue from 'vite-plugin-resolve-extension-vue';

export default {
  plugins: [resolveExtensionVue()],
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Aliases and Symbolic Links | Problems with OS X Files
Now whenever you click an alias, it launches the original file, as though the file were in two locations at the same time....
Read more >
Using aliases - RimuHosting
Using aliases. When working on the command line, you'll likely find that you're executing the same command multiple times. It's the case that...
Read more >
An Introduction to Useful Bash Aliases and Functions
Luckily, bash allows us to create our own shortcuts and time-savers through the use of aliases and shell functions. In this guide, we'll...
Read more >
Alias: An approach to .NET Assembly Conflict Resolution
A plugin model allows extension or customization of functionality by adding assemblies and config files to a directory that is scanned at ...
Read more >
About Aliases - Oracle Help Center
The same name for members from different dimensions or from the same ... If you're using the alias for display purposes only then...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found