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

Automatic inclusion of package.json breaks Next SSG #625

Closed
1 of 2 tasks
tjzel opened this issue Sep 8, 2024 · 4 comments
Closed
1 of 2 tasks

Automatic inclusion of package.json breaks Next SSG #625

tjzel opened this issue Sep 8, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@tjzel
Copy link

tjzel commented Sep 8, 2024

Description

After bumping react-native-builder-bob in Reanimated monorepo, our example app using Next stopped building with a very obscure error.

Errors screenshots

Screenshot 2024-09-08 at 13 21 12

Screenshot 2024-09-08 at 13 19 44

Obviously this file doesn't have any instances of global and it worked well before the bump.

After investigation turns out the culprit is enforced addition of package.json into the build directory added in

I don't exactly understand why is that causing the error, especially that the error message and the callstack itself don't provide any useful information.

Packages

  • create-react-native-library
  • react-native-builder-bob

Selected options

 {    "source": "src",
    "output": "lib",
    "targets": [
      "module",
      "typescript"
    ]
  }

Link to repro

https://github.com/software-mansion/react-native-reanimated/tree/main/apps/next-example

Environment

Irrelevant, since it breaks in GitHub actions as well.

@tjzel
Copy link
Author

tjzel commented Sep 8, 2024

Hey @satya164, thanks for the quick release! I tested it and unfortunately the inclusion of package.json with "type":"commonjs" still breaks Next 😢

Screenshot 2024-09-08 at 15 45 08

Also, using the following config:

{
    "source": "src",
    "output": "lib",
    "targets": [
      [
        "module",
        {
          "esm": true
        }
      ],
      "typescript"
    ]
}

results in the same error as in the original issue.

@satya164
Copy link
Member

satya164 commented Sep 8, 2024

@tjzel seems like this is a NextJS bug :<
type: commonjs should behave exactly like having no type. without this there is no way to support specifying type: module in root package.json. we can temporarily remove the package.json but it's not a permanent solution.

@satya164
Copy link
Member

satya164 commented Sep 8, 2024

results in the same error as in the original issue.

When ESM option is enabled, afaik it's necessary to use globalThis instead of global since global is a legacy thing.

@tjzel
Copy link
Author

tjzel commented Sep 9, 2024

I replaced all uses of global in Reanimated with globalThis, even though files using global shouldn't be loaded into the Next example, and the issue persists. It must be something very eerie about Next/Webpack.

Thank you for the 0.30.2 version, with esm: true it works now as before 🥳

github-merge-queue bot pushed a commit to software-mansion/react-native-reanimated that referenced this issue Sep 9, 2024
…der-bob` (#6494)

## Summary

Without this fix our Next example breaks. You can read more in the [open
issue](callstack/react-native-builder-bob#625).

## Test plan

- Next GitHub actions pass
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