Comments (4)
This seems to be an error that only occurs with testing, and it seems like this is an error specifically with jest - it is expecting the imports to be CJS unless you make some special notation. (Apps work just fine).
For the moment, you can indicate to jest that the jsfive import is an ES module, by
- "test": "react-scripts test", + "test": "react-scripts test --transformIgnorePatterns \"node_modules/(?!(jsfive))/\"",
Longer term, I am updating the package.json (see 64e0927) so that the imports are identifiable as CJS and ESM. This will affect the next release.
from jsfive.
Thanks. That solution works for the specific problem with Jest, so I will close this issue.
I am still having problems with versions after 0.3.5, though. Specifically, I have an NPM module, B, that imports jsfive
, and then an application, A, created with create-react-app
that imports B (using npm link
for development). I can start A but when it calls code from B it fails:
TypeError: hdf5.File is not a constructor
B.js:112 stack: TypeError: hdf5.File is not a constructor
at FileReader.reader.onload (https://localhost:3000/static/js/main.chunk.js:230:34)
I don't need any fancy HDF5 capabilities, so for now, at least, my solution is to just continue using 0.3.5, but I am hoping the problem is solved in the next release, as you mentioned.
from jsfive.
I am having trouble reproducing the issue you describe - I created a dummy package jsfive-test
with an installed [email protected] and this index.js:
import * as hdf5 from 'jsfive';
const DEFAULT_URL = "https://ncnr.nist.gov/pub/ncnrdata/vsans/202009/27864/data/sans66167.nxs.ngv";
export async function load_and_show_keys(file_url = DEFAULT_URL) {
const result = await fetch(file_url);
const ab = await result.arrayBuffer();
const f = new hdf5.File(ab, "file");
const keys = f.keys;
console.log(keys);
return keys;
}
And then I did npx create-react-app
in a separate folder, and npm link ../../jsfive-test
, and added these lines to the header of src/App.js, and it is able to run and outputs the expected keys for the loaded file when I run npm start
import logo from './logo.svg';
import './App.css';
import {load_and_show_keys} from 'jsfive-test';
load_and_show_keys();
...
Are you building the intermediate library B with webpack or something like that? I would like to reproduce the problem so I can verify that the new package.json
layout would address it.
from jsfive.
I think in 0.3.6 to 0.3.9 I wasn't creating a CommonJS module, and I think that is what is getting pulled into CRA for some reason (this seems to happen in webpack).
I have added a CommonJS module back into version 0.3.10
from jsfive.
Related Issues (20)
- Link message "length of link name" calculated incorrectly
- Support for Node.js HOT 7
- Uncaught (in promise) ReferenceError: hdf5 is not defined HOT 3
- Fail create hdf5.File - signature assert HOT 5
- Version 0.3.3 won't compile with `create-react-app`. HOT 18
- Compound Datatype HOT 3
- JSFive to support VBZ compression HOT 10
- Latest changes on master not published on NPM HOT 1
- Npm version 0.3.8 has an issue when resolving imports HOT 4
- Import problems after upgrading to version 0.3.8 HOT 2
- Question: Will all data be loaded as a single consecutive array? HOT 2
- URI malformed error while fetching attrs HOT 5
- v0.3.9 throws TypeError when calling hdf5.File HOT 5
- Range Error with Compressed Files HOT 13
- jsfive throws an error with unsupported superblock version with a valid file HOT 11
- Remote hdf5 file access HOT 27
- RangeError: Offset is outside the bounds of the DataView HOT 7
- Node.js built with icu_small returns error upon loading ArrayBuffer HOT 1
- Not available on npm? HOT 19
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsfive.