preactjs / wmr

👩‍🚀 The tiny all-in-one development tool for modern web apps.
https://wmr.dev/
MIT License
4.92k stars 109 forks source link

"Invalid Specifier" when import location has >1 forward slash #876

Open bhallstein opened 3 years ago

bhallstein commented 3 years ago

Today I tried to switch from parcel to wmr as the runtime for our medium-sized preact project, which uses @heroicons/react as an icon library.

Describe the bug

With @heroicons/react, to import an icon you write, for example: import {XIcon} from '@heroicons/react/outline'. (Or for solid icons, @heroicons/react/solid.)

When wmr is started and the app accessed through the web browser, wmr then emits an error message, "Invalid specifier" for the import location '@heroicons/react/outline'.

To Reproduce

Steps to reproduce the behavior:

  1. npm i -S @heroicons/react
  2. Add an import such as: import {XIcon} from '@heroicons/react/outline'
  3. Run the app with wmr and load localhost:8080 in a browser.
  4. See error

Expected behavior

Bug occurs with:

I haven't tested on build / serve.

Desktop:

Additional context

WMR is amazing, I'm really looking forward to using it ❤️

rschristian commented 3 years ago

Odd, I cannot seem to reproduce myself (Linux, Node 14 & 16)

Can you reproduce in a brand-new project?

bhallstein commented 3 years ago

Trying to minimally replicate in a fresh repo: https://github.com/bhallstein/wmr-testing

So, I then tried adding both @heroicons/react and otter-editor as dependencies. This led to some errors that are similar to the one I wrote about above — hard to tell if it's a different issue or the same.

Screenshot 2021-09-28 at 11 48 43

When otter-editor is prepared for publishing to npm, it is simply transpiled with babel — babel src/index.js -d dist && babel src/core -d dist/core. A typical transpiled import then looks like this:

var _reactQuill = _interopRequireDefault(require("react-quill"));

Happy to update the original issue if we can clarify further.

LeuisKen commented 2 years ago

Any progress? I met the same problem when using @babel/traverse