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

Uncaught ReferenceError: exports is not defined at version 3.3.18 and Parcel #8675

Closed
irenlian opened this issue Aug 20, 2021 · 9 comments
Closed
Assignees
Labels
🏓 awaiting-team-response requires input from the apollo team 🌤 has-workaround

Comments

@irenlian
Copy link

Intended outcome:

The version of @apollo/client is upgraded from 3.3.17 to 3.3.18 safely and the built application is running without issues.

Actual outcome:

After upgrade and build without issues, the application fails from the start with a blank page and an error in console:

Uncaught ReferenceError: $24a7145fde937c9e5b0a055eaa64c5e1$exports is not defined

How to reproduce the issue:

  • Set dependencies:
"@babel/core": "^7.10.1",
"@parcel/config-default": "^2.0.0-beta.1",
"@parcel/transformer-typescript-tsc": "^2.0.0-beta.1",
"@parcel/validator-typescript": "^2.0.0-beta.1",
"parcel": "^2.0.0-beta.1",
"@apollo/client": "3.3.18",
  • Parcel config .parcelrc:
{
  "extends": "@parcel/config-default",
  "transformers": {
    "*.{ts,tsx}": ["@parcel/transformer-typescript-tsc"]
  }
}
  • tsconfig.json
{
    "compilerOptions": {
        "target": "es6",
        "resolveJsonModule": true,
        "module": "commonjs",
        "jsx": "react",
        "outDir": "./dist",
        "rootDir": "./src",
        "strict": true,
        "moduleResolution": "node",
        "baseUrl": "./src",
        "paths": {
            "~/*": ["./*"]
        },
        "types": [
            "./src/models",
            "node",
            "jest"
        ],
        "esModuleInterop": true,
        "experimentalDecorators": true,
        "skipLibCheck": true
    },
    "exclude": ["dist/**", "node_modules/**.*"]
}
  • Run build command npx parcel build src/index.html
  • Run with Nginx (if it matters) and open in browser

Versions

System:
    OS: macOS 11.5
  Binaries:
    Node: 16.6.1 - /usr/local/bin/node
    Yarn: 1.22.10 - ~/stockX/viper/node_modules/.bin/yarn
    npm: 7.20.5 - /usr/local/bin/npm
  Browsers:
    Chrome: 92.0.4515.159
    Firefox: 90.0.2
    Safari: 14.1.2
  npmPackages:
    @apollo/client: 3.3.18 => 3.3.18 
    @apollo/link-error: ^2.0.0-beta.3 => 2.0.0-beta.3 
    apollo: ^2.31.0 => 2.32.1 
    react-apollo: 3.1.5 => 3.1.5

I assume that this PR that corresponds this patch may still miss some side effects and should include some dependencies to avoid their truncation.
Since I have the same error but on other line of code if upgrading to 3.4.8, I assume that there could be more side effects.

@irenlian irenlian changed the title Uncaught ReferenceError: exports is not defined at version 3.3.18 Uncaught ReferenceError: exports is not defined at version 3.3.18 and Parcel Aug 20, 2021
@benjamn
Copy link
Member

benjamn commented Aug 20, 2021

@irenlian Can you share the stacktrace leading to that ReferenceError?

@brainkim brainkim added the 🏓 awaiting-contributor-response requires input from a contributor label Aug 20, 2021
@irenlian
Copy link
Author

Unfortunately, there is not much information in the stacktrace here.

Here are screenshots from the console.

Screenshot 2021-08-20 at 12 36 34

Screenshot 2021-08-20 at 12 36 50

Let me know if I can attach anything additionally.

@benjamn
Copy link
Member

benjamn commented Aug 25, 2021

It's strange there's no long $...$exports variable visible in the code where the red squiggly line appears. Can you try temporarily disabling JS source maps to see if there's more to this code than meets the eye?

Alternatively, if your application is using client.onClearStore to register client.clearStore callbacks, I guess there's some possibility one of those callbacks might trying to refer to the $...$exports variable, and for some reason the error is reported here rather than in the function itself?

@irenlian
Copy link
Author

Here are screenshots (I used pretty-print) after disabling source maps. And it doesn't seem to help much, unfortunately.

Screenshot 2021-08-26 at 19 02 54

Screenshot 2021-08-26 at 19 03 10

@irenlian
Copy link
Author

I also searched for onClearStore throughout the codebase, we don't use it. So I hope it is not the reason.

@benjamn benjamn removed the 🏓 awaiting-contributor-response requires input from a contributor label Aug 26, 2021
@irenlian
Copy link
Author

For anyone who are searching for a workaround, here is what works for me:
Replace import from

import { ApolloProvider } from "apollo/client"

with

import * as apolloClient from '@apollo/client';
const { ApolloProvider } = apolloClient;

@benjamn benjamn self-assigned this Sep 10, 2021
@bignimbus bignimbus added 🌤 has-workaround 🏓 awaiting-team-response requires input from the apollo team labels Dec 2, 2022
@phryneas
Copy link
Member

phryneas commented Aug 5, 2024

I believe this is a quirk of Parcel, not a bug in how Apollo Client is packaged. Since nobody else has reported encountering this in a very long time and a workaround is available, I'm going to close this issue.

@phryneas phryneas closed this as completed Aug 5, 2024
Copy link
Contributor

github-actions bot commented Aug 5, 2024

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.

Copy link
Contributor

github-actions bot commented Sep 6, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🏓 awaiting-team-response requires input from the apollo team 🌤 has-workaround
Projects
None yet
Development

No branches or pull requests

5 participants