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

[BUG] Fix "Try not defined" #45

Open
2 tasks done
Marius9595 opened this issue Oct 15, 2024 · 2 comments
Open
2 tasks done

[BUG] Fix "Try not defined" #45

Marius9595 opened this issue Oct 15, 2024 · 2 comments
Labels
bug Something isn't working hacktoberfest good issue to contribute in the hacktoberfest

Comments

@Marius9595
Copy link
Collaborator

Describe the bug.

GIVEN the library at v.1.1.0 in a nextjs project
WHEN it is used just the Either and the next build is executed
THEN an error of Try is not defined is raised when the compiler is collecting page data

Expected behavior

No error should be raised

Screenshots

image

How to Reproduce

  1. Import a Either in some file that it will be used in a page or route
  2. Then execute 'next build'
  3. And It should be raised a "Try not defined" when page data is collecting

👀 Have you checked for similar open issues?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

No, someone else can work on it

@Marius9595 Marius9595 added bug Something isn't working hacktoberfest good issue to contribute in the hacktoberfest labels Oct 15, 2024
@Marius9595
Copy link
Collaborator Author

I fixed the problem temporary, downgrading to 1.0.1 because I am just using Either monad in the project. But if someone want to use the new ones, it is needed to solve this issue

@Marius9595
Copy link
Collaborator Author

I was trying to fix this issue.

In order to work in a clean project, I created a blank one as follows:

npx create-next-app@latest my-nextjs-app

cd my-nextjs-app

Inside this project, I put the following code inside in the main page.tsx:

import { Either } from '@leanmind/monads';

const HomePage = () => {
  const right = Either.right(42);
  const left = Either.left('Error');

  return (
    <div>
      <p>Right: {right.isRight() ? 'Yes' : 'No'}</p>
      <p>Left: {left.isLeft() ? 'Yes' : 'No'}</p>
    </div>
  );
};

export default HomePage;

Workflow to analyze the problem

In order to work quickly, I have been applying the following workflow:

1. In monads repository

  1. Apply the experiment you think it can fix the issue
  2. Execute npm run build (if this dist folder exists, drop it) --> It creates the compiled library
  3. Execute npm pack --> creates the tarball file to be installed

2. In the test project with Nextjs

  1. Execute npm i <absolute-path-of-tarball-file-generated>
  2. Execute next build. If there is .next folder created, drop it because it caches some and It could give you a false positive/negative

3. Again step 1

Experiments performed:

  1. Delete Try --> ✅ It works. So it seems try is the problem
  2. Rename Try to Other --> ❌ It does not work, the error description substitutes "Try" with "Other" -> It seems the problem is related to the code
  3. Delete code and only export a file like:
abstract class Try {}

export { Try };

---> ✅ It works. Effectively, the problem is related to the implementation, something is weird, and it needs a revision

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hacktoberfest good issue to contribute in the hacktoberfest
Projects
None yet
Development

No branches or pull requests

1 participant