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
Integration in Angular failing to import flattenChildren() #914
Comments
This issue seems related, however I don't know what role webpack plays in the whole setup |
Hey, thanks for the report! This is very enigmatic. Fortunately, we've done a round of dependency upgrades a few weeks ago in #897, after the latest v1.3.0 release. So before going further, I'd recommend waiting for the next release to see if the error disappears. We'll try to do the release asap, hopefully next week. |
Thanks for the feedback. To add some more information: I tried an alternate setup where I made a small pure react app (with create-react-app cli) setting up just h5web, and I'm getting exactly the same issue. Hopefully your new release helps out! Also - doing all this on Windows. Maybe that's part of the issue. |
Hey, is there any information on the schedule for the upcoming release? Thanks in advance! |
Should be this afternoon or tomorrow. 😉 |
Perfect, thanks |
v1.4.0 landed this morning. You can give it a try and tell us if it fixes your issue 🙂 |
Hmm sorry to hear that. Do you use |
I use plain NPM. Maybe you can try making a small project where you import just h5web in a plain NPM setup? |
Yep, I'm on it 😉 Got stuck for a sec on trying to create a new CRA app with v4.0.3 (they've released v5 recently, which we haven't tested yet). This is the magic command, FYI: |
So here is what I've done and it seems to work (on Windows 10, with $ npx create-react-app --scripts-version 4.0.3 my-app
$ cd my-app
$ npm install --save @h5web/app In import "@h5web/app/dist/style-lib.css";
import "@h5web/app/dist/style.css";
import React from "react";
import { App, MockProvider } from "@h5web/app";
function MyApp() {
return (
<div style={{ height: "100vh" }}>
<MockProvider>
<App />
</MockProvider>
</div>
);
}
export default MyApp; npm start |
Alright I'll give that a try on my side as well. Just to be sure: with the MockProvider, you also pass through the "Toolbar" function?
|
Your example works on my end. And if I replace the MockProvider with a H5GroveProvider pointing to my backend URL, it also works. Guess I have to find out where I'm doing things differently now in my other experiments... |
Ah, some progress! Thanks to your hint I noticed that my experimental application (outside of the actual react project) was using react-scripts 5. Reverting to v4 fixes the issue. I'm trying to force the same changes now on my main application but I haven't gotten it fixed just yet. Will keep you updated. |
Yeah, Given what we've excluded so far, I'd be willing to bet that the issue comes from Angular's webpack config/version. |
It does seem like Angular 13 imposes Webpack 5, and I agree with your analysis that the issue seems to be there. What would be required to get h5web working with Webpack 4? I don't know how many Angular versions I'd have to go back to get to Webpack 4, I'll try to look into it ... |
We're currently working on another round of upgrades, including CRA v5 for the demo, which includes webpack 5. That being said, if I understand the issue you linked to, it seems webpack 5 will uncover the issue above, not fix it, so we may have to take the problem to EDIT Sorry, the problem is not quite the same, since |
I fear I don't understand enough about how webpack and all the other "behind the scenes" mechanisms work to contribute something useful :-| |
We've just released |
I'm getting this funky error when I build my application:
I have no idea what it's about, I'll try and google my way out. |
Hmm yeah, okay. It's because I removed As mentioned, I think the way forward would be for you to set up a minimal reproduction repository that we can play with. |
I created a minimal Angular project with a wrapper for h5web using the It's the example project here: https://github.com/wlievens/h5web-issue-914 Instructions in the README in the example dir should be enough. |
Hey, have you had time to try and reproduce the issue? |
I've managed to make it work, sorry for the wait. I've released the fix in a beta version: After the PR above, #940, which did not fix the issue, I tried bundling |
I'm still not convinced the problem comes from the Regardless, I've opened an issue grrowl/react-keyed-flatten-children#3 to suggest providing an ESM build. |
I tested your new build and this works! I don't understand where the issue comes from either but I'm not very knowledgeable on how various kinds of bundles and imports in JS work, but I'm happy of course it works like this now. |
Hi @wlievens, It will go out in the next major release, along with the React 18 upgrade. Please do get back to us then, if the error comes back. |
Describe the bug
I'm attempting to integrate the component in an Angular application.
This is partially successful, I made an Angular wrapper component where I instantiate the h5web component as follows:
My backend is h5grove compatible at the URL where I am testing it. I can browse the HDF5 tree just fine and can see metadata, attributes, and scalar values.
However, when I click a multidimensional dataset node, I get the following error:
react_keyed_flatten_children__WEBPACK_IMPORTED_MODULE_5__ is not a function
I traced this to the following line in the
Toolbar
function/class and checked with some console prints, and it indeed isn't a function ... it's thereact-keyed-flatten-children
module object being referred at the following line:const allChildren = flattenChildren(children).filter(isReactElement);
If I replace that line with:
const allChildren = flattenChildren.default(children).filter(isReactElement);
everything works fine! So somehow it is failing to recognise the default export on
flattenChildren
when I integrate the component in Angular.Now, I don't know much about TypeScript and JavaScript's import magic, so I tried various combinations of setting the tsconfig values for
esModuleInterop
,allowSyntheticDefaultImports
,isolatedModules
and so forth but to no avail.To Reproduce
I'm not sure anyone is interested in debugging my Angular setup since this is a React component so I was hoping for some wisdom from above regarding the peculiarities of TypeScript and/or JavaScript's import behaviour. If that leads us nowhere I can always try setting up a clean Angular sample app.
Expected behaviour
No errors on a trivial function import.
Screenshots
Context
The text was updated successfully, but these errors were encountered: