-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Undefined imports in production build with shared components #4083
Comments
As a workaround to this issue, you can use import { faMinusCircle } from "@fortawesome/free-solid-svg-icons";
import { faPlusCircle } from "@fortawesome/free-solid-svg-icons"; instead of import { faMinusCircle } from "@fortawesome/free-solid-svg-icons/faMinusCircle";
import { faPlusCircle } from "@fortawesome/free-solid-svg-icons/faPlusCircle"; |
@cuiqui it would be useful that you try to create a reproduction only using vanilla, so it is easier for others to check out. |
Thanks for the reply @patak-js, I ended up building the icon library instead of importing an icon in each component: import { library } from "@fortawesome/fontawesome-svg-core";
import { faMinusCircle, faPlusCircle } from "@fortawesome/free-solid-svg-icons";
library.add(faMinusCircle, faPlusCircle); Which in essence is your workaround. I'll try to make some time to create a vanilla reproduction, but I'm sorry I can't promise anything right now. |
This still seems to happen in Vite 2.8.6 |
Hi ✋🏻 I have a the same problem.
|
Also facing the same problem with vite 3.0.9. Trying to import a class with static members from a private shared package, import is undefined in production build. |
I have code similar to this:
Session class:
I found a weird workaround: adding |
Facing this problem with Shopify Polaris library and Vite.
Provider component gets undefined in the production build. |
same issue with EDIT: here is reproduction code https://github.com/zbigniewstefaniuk/vite-lib-on-build-resolving-issue |
i am facing same issue while having 2 entries, both have imported i read the compiled code and found something interesting, 3 js files generated ex: the actual declaration of i cant provide the actual code since it is a closed source project, but the below code is roughly how the compiled code will looks like // shared.js
var faMultiply = {};
export { faMultiply }; // entry1.js
import { faMultiply } from "./shared.js";
console.log(faMultiply.faMultiply); // <= undefiend since faMultiply is just empty object in shared.js // entry2.js
import { faMultiply } from "./shared.js";
(function(exports){
/* actual definition is here */
})(faMultiply);
console.log(faMultiply.faMultiply); // <= the definitions of the icon is logged properly the actual definitions is not compiled into the shared library, i hope this info is useful and i will try to see whether i can replicate it in a clean vanilla vite project or not when i am free |
Maybe you can use vite-plugin-mediapipe:https://github.com/Spencer17x/arca/tree/main/packages/vite-plugin/vite-plugin-mediapipe |
I believe this is fixed as of v3.0.0-alpha5, or, secifically 909cf9c from #8280. At least, a bisect using https://github.com/cuiqui/vite-issue-repo points to that commit. I'm unable to reproduce any of the other examples as of either @zbigniewstefaniuk it seems that import selfieSegmentation from "@mediapipe/selfie_segmentation";
const { SelfieSegmentation, VERSION } = selfieSegmentation; I'm not familiar enough with mediapipe to say whether or not there's a better way. |
Thanks for triaging this. Yeah I can also see that it's fixed now. I'll close this for now. Regarding |
Describe the bug
When building for production, several pages import from FontAwesome (
import { faXXX } from '@fortawesome/sub/faXXX.js'
). Some of those imports are shared between a lot of components. These shared imports indist/assets
are seen, after runningnpm run build
, as a separate chunk of the formfaXXX.hash.js
, apparently empty. Example from the repo to reproduce issue:Which produces following error in some pages:
Pages in which it does not result in error are those that concatenated the import code in its chunk as such:
More information: https://github.com/cuiqui/vite-issue-repo#weird-bundling
Reproduction
https://github.com/cuiqui/vite-issue-repo
System Info
System: OS: Linux 4.15 Ubuntu 18.04.5 LTS (Bionic Beaver) CPU: (4) x64 Intel(R) Core(TM) i5-4300M CPU @ 2.60GHz Memory: 160.38 MB / 11.43 GB Container: Yes Shell: 4.4.20 - /bin/bash Binaries: Node: 14.16.0 - /usr/bin/node npm: 6.14.11 - /usr/bin/npm Browsers: Chrome: 89.0.4389.114 Firefox: 87.0 npmPackages: vite: ^2.3.8 => 2.3.8
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: