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

UTF-8 with BOM files cause vite to fail import rewrite #3162

Closed
6 tasks done
rjregenold opened this issue Apr 26, 2021 · 4 comments · Fixed by #3171
Closed
6 tasks done

UTF-8 with BOM files cause vite to fail import rewrite #3162

rjregenold opened this issue Apr 26, 2021 · 4 comments · Fixed by #3171

Comments

@rjregenold
Copy link

rjregenold commented Apr 26, 2021

Describe the bug

The issue described in #806 is happening again in vite 2.2.1 (and 2.2.3). If a file uses UTF-8 with BOM encoding, the first line of the file is not rewritten correctly.

Reproduction

https://github.com/rjregenold/vite-utf8-bom-issue/blob/master/src/main.js

The main.js file is saved with UTF-8 with BOM encoding. When running the app in development mode, the following error appears in the console:

Uncaught TypeError: Failed to resolve module specifier "vite/dynamic-import-polyfill". Relative references must start with either "/", "./", or "../".

System Info

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

 System:
    OS: Windows 10 10.0.19043
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 17.41 GB / 31.73 GB
  Binaries:
    Node: 16.0.0 - C:\Program Files\nodejs\node.EXE        
    Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 90.0.4430.85
    Edge: Spartan (44.19041.962.0), Chromium (90.0.818.46) 
    Internet Explorer: 11.0.19041.1
  npmPackages:
    @vitejs/plugin-vue: ^1.2.1 => 1.2.1
    vite: ^2.1.5 => 2.2.1

Used package manager: yarn

Logs

Uncaught TypeError: Failed to resolve module specifier "vite/dynamic-import-polyfill". Relative references must start with either "/", "./", or "../".

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.
@github-actions
Copy link

Hello @rjregenold. We totally like your proposal/feedback, welcome to send us a Pull Request for it. Please provide changelog/TypeScript/documentation/test cases if needed and make sure CI passed, we will review it soon. We appreciate your effort in advance and looking forward to your contribution!

@patak-dev
Copy link
Member

Looks like @Aaron-Pool already digged into this: #814 (comment)

@ygj6
Copy link
Member

ygj6 commented Apr 27, 2021

I am glad to pick up this issue!

ygj6 added a commit to ygj6/vite that referenced this issue Apr 27, 2021
@Shinigami92
Copy link
Member

Declaring this as a has workaround because it's possible to remove it manually 😅

TobiasMelen pushed a commit to TobiasMelen/vite that referenced this issue May 3, 2021
fi3ework pushed a commit to fi3ework/vite that referenced this issue May 22, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants