wxt-dev / wxt

⚡ Next-gen Web Extension Framework
https://wxt.dev
MIT License
4.15k stars 169 forks source link

Run dev failed when there have a components folder #440

Open chhpt opened 7 months ago

chhpt commented 7 months ago

Describe the bug

Run dev failed with the following error when there have a components folder


> wxt-starter@0.0.0 dev /Users/chaihe/Desktop/wxt
> wxt

WXT 0.14.6 
✖ Command failed after 244 ms                                                             

ERROR  EISDIR: illegal operation on a directory

ELIFECYCLE  Command failed with exit code 1.

To Reproduce

Open this stackblitz link https://stackblitz.com/~/github.com/chhpt/wxt-starter, or clone this repo https://github.com/chhpt/wxt-starter

Steps to reproduce the bug using the reproduction:

  1. Install dependencies: pnpm i

Expected behavior

Run dev successed

Screenshots

image

Environment

  System:
    OS: macOS 14.2.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 274.08 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
    pnpm: 8.15.2 - ~/.nvm/versions/node/v20.11.0/bin/pnpm
    bun: 1.0.26 - ~/.bun/bin/bun
  Browsers:
    Chrome: 121.0.6167.160
    Edge: 113.0.1774.35
    Safari: 17.2.1
  npmPackages:
    wxt: ^0.14.0 => 0.14.6 

Additional context

aklinker1 commented 7 months ago

This is an upstream issue with unimport, here's a related PR, just doesn't cover JSX/TSX files: https://github.com/unjs/unimport/pull/229

I'll try and open a PR soon.


Looks like unimport is looking for index files when importing the directory (with an index file in it)...

https://github.com/unjs/unimport/blob/8a622c9c38d28ee9a80e7c0b8cb82bea05a69766/src/scan-dirs.ts#L94-L97

But it doesn't look for JSX/TSX extensions...

https://github.com/unjs/unimport/blob/8a622c9c38d28ee9a80e7c0b8cb82bea05a69766/src/scan-dirs.ts#L41-L48

So it tries to read the directory as a file, and we get this error

aklinker1 commented 7 months ago

Quick fix:

-export * from './iframe'
+export * from './iframe/index.tsx'
aklinker1 commented 7 months ago

I created an issue on unimport, will probably open a PR at some point once I figure out how to setup a valid test.

https://github.com/unjs/unimport/issues/326