remirror: Uncaught TypeError: module.exportDefault is not a function
Summary
When importing from most packages in Meteor (Babel compiler) I get the error
Uncaught TypeError: module.exportDefault is not a function
on client and I’m unable to proceed.
Steps to reproduce
meteor create remirrorcd remirrormeteor npm add remirror @remirror/react @remirror/pm @remirror/styles --save- Replace the content in
imports/ui/Hello.jsxwith:
import React from 'react';
import { useRemirror } from '@remirror/react';
export const Hello = () => {
return (
<div>
TEST
</div>
);
};
- run
npm run - Navigate in browser to
localhost:3000and you will see a blank page with the error in the console.
I have tried to recompile the package with Meteor build system, but without success.
Expected results
Error should not happen and imports should work normally.
Actual results
Application crashes with Uncaught TypeError: module.exportDefault is not a function
Possible Solution
Further testing revealed that import and use of: import { AllStyledComponent } from '@remirror/styles/styled-components'; works fine, so this might be a good start to look on what is different in package bundling between that one compare to the other ones.
Screenshot(s)

About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (16 by maintainers)
Just to let you know: the easiest solution I found is to override
jsx-dompackage (that generates this problem).node_modules/jsx-domto any directorypackage.jsonfile: set bothmainandmodulekeys tolib/index.cjs.jsjsx-domdirectory (i.e.tar czf jsx-dom-6.4.23.tar.gz jsx-dom)meteor npm i --save ./path/to/jsx-dom-6.4.23.tar.gzpackage.jsonfile:I attached a prepared package for you (you can skip step 1-3 in this case). I didn’t add any bloatware or I don’t intend to harm your code, but you do it on your own responsibility 👍
jsx-dom-6.4.23.tar.gz
EDIT: In case it doesn’t work please make sure that
package-lock.jsondoesn’t containjsx-domresolution for@remirror/extension-react-tablespackage.If you have the
module.exportDefault is not a functionerror when using Meteor, according to this comment, seems that we don’t have any way to fix this error directly for now.I can think of one workaround. You can create a separate git repo for your React editor component. This git repo is an NPM package that imports Remirror as a dependency as well as some of your own code. When building this package, embed the dependencies into the output file (for example, you can use ESbuild and the
--bundleoption). So remirror is in yourdevDependenciesinstead ofdependenciesinside your package.json. In the end, you will get a new NPM package that only contains one big JS file.By doing that, you can not only split up the complex editor logic, but also removed these
exportsfields in package.json which is not supported by Meteor (Because your Meteor project doesn’t require remirror directly).