TypeError: Object(...) is not a function
tatchi opened this issue · 2 comments
TypeError: Object(...) is not a function
With the new version 0.11 which fix issue #1, I have now an error when trying to import the getBundles
function.
import { getBundles } from 'react-loadable-ssr-addon'
Expected Behavior
No Errors
Current Behavior
I got the following error:
TypeError: Object(...) is not a function
Possible Solution
I was able to make it work if in the index.js
file, we export the two modules like that:
module.exports = { ReactLoadableSSRAddon, getBundles };
and we import them like:
const { ReactLoadableSSRAddon } = require('react-loadable-ssr-addon');
import { getBundles } from 'react-loadable-ssr-addon'
I was not able to find a way to keep the default export. I don't have any experience with bundling lib, but I suppose it's a problem with the different modules systems.
Thanks for reporting @tatchi .
This issue was not noticed before because in ours tests we were importing the getBundles
straight from its path, e.g. import getBundles from 'react-loadable-ssr-addon/lib/getBundles'
.
We will fix that and release a patch today.
Fixes for this bug was release in the v0.1.2
.
The initial compatibility was maintained, so you can return using the default import.
const ReactLoadableSSRAddon = require('react-loadable-ssr-addon');
// or
const ReactLoadableSSRAddon = require('react-loadable-ssr-addon/lib/ReactLoadableSSRAddon');
import { getBundles } from 'react-loadable-ssr-addon';
// or
import getBundles from 'react-loadable-ssr-addon/lib/getBundles';
Also in the Release history
we mentioned you due to your report.