Skip to content

vite serve fails when using @elastic/eui #280

Closed

Description

@joshacheson

Do NOT ignore this template or your issue will have a very high chance to be closed without comment.

Describe the bug

When attempting to import/utilize @elastic/eui, vite cli reports an error (Error: EISDIR: illegal operation on a directory, read) and app is not functional.

I am guessing this has something to do with bare imports, but am not sure what alternative I have in this situation.

Reproduction

Repro repo: https://github.com/joshacheson/vite-eui-bug-repro

All code in this repo is what is bootstrapped when doing npm init vite-app <project-name> --template react except for this import statement.

System Info

  • required vite version: 0.17.1
  • required Operating System: macOS 10.14.6
  • required Node version: 11.13.0
  • Optional:
    • npm/yarn version: [email protected]
    • Installed vue version (from yarn.lock or package-lock.json): n/a (react)
    • Installed @vue/compiler-sfc version: n/a (react)

Logs (Optional if provided reproduction)

  1. Run vite or vite build with the --debug flag.
  2. Provide the error log here.
vite v0.17.1
  vite:config env mode: development +0ms
  vite:config env: {} +1ms
  vite:config config resolved in 36ms +1ms
  vite:optimize Hash is consistent. Skipping. Use --force to override. +0ms

  Dev server running at:
  > Local:    http://localhost:3000/
  > Network:  http://192.168.0.17:3000/

  vite:server server ready in 185ms. +0ms
  vite:hmr ws client connected +0ms
  vite:rewrite /: rewriting +0ms
  vite:hmr         / imports /@react-refresh +23ms
  vite:rewrite     no imports rewritten. +2ms
  vite:hmr         / imports /src/main.jsx +0ms
  vite:rewrite (skipped) / +1ms
  vite:rewrite /src/main.jsx: rewriting +263ms
  vite:rewrite     "react" --> "/@modules/@pika/react/source.development.js" +2ms
  vite:hmr         /src/main.jsx imports /@modules/@pika/react/source.development.js +266ms
  vite:rewrite     "react-dom" --> "/@modules/@pika/react-dom/source.development.js" +1ms
  vite:hmr         /src/main.jsx imports /@modules/@pika/react-dom/source.development.js +1ms
  vite:rewrite     "./index.css" --> "/src/index.css?import" +0ms
  vite:hmr         /src/main.jsx imports /src/index.css +0ms
  vite:resolve (extension) /Users/joshuaacheson/code/vite-eui-bug-repro/src/App -> /Users/joshuaacheson/code/vite-eui-bug-repro/src/App.jsx +0ms
  vite:rewrite     "./App" --> "/src/App.jsx" +1ms
  vite:hmr         /src/main.jsx imports /src/App.jsx +1ms
  vite:rewrite (skipped) /vite/hmr +5ms
  vite:rewrite /@react-refresh: no imports found. +4ms
  vite:resolve (node_modules) @pika/react-dom/source.development.js -> node_modules/@pika/react-dom/source.development.js +0ms
  vite:resolve (node_modules) @pika/react/source.development.js -> node_modules/@pika/react/source.development.js +1ms
  vite:rewrite /@modules/@pika/react/source.development.js: no imports found. +50ms
  vite:rewrite /src/index.css: rewriting +53ms
  vite:rewrite     no imports rewritten. +0ms
  vite:rewrite /src/App.jsx: rewriting +37ms
  vite:hmr         /src/App.jsx imports /@react-refresh +150ms
  vite:hmr rewriting /src/App.jsx for HMR. +0ms
  vite:rewrite     "react" --> "/@modules/@pika/react/source.development.js" +6ms
  vite:hmr         /src/App.jsx imports /@modules/@pika/react/source.development.js +5ms
  vite:resolve (node_module entry) @elastic/eui -> es +156ms
  vite:rewrite     "@elastic/eui" --> "/@modules/@elastic/eui/es" +1ms
  vite:hmr         /src/App.jsx imports /@modules/@elastic/eui/es +1ms
  vite:rewrite     "./logo.svg" --> "/src/logo.svg?import" +0ms
  vite:hmr         /src/App.jsx imports /src/logo.svg +0ms
  vite:rewrite     "./App.css" --> "/src/App.css?import" +0ms
  vite:hmr         /src/App.jsx imports /src/App.css +0ms
  vite:rewrite /@modules/@pika/react-dom/source.development.js: rewriting +19ms
  vite:rewrite     "react" --> "/@modules/@pika/react/source.development.js" +13ms
  vite:hmr         /@modules/@pika/react-dom/source.development.js imports /@modules/@pika/react/source.development.js +32ms
  vite:resolve (node_modules) @elastic/eui/es -> node_modules/@elastic/eui/es +184ms
  vite:rewrite /src/logo.svg: no imports found. +9ms

  Error: EISDIR: illegal operation on a directory, read

  vite:rewrite /src/App.css: rewriting +13ms
  vite:rewrite     no imports rewritten. +0ms
  vite:history not redirecting /favicon.ico (not accepting html) +0ms
  vite:rewrite (skipped) /favicon.ico +29ms
  vite:hmr ws client connected +2s

Activity

  1. ais-one commented on May 28, 2020

    @ais-one
    Contributor

    have you tried running it through snowpack? also quite a lot of UI Frameworks have the problem of needing webpack to work properly...

    You might need to rely on browser builds instead (where you just include as script tag in the html)

    You can try looking into web-components also

  2. yyx990803 commented on May 28, 2020

    @yyx990803
    Member

    The entry issue is already fixed in 63b0e3c

    But the bigger problem is @elastic/eui assumes webpack so it does a lot of problematic things:

    • Ships a ESM build but imports:
      • Nested pinned dep of react-is (which is a CJS dep)
      • CJS build of lodash
      • A dep that requires crypto which is a node built-in

    It only worked because webpack handles it, but this is just wrong. If you are shipping ESM you shouldn't depend on things that are actually CJS.

  3. joshacheson commented on May 28, 2020

    @joshacheson
    Author

    @ais-one I did try snowpack, and it also wouldn't build (seems reasonable that even though the surfaced error was different the root cause was more or less the same).

    @yyx990803 thank you for looking into this. It looks like I should use another build tool if I'm attached to @elastic/eui.

    I feel bad for surfacing an example of what seems like an existential problem! If there's some way I can be helpful please let me know.

    edit: I guess at the very least I will mention this to the @elastic/eui folks but of course hold no expectation they'll work through this issue. Seems like it might be a doozy.

  4. yyx990803 commented on May 28, 2020

    @yyx990803
    Member

    I actually made it work by upgrading to @rollup/plugin-commonjs 12.0.0 but only when certain peer deps are deduped and placed in devDeps. Still trying to pinpoint the issue in the rollup plugin.

  5. yyx990803 commented on May 28, 2020

    @yyx990803
    Member

    With 2f071b3 it works but requires excluding @elastic/eui's peer deps (in particular react-is, prop-types) via optimizeDeps.exclude. There is a bug in @rollup/plugin-commonjs being tracked at rollup/plugins#424 but there's nothing else can be done on Vite's side.

  6. locked and limited conversation to collaborators on Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions