-
Notifications
You must be signed in to change notification settings - Fork 7
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 function when importing float16 from another library in CRA which uses module bundler #900
Comments
To verify other libraries work i've also required lodash: const array = require('lodash/array'); and simply print within the conversion function at beginning: console.log(array.chunk(['a', 'b', 'c', 'd'], 2)); No issues there. Could be some mismatch in the way float16 is exported? |
I have tried it with the latest CRA and have confirmed this issue. It appears that the CommonJS style with const f = require("@petamoriken/float16");
console.log(f); // => "/static/media/index.9ea9595cf22b971e0a2e.cjs" On the other hand, the ES Module style seems to work fine. import { getFloat16 } from '@petamoriken/float16';
function conversion(value) {
var buffer = new ArrayBuffer(4);
var view = new DataView(buffer);
view.setUint16(0, value);
return getFloat16(view, 0, false);
} |
Potentially an issue with CRA Add support for CJS files #12700 |
Or webpack in general since main and module is defined in package.json webpack/webpack#5756 (comment) |
Probably a CJS issue for the CRA. Line 41 in ccd5cf9
|
I can confirm that - I've just posted a comment on the CRA issue - this is how i've worked around it for now: facebook/create-react-app#12700 (comment) |
Scenario:
My library contains your package as a dependency, this library is imported from create-react-app (CRA) project.
Library code:
The issue:
Why would the import inside the CRA project be undefined when the library has it as dependency?
I've checked for circular dependencies using:
npx madge --circular --extensions ts,js ./
The text was updated successfully, but these errors were encountered: