-
Notifications
You must be signed in to change notification settings - Fork 9
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: Can't resolve react-component-lib since v4.0.0 #495
Comments
Hi @mkilp 👋 There is an upstream issue which includes a workaround which you can use until the upstream issue is resolved / until we find a proper fix for this:
import { createReactComponent } from './react-component-lib/index.js';
npx patch-package @emdgroup-liquid/liquid
I'm attaching my patch file here: @emdgroup-liquid+liquid+4.4.1.patch It would be great to have more information on your project setup in order to be able to reproduce the issue and see, if this is something that we can fix on our end or if we need to communicate this further to an upstream project with the additional information. Feel free to update your issue description with anything that may seem relevant (are you using Webpack? Which version? CRA? Next? Which version? etc. ). |
Hello, Similar issue here when updating to liquid v4.3.5. App is using CRA with version
|
We are using CRA, with JS and react-scripts 5.0.1. Thanks for the help, I will take a look at the workaround! |
@borisdiakur the workaround sadly does not work at all and creates a whole bunch of downstream problems.
I think there might be some incompatibilities with react-scripts 5.x. I will try downgrading to 4.x and see if that helps. |
Update: Downgrading react-scripts to |
@mkilp This is a good hint. Setting resolve.fullySpecified in the webpack config to |
That might help. For now we will use the downgraded react-scripts as we don't want to |
I have created a sandbox app with CRA and liquid: |
I have created a pull request to the stencil-ds-output-targets project. Let's hope someone from the Stencil team will pick it up soon. In the meantime I'll try to create a patch for @emdgroup-liquid/liquid, so that you do not need to apply any workarounds in your own projects. |
🎉 This issue has been resolved in version 4.4.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Hello, Upgrading to v4.4.3 does not fix the issue in our repository. I have created a minimal app to reproduce the issue. Maybe it works for the original issue. If needed, I can open a new issue.
Edit: Switching to import { defineCustomElements } from '@emdgroup-liquid/liquid/dist/loader';
defineCustomElements(); when using liquid v4.4.3, is fixing the issue. |
Hi @vvision,
// use liquid.global.css if you are not using CSS components. It's way smaller than liquid.css
import "@emdgroup-liquid/liquid/dist/css/liquid.global.css";
import { defineCustomElements } from '@emdgroup-liquid/liquid/dist/loader'
// @ts-ignore
window.__LD_ASSET_PATH__ = `${window.location.origin}/liquid`
defineCustomElements() // this line is important for the components to work
import './App.css';
import './liquid';
import {
LdTypo,
LdButton,
} from '@emdgroup-liquid/liquid/dist/react'
function App() {
return (
<div className="App">
<LdTypo variant="b2">
App Title
</LdTypo>
<br/>
<LdButton size="sm">A button</LdButton>
</div>
);
}
export default App; I strongly recommend using the React bindings, because you'll benefit from type checking and intellisense. And of course, your issue will be resolved. You can have a look at our create-react-app sandbox application for a complete working example. |
Thanks for the insights! Using React bindings indeed fixes the issue, but the automatic lazy loading introduces very surprising behavior, with our main centered content being displayed first, then the left menu and finally, the footer and the header. I'm also seeing similar behavior on https://github.com/emdgroup-liquid/liquid-sandbox-cra-tailwind, when throttling network to "Slow 3G". Which I assume is normal because of lazy loading. I read about custom elements in Stencil doc to assess liquid dist-custom-elements. import "@emdgroup-liquid/liquid/dist/css/liquid.global.css";
import { defineCustomElement as defineButton } from '@emdgroup-liquid/liquid/dist/components/ld-button';
defineButton(); |
Hi @vvision import { LdButton as LdButtonCE } from '@emdgroup-liquid/liquid/dist/components/ld-button'
import { LdButton } from '@emdgroup-liquid/liquid/dist/react'
// @ts-ignore
customElements.get('ld-button') ||
customElements.define('ld-button', LdButtonCE) However, due to how CRA handles imports from ESM modules this is currently not working. It would also involve a lot of patching of stencil code, just to fix quirks on CRA side. What you could do is, you could adjust your Webpack config without ejecting using craco (see this issue for reference). However, I would rather suggest to switch over to using Vite and forget about CRA. Using Vite solves all the issues listed above. You can have a look at our Vite based react sandbox app, if you'd like to take Vite for a spin. Otherwise, if you must stay with CRA and feel that the current solution with lazy loading doesn't work for you, I'd like to ask of you to open up a new issue. |
Prerequisites
Liquid version
4.0.0 + (Tried 4.3.5 and 4.0.0)
Framework bindings
React
Current behavior
Cannot use Liquid anymore since the switch to ESM modules.
Breaks with following error:
Expected behavior
Liquid imports as expected.
Steps to reproduce
Not able to reproduce in public sandbox.
Code reproduction URL
Not able to reproduce in public sandbox.
Additional information
Feel free to reach out for a private demo on MS Teams if bug is unknown to the team!
The text was updated successfully, but these errors were encountered: