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 not supported inside wxt.config.ts file #934

Closed
5 tasks done
Tracked by #297
minht11 opened this issue Aug 21, 2024 · 1 comment
Closed
5 tasks done
Tracked by #297

import.meta not supported inside wxt.config.ts file #934

minht11 opened this issue Aug 21, 2024 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@minht11
Copy link

minht11 commented Aug 21, 2024

Describe the bug

Try using import.meta.dirname inside wxt.config.ts file.

✖ Command failed after 96 ms                                                                                            5:14:37 PM

 ERROR  Cannot use 'import.meta' outside a module                                                                        5:14:37 PM

  import.meta.dirname;
  ^^^^
  
  SyntaxError: Cannot use 'import.meta' outside a module
  at new Script (node:vm:99:7)
  at createScript (node:vm:255:10)
  at Object.runInThisContext (node:vm:303:10)

Reproduction

Use import.meta.dirname inside wxt.config.ts file.

Steps to reproduce

No response

System Info

System:
    OS: macOS 14.6.1
    CPU: (8) arm64 Apple M1
    Memory: 77.20 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/.proto/shims/node
    Yarn: 1.22.22 - ~/.proto/shims/yarn
    npm: 10.2.4 - ~/.proto/shims/npm
    pnpm: 9.6.0 - ~/.proto/shims/pnpm
  Browsers:
    Brave Browser: 126.1.67.123
    Chrome: 127.0.6533.120
    Chrome Canary: 130.0.6669.0
    Edge: 127.0.2651.105
    Safari: 17.6

Used Package Manager

npm

Validations

@minht11 minht11 added the pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug label Aug 21, 2024
@aklinker1
Copy link
Collaborator

Duplicate of #297. The file is loaded as this weird CJS/ESM hybrid, and it doesn't support all ESM features, like import.meta.dirname.

Use __dirname instead.

@aklinker1 aklinker1 added duplicate This issue or pull request already exists and removed pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug labels Aug 21, 2024
@aklinker1 aklinker1 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants