-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Bug]: FeatureFlags queried on import wrong if package imported indirectly (Vite dev only) #13505
Comments
The most likely culprit is |
@lee-chase I think you're onto something with suspecting The feature flags code is currently listed in carbon/packages/react/package.json Lines 129 to 131 in a95ac1d
When For the production builds, Vite uses Rollup, which interestingly enough had a recent update to properly respect I see your example uses Vite v2 - I'm curious if you see the same behavior when using Vite v3? Something mentioned in the changelog caught my eye
|
@lee-chase Also on the Vite docs about pre-bundling, I found this
So you might also try customizing the pre-build behavior or explicitly turning off tree shaking when vite uses esbuild via the |
@tay1orjones can we not simply update Carbon to replace the |
@lee-chase Switching the flag to be an inverse " |
Yes, just a sidestep but it would unblock @carbon/ibm-products temporarily. |
@tay1orjones having copied the sample, possibly from Carbon, I had not realised the version of Vite was so out of date. Updating to 4.3.4 appears to fix this. |
@lee-chase Great news! I too didn't realize Vite was so out of date. We need to update our examples to use v4.x #13683 |
I'm going to close this out but happy to reopen if there's still issues. We could always explore turning the v11 flag on at the root to avoid it ever being set carbon/packages/feature-flags/feature-flags.yml Lines 21 to 24 in 36685a0
Right now it's currently turned on within
|
Package
@carbon/react
Browser
Chrome
Package version
1.26
React version
17
Description
When using Vite in dev mode when Carbon is referenced/loaded through a third party library Vite the feature flags queried on import are wrong.
This does not happen if using 'vite preview' which uses production built code.
NOTE: This will prevent @carbon/ibm-products from working with Vite and V11 support.
Reproduction/example
https://stackblitz.com/edit/github-l56ye7?file=src%2FApp.jsx,fake-package%2Fpackage.json,fake-package%2Findex.js,src%2FExample.jsx
Steps to reproduce
These steps are copied from carbon-design-system/ibm-products#2734
On loading this example may work (depending on state left in). If so follow the steps below to move 'fake-package' is into node_modules and run again.
Steps.
NOTE: You may need to refresh the preview pane (not the whole page as this causes a reinstall of node_modules).
NOTE2: If you want to flip between the two scenarios you will need to delete the vite cache node_modules/.vite between runs.
Note if running this locally you will need to remove 'node_modules/.vite' between runs if changing node modules to bypass the cache.
Further testing...
Stack traces from the from local runs show that only Import time tests are impacted listing every component in @carbon/react that performs such a test and showing
enable-v11-release
evaluates to false. Only later whenDropdown
performs a runtime test is the value correct.Suggested Severity
Severity 2 = User cannot complete task, and/or no workaround within the user experience of a given component.
Application/PAL
@carbon/ibm-products
Code of Conduct
The text was updated successfully, but these errors were encountered: