Closed Benjaki2 closed 2 years ago
Perhaps directly importing kekule.min.js
would work? e.g.:
import * as K from './node_modules/kekule/dist/kekule.min.js';
console.log(Kekule.VERSION);
@Benjaki2 did you find a solution?
Thanks @partridgejiang.
@filoscoder My solution was a mix of what @partridgejiang stated above and dynamic imports. The solution does not do SSR (server-side-rendering) but it works. This seems necessary because Kekule depends on the window
object.
const DynamicComponentWithNoSSR = dynamic(
() => import('../components/hello3'),
{ ssr: false }
)
relates to #262 --- closing.
Next.js docs say
Calling require directly is not allowed. Use ES Modules instead
. It appears the middleware does not allow for this.Error I see:
For what it's worth, Kekule seems to work when not present on initial load.
I am considering trying to transpile the code to ES6 modules with something like the
cjs-to-es6
npm module. @partridgejiang do you have any suggestions? Thank you for all your work/help!