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.meta error in vite 3.1.3 #10183

Closed
7 tasks done
chesterlaykin opened this issue Sep 21, 2022 · 5 comments
Closed
7 tasks done

Import.meta error in vite 3.1.3 #10183

chesterlaykin opened this issue Sep 21, 2022 · 5 comments
Labels
duplicate This issue or pull request already exists

Comments

@chesterlaykin
Copy link

Describe the bug

There appears to be a bug in vite 3.1.3: when using vite with react and typescript (using a package called vite-plugin-ssr) I get errors beginning with:
[vite] warning: "import.meta" is not available in the configured target environment ("ES2017") and will be empty

If I change the version to vite 3.0.9, the error goes away.
The issue is with the vite version rather than the vite-plugin-ssr package, as I understood it.
Here is a reproduction: .

tsconfig has"module": "ES2020"and:

"ts-node": {
    "transpileOnly": true,
    "compilerOptions": {
      "module": "CommonJS"
    }
  }

Reproduction

https://stackblitz.com/edit/github-c4bkhn

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 3.16 GB / 15.73 GB
  Binaries:
    Node: 16.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (105.0.1343.42)
    Internet Explorer: 11.0.19041.1566

Used Package Manager

yarn

Logs

No response

Validations

@OliverGrimsley
Copy link

Similar issue in vue plugin - I can confirm - if I set version to 3.0.9, my app builds in production and development, HMR works, etc no issues. If I move the Vite dependency to 3.1.0, I have the problem noted in this discussion thread - but to reduce it down, something in the new code in 3.1.1 started injecting import_meta (and please note the underscore) as a blank object, and then trying to read from it. If I view the same compiled code in development under v 3.0.9, there is no reference to import_meta and the later call is to import.meta - I think these are related issues is why I posted here and did not open a new issue.

@htmnk
Copy link

htmnk commented Sep 21, 2022

#10167 might be related, similiar import.meta issues went away for me after setting esbuild.target to 'esnext' as a workaround.

@OliverGrimsley
Copy link

I can confirm changing target to esnext in TS compile options fixed issue for me. thx!

@chesterlaykin
Copy link
Author

That works for me too, great!

@sapphi-red
Copy link
Member

Yeah, it's happening by the same cause with #10167.
Closing to keep the discussion in a single place.

@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Sep 21, 2022
@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed pending triage labels Sep 21, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants