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

import(/* @vite-ignore */) is not worked in *.ts for v4 #11377

Closed
7 tasks done
igisev opened this issue Dec 14, 2022 · 7 comments
Closed
7 tasks done

import(/* @vite-ignore */) is not worked in *.ts for v4 #11377

igisev opened this issue Dec 14, 2022 · 7 comments
Labels
bug: upstream Bug in a dependency of Vite p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@igisev
Copy link

igisev commented Dec 14, 2022

Describe the bug

In v4.0.1 the comment /* @vite-ignore */ is ignored for import(/* @vite-ignore */)

let url = `/dynamic/${file}.js`;
// ...
import(url);                      // <- case1: warning expected
import(/* @vite-ignore */ url);   // <- case2: no warning expected

Run npx vite.
In case1 and case2 a warning will be issued:

The above dynamic import cannot be analyzed by Vite.
See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations for supported dynamic import formats. If this is intended to be left as-is, you can use the /* @vite-ignore */ comment inside the import() call to suppress this warning.

NOTE: for v3.2.5 case2 without warning.

Reproduction

https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations
https://stackblitz.com/edit/vitejs-vite-tyj1xj?file=main.ts&terminal=dev

Steps to reproduce

No response

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
    Memory: 19.09 GB / 31.93 GB
  Binaries:
    Node: 16.18.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.963.0), Chromium (108.0.1462.46)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @vitejs/plugin-vue: 4.0.0 => 4.0.0
    vite: 4.0.1 => 4.0.1

Used Package Manager

npm

Logs

No response

Validations

@github-actions
Copy link

Hello @igisev. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@patak-dev
Copy link
Member

Please help us by creating a real reproduction, you can use https://vite.new for it. Thanks!

@igisev
Copy link
Author

igisev commented Dec 14, 2022

@igisev
Copy link
Author

igisev commented Dec 14, 2022

I found that warning is only in ts-files, not in js-files

@igisev igisev changed the title import(/* @vite-ignore */) is not worked for v4 import(/* @vite-ignore */) is not worked in *.ts for v4 Dec 14, 2022
@antfu antfu added bug p3-minor-bug An edge case that only affects very specific usage (priority) and removed needs reproduction labels Dec 16, 2022
@antfu
Copy link
Member

antfu commented Dec 16, 2022

It seems the comment has been removed on transpiling from TS to JS.

@bluwy
Copy link
Member

bluwy commented Dec 17, 2022

Looks like it was (sort-of) a breaking change introduced in esbuild 0.15.17 (evanw/esbuild#2439). The issue in general is tracked at evanw/esbuild#2721

@bluwy
Copy link
Member

bluwy commented Jan 5, 2023

This is fixed in esbuild v0.16.14

@bluwy bluwy closed this as completed Jan 5, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: upstream Bug in a dependency of Vite p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants