Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commonjs module system instead of ESNext #109

Closed
yashmahalwal opened this issue Jan 5, 2021 · 1 comment
Closed

Commonjs module system instead of ESNext #109

yashmahalwal opened this issue Jan 5, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@yashmahalwal
Copy link

yashmahalwal commented Jan 5, 2021

I recently installed the v1.3.2 version in a next.js project. The compilaton failed with the following error message:


import { transformToNestObject } from 'react-hook-form';
^^^^^^

SyntaxError: Cannot use import statement outside a module

Which was in the file /node_modules/@hookform/resolvers/dist/yup.js:2
On inspection, I found that the built files has import statements. That means they'd need to be transpiled before using. I believe that it is not a good practice to transpile code from node_modules (especially if it is from a third party library).

I noticed in the source code that v1.3.1 and later tsconfig with had the following option:
"module": "ESNext"

Whereas v1.3.0 has:
"module": "commonjs"

Downgrading to v1.3.0 fixes the import issue. I suggest changing the tsconfig.json. In case it was intentional, I'd like to know the rationale behind it.

@jorisre
Copy link
Member

jorisre commented Jan 5, 2021

Thanks for reporting

Duplicate of #100

Problem solved in V2 currently in beta, more detail here: #71 (comment)

@jorisre jorisre closed this as completed Jan 5, 2021
@jorisre jorisre added the bug Something isn't working label Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants