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

Module not found: Can't resolve '@builder.io/partytown/integration' #35630

Closed
1 task done
jlarmstrongiv opened this issue Mar 27, 2022 · 23 comments
Closed
1 task done
Labels
Script (next/script) Related to Next.js Script Optimization.

Comments

@jlarmstrongiv
Copy link
Contributor

jlarmstrongiv commented Mar 27, 2022

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

    Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 19.6.0: Tue Feb 15 21:39:11 PST 2022; root:xnu-6153.141.59~1/RELEASE_X86_64
    Binaries:
      Node: 14.18.1
      npm: 8.1.0
      Yarn: 1.22.10
      pnpm: 6.32.2
    Relevant packages:
      next: 12.1.2-canary.0
      react: 17.0.2
      react-dom: 17.0.2

What browser are you using? (if relevant)

Not relevant

How are you deploying your application? (if relevant)

Vercel, next build

Describe the Bug

warn  - Compiled with warnings

./node_modules/next/dist/pages/_document.js
Module not found: Can't resolve '@builder.io/partytown/integration' in '…'

Import trace for requested module:
./node_modules/next/document.js
./src/pages/_app.tsx

To ignore the warnings, use a custom webpack config:

      config.ignoreWarnings = [
        {
          module: /\.\/node_modules\/next\/dist\/pages\/_document\.js/, 
        },
      ];

Expected Behavior

No warnings. It worked in the last next version 12.1.0.

See recent merge of #34244

I like that PR. I would love to see a fix, rather than a rollback.

@housseindjirdeh and @ijjk

To Reproduce

Use a custom _app and _document and try building with webpack.

Probably not relevant, but I am using a monorepo and custom webpack config.

@jlarmstrongiv jlarmstrongiv added the bug Issue was opened via the bug report template. label Mar 27, 2022
@balazsorban44 balazsorban44 added the Script (next/script) Related to Next.js Script Optimization. label Mar 28, 2022
@balazsorban44
Copy link
Member

Are you using the recently introduced Script with an experimental worker strategy?

Have you tried canary yet?

In any case, would you mind attaching a reproduction/your code? 🙏

@ijjk ijjk added the please add a complete reproduction The issue lacks information for further investigation label Mar 28, 2022
@jlarmstrongiv
Copy link
Contributor Author

@balazsorban44

Are you using the recently introduced Script with an experimental worker strategy?

No, I was just updating my dependencies.

Have you tried canary yet?

Yes, I did try 12.1.2-canary.0

In any case, would you mind attaching a reproduction/your code?

If Vercel has a place where I could email / upload my private repo, I would do that.

@ijjk
Copy link
Member

ijjk commented Mar 28, 2022

@jlarmstrongiv if the repo is on GitHub and are able to invite myself @ijjk then that would be great, otherwise if you would prefer to share details more privately you can submit a ticket here https://vercel.com/support/request and reference this issue/message

@jlarmstrongiv
Copy link
Contributor Author

jlarmstrongiv commented Mar 28, 2022

@ijjk I invited you to the repo 👍

  1. run npm install in the root
  2. disable hiding the warnings in configs/next/src/index.ts
  3. run npx turbo run turbo:build
  4. cd apps/nextjs/example
  5. npm run turbo:build or npm run turbo:dev

@ijjk
Copy link
Member

ijjk commented Mar 28, 2022

@jlarmstrongiv it seems that project has unrelated errors and is trying to build with a custom bin/nextjs/build script that doesn't exist. Also an additional repo is attempting to be cloned during postinstall

@jlarmstrongiv
Copy link
Contributor Author

jlarmstrongiv commented Mar 29, 2022

@ijjk my sincerest apologies! I had gone through the steps from scratch a few days ago, but hadn’t checked on the latest version of the repo. Please pull the latest code (commit d93af2155df6754348eb72138fb1a5375fac8989) and try again.


You can safely ignore the additional repo cloning during postinstall—it is for monkey patching while I contribute to an upstream repo.

The script was accidentally gitignore’d.

I have run through and confirmed all the steps on a secondary machine 🤞

@balazsorban44 balazsorban44 added type: needs investigation and removed bug Issue was opened via the bug report template. please add a complete reproduction The issue lacks information for further investigation labels Mar 29, 2022
@jlarmstrongiv
Copy link
Contributor Author

You may need to install via npm install --force because @headlessui/react isn’t playing well in peerDependencies, due to the react v18 release yesterday.

@ijjk
Copy link
Member

ijjk commented Mar 31, 2022

Hi, this issue appears to be that next/document is being imported in your _app file specifically the export { App as default } from "@reactjs/next" which is used client side and shows the missing module warning while if it's used only server-side like it's meant to be the warning won't show.

@ijjk ijjk closed this as completed Mar 31, 2022
@jlarmstrongiv
Copy link
Contributor Author

@ijjk I’m not sure I understand.

The export { App as default } from "@reactjs/next" refers to:

// docs https://nextjs.org/docs/basic-features/typescript#custom-app
import type { AppProps } from "next/app";

export function App({ Component, pageProps }: AppProps) {
  return <Component {...pageProps} />;
}

So I am unsure where, why, or how next/document would be imported in the _app file.

@ijjk
Copy link
Member

ijjk commented Mar 31, 2022

Since you are using a stub file that exports both like below, it causes the Document import to be processed as well when importing the App export in _app

export { App } from "./App";
export { Document } from "./Document";

@jlarmstrongiv
Copy link
Contributor Author

Thank you @ijjk 👍 I really appreciate your help and patience

@tw1t611
Copy link

tw1t611 commented Mar 31, 2022

I came across the same issue on canary without a stub file:

image

The error occurs on vercel, but does not occur on local yarn build

@housseindjirdeh
Copy link
Collaborator

@tw1t611 Any chance you can share your code or a reproduction?

@tw1t611
Copy link

tw1t611 commented Mar 31, 2022

@housseindjirdeh it works now.
I installed "@builder.io/partytown": "^0.5.1",

Hope that helps, otherwise please tell me what you need. You could also have an invite as a github collaborator. :)

@ijjk
Copy link
Member

ijjk commented Mar 31, 2022

@tw1t611 do you have the experimental.nextScriptWorkers enabled in your next.config.js? If not you shouldn't have to install @builder.io/partytown and if this is the case would love an invite to investigate this!

@housseindjirdeh
Copy link
Collaborator

+1 to what @ijjk said. You shouldn't have to install @builder.io/partytown unless you need to use experimental .nextScriptWorkers.

Please invite both of us to your repo if that's okay :)

kodiakhq bot pushed a commit that referenced this issue Mar 31, 2022
…#35793)

A few errors about Next.js not correctly handling the missing partytown dependency in `_document.js` have been flagged. Instead of `/* webpackIgnore: true */`, this PR switches to use [`__non_webpack_require__`](https://webpack.js.org/api/module-variables/#__non_webpack_require__-webpack-specific) to ensure webpack doesn't process fetching the dep server-side. 

-----

Related issues: 

- #35645 
- #35630 (comment)
@ajnart
Copy link

ajnart commented Apr 9, 2022

Had the same issue after upgrading packages, including Next. Reverting the upgrade fixed it thankfully

@ijjk
Copy link
Member

ijjk commented Apr 9, 2022

@ajnart were you encountering the above error on the latest canary of Next.js, v12.1.5-canary.4?

@ajnart
Copy link

ajnart commented Apr 9, 2022

@ajnart were you encountering the above error on the latest canary of Next.js, v12.1.5-canary.4?

No, the version I had was 12.1.0. I upgraded all my packages instead of only a few ones, and it created this error.

My package.json dependencies when I had the issue
 "dependencies": {
    "@emotion/react": "^11.9.0",
    "@emotion/styled": "^11.8.1",
    "@mantine/core": "^4.1.2",
    "@mantine/dates": "^4.1.2",
    "@mantine/dropzone": "^4.1.2",
    "@mantine/form": "^4.1.2",
    "@mantine/hooks": "^4.1.2",
    "@mantine/modals": "^4.1.2",
    "@mantine/next": "^4.1.2",
    "@mantine/notifications": "^4.1.2",
    "@mantine/prism": "^4.1.2",
    "@mantine/rte": "^4.1.2",
    "@mantine/spotlight": "^4.1.2",
    "axios": "^0.26.1",
    "cookies-next": "^2.0.4",
    "dayjs": "^1.11.0",
    "framer-motion": "^6",
    "next": "12.1.0",
    "prism-react-renderer": "^1.3.1",
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "react-icons": "^4.3.1",
    "react-markdown": "^8.0.2",
    "swiper": "^8.1.0",
    "tabler-icons-react": "^1.44.0"
  },
  "devDependencies": {
    "@next/bundle-analyzer": "^12.1.4",
    "@next/eslint-plugin-next": "^12.1.4",
    "@types/node": "^17.0.23",
    "@types/react": "^18.0.0",
    "@typescript-eslint/eslint-plugin": "^5.18.0",
    "@typescript-eslint/parser": "^5.18.0",
    "cross-env": "^7.0.3",
    "eslint": "^8.13.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-airbnb-typescript": "^17.0.0",
    "eslint-config-mantine": "^1.1.0",
    "eslint-config-next": "^12.1.4",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-jsx-a11y": "^6.5.1",
    "eslint-plugin-react": "^7.29.4",
    "eslint-plugin-react-hooks": "^4.4.0",
    "prettier": "^2.6.2",
    "typescript": "^4.6.3"
  }

@ijjk
Copy link
Member

ijjk commented Apr 9, 2022

Can you confirm you are no longer having the issue in the latest canary? It should be fully resolved now.

@ajnart
Copy link

ajnart commented Apr 9, 2022

Can you confirm you are no longer having the issue in the latest canary? It should be fully resolved now.

Yup! I just tested, and I no longer have the issue while using canary 🥳

@github-actions
Copy link
Contributor

github-actions bot commented May 9, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Script (next/script) Related to Next.js Script Optimization.
Projects
None yet
Development

No branches or pull requests

6 participants