Replies: 1 comment
-
|
Did you ever find a solution? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am trying to use react-imask in Next.js. Since it is an old project it still uses babel.
When the project is build, all imports are converted to require and the page complains that react-imask/imask packages modules and import statement should be used.
imask.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename imask.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /node_modules/imask/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).This was not an issue in versions react-imask@7.0.1 and imask@7.0.1 but after an upgrade, imask is installed as 7.1.3 and it is also breaking the page. installing 7.1.3 of react-imask immediately breaks the page.
Error: require() of ES Module /..../node_modules/imask/dist/imask.js from /.../react-imask/dist/react-imask.js not supported.I temporarily fixed by pinning both versions to 7.0.1 but it is a big issue for us to solve this.
I've tried dynamic import of NextJS but one can admit that it is also not a proper solution.
I guess providing a cjs dist can solve the issue as mentioned in this PR and that would be awesome if this was prioritized.
#912
Do you have any other solutions?
Beta Was this translation helpful? Give feedback.
All reactions