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

v6 Named export 'faDiscord' not found #18677

Closed
3 of 7 tasks
alexcroox opened this issue Feb 10, 2022 · 12 comments
Closed
3 of 7 tasks

v6 Named export 'faDiscord' not found #18677

alexcroox opened this issue Feb 10, 2022 · 12 comments
Assignees
Labels
Milestone

Comments

@alexcroox
Copy link

alexcroox commented Feb 10, 2022

Describe the bug

"@fortawesome/fontawesome-svg-core": "1.3.0",
"@fortawesome/free-brands-svg-icons": "6.0.0",
"@fortawesome/free-solid-svg-icons": "6.0.0",
"@fortawesome/vue-fontawesome": "3.0.0-5",

Vue 3

<script setup lang="ts">
import { faDiscord, faPatreon, faTwitter } from '@fortawesome/free-brands-svg-icons'

[...]

<FontAwesomeIcon :icon="faDiscord" />

Oddly it works during development, just not build (using Vite)

import { faSteamSymbol, faDiscord, faTwitter, faPatreon } from "@fortawesome/free-brands-svg-icons";
                        ^^^^^^^^^
SyntaxError: Named export 'faDiscord' not found. The requested module '@fortawesome/free-brands-svg-icons' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@fortawesome/free-brands-svg-icons';
const { faSteamSymbol, faDiscord, faTwitter, faPatreon } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)

Screenshots
image

  • SVG with JS
  • Web Fonts with CSS
  • SVG Sprites
  • On the Desktop

Bug report checklist

  • I have filled out as much of the above information as I can
  • I have included a test case because my odds go way up that the team can fix this when I do
  • I have searched for existing issues and to the best of my knowledge this is not a duplicate
@tagliala
Copy link
Member

Hi!

Thanks for being part of the Font Awesome Community.

@robmadole since this only happens in development and it is related to Vue 3, is it possible that the issue belongs to the vue-fontawesome package?

@mcmxcdev
Copy link

Doesn't seem to be Vue specific. I just encountered this with SvelteKit:

Screenshot from 2022-02-12 12-14-29

@aaronleopold
Copy link

Same boat as @mhatvan, I am using sveltekit and pretty much got that same error. If I remove an icon, it just complains about the next one.

@d42ohpaz
Copy link

The faBackpack, faBuildings, and faComputerClassic are also missing.

@robmadole
Copy link
Member

Can anyone provide a reproducible example for me? That would help a ton.

@alexcroox
Copy link
Author

@robmadole since this only happens in development and it is related to Vue 3, is it possible that the issue belongs to the vue-fontawesome package?

To clarify, it's fine during development, it only happens when you come to bundle for production

@jasonlundien
Copy link
Member

jasonlundien commented Mar 15, 2022

Hi @alexcroox ---

I am not able to reproduce this build error, and perhaps could use your help if you have a few minutes to spare here or there.

  • I created a very short/simple Vue3 + Vite project here.
  • I was able to import Font Awesome and use the icons as mentioned on our Vue3 npm page.
  • I was able to npm run build (vite build) in my project --- the dist directory was created and no error messages popped in the console.

So if you get a chance, could you take a look and let me know what I am missing.

@jasonlundien jasonlundien self-assigned this Mar 15, 2022
@fabianmossberg
Copy link

I get the same problem, with a bunch of icons, as well as the icon method.

I uploaded it in a repo that is stripped clean of anything but FontAwesome, you can find it here.

https://github.com/fabianmossberg/fontawesome-problem

@jasonlundien
Copy link
Member

jasonlundien commented Mar 18, 2022

@fabianmossberg ---
Thank you for this... I will pull this down and work with it then!

@fabianmossberg
Copy link

@jasonlundien: One more thing.

It works perfectly if I do the following:

Edit the the following files:

node_modules/@fortawesome/fontawesome-svg-core/package.json
node_modules/@fortawesome/free-solid-svg-icons/package.json

By adding this:

"type": "module",

As suggested by this PR
#18720

But I assume that those files are generated by some other private repo, and that the change that is needed would be done there.

@fabianmossberg
Copy link

A workaround until the packages are shipped as esm is to fix it in the vite config.

In SvelteKit, edit svelte.config.js and add '@fortawesome/*' to kit.vite.ssr.noExternal

https://github.com/fabianmossberg/fontawesome-problem/blob/7357af392e3858b726520a95688bb2a82d9913e0/svelte.config.js#L4-L13

@robmadole
Copy link
Member

robmadole commented Jul 28, 2022

All we are going to focus the conversation about type: "module" in the PR #19041

@tagliala tagliala added this to the 6.2.0 milestone Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants