Remove type: "commonjs" to fix importing in NextJS #270
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When
"type": "commonjs"
is specified in our package.json, it apparently causes the following problem in NextJS:This is odd, since we indeed are using "commonjs" type, as that's the default (https://nodejs.org/api/packages.html#type), but it seems that fortunately merely omitting this resolves import errors in NextJS, and still supports NodeJS, based on my testing.
Should resolve #264, removing one of the changes from #259, while still hopefully keeping #256 fixed.
Note that I did try other approaches in attempting to fix NextJS and still support Node:
@mui/icons-material
bumped to v6 for supposed "proper" ESM support Project build fails with mui-tiptap v1.10.0: Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (1:0) #264 (comment), but that still caused problems in the Node context. It seems icons-material still doesn't use.js
extensions, so is still not correct."type": "module"
, using.js
extensions for all relative imports in the project (enforced/automated with the eslint plugineslint-plugin-require-extensions
). This seemed like an improvement, but still seems it would require some workarounds for lodash and/or mui/icons-material like in Use tsup to build project compatible with CJS and ESM, and validate in CI #258 in the Node context, as those imports of the third party dependencies failed when importing mui-tiptap.