unplugin / unplugin-icons

🤹 Access thousands of icons as components on-demand universally.
https://www.npmjs.com/package/unplugin-icons
MIT License
3.66k stars 131 forks source link

Virtual Svelte module ids should start with `\0` #274

Closed IanVS closed 1 year ago

IanVS commented 1 year ago

Describe the bug

This tool creates virtual modules for svelte, which can cause problems for other plugins which attempt to load those files, not realizing they are virtual. The plugin documentation for rollup specifies:

If your plugin uses 'virtual modules' (e.g. for helper functions), prefix the module ID with \0. This prevents other plugins from trying to process it.

So, should virtual modules created when unplugin-icons is configured with compiler: "svelte" be prefixed? Or is there another way that other plugins should detect these are virtual modules, ideally without hitting the filesystem?

See https://github.com/storybookjs/storybook/issues/20562 for the issue in Storybook.

Reproduction

https://github.com/enyo/storybook-test/tree/main/my-app

System Info

System:
    OS: macOS 13.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 16.05 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
    Yarn: 3.4.1 - ~/.yarn/bin/yarn
    npm: 8.12.1 - ~/.nvm/versions/node/v16.14.2/bin/npm
  Browsers:
    Brave Browser: 111.1.49.120
    Firefox: 110.0.1
    Safari: 16.2

Used Package Manager

npm

Validations

antfu commented 1 year ago

I feel that it's best for integrations to be able to process virtual modules. As in this case, our virtual module is mean to be processed by other plugins (we serve raw components).