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

Fix warning "module.parent.require is not supported by webpack" #138

Closed
tansongyang opened this issue Jan 25, 2024 · 4 comments · Fixed by #222 or #235
Closed

Fix warning "module.parent.require is not supported by webpack" #138

tansongyang opened this issue Jan 25, 2024 · 4 comments · Fixed by #222 or #235
Assignees

Comments

@tansongyang
Copy link

I have a repro of this issue at https://github.com/tansongyang/raygun-webpack-issue-repro.

Run npm run build in the console. Here's the output:

> next build

   ▲ Next.js 14.1.0

   Creating an optimized production build ...
 ⚠ Compiled with warnings

./node_modules/raygun/build/raygun.js
module.parent.require is not supported by webpack.

Import trace for requested module:
./node_modules/raygun/build/raygun.js
./app/raygun.ts
./app/page.tsx

./node_modules/raygun/build/raygun.js
Module not found: Can't resolve 'raygun-apm/lib/src/crash_reporting' in '/Users/frank/Code/raygun-webpack-issue-repro/node_modules/raygun/build'

Import trace for requested module:
./node_modules/raygun/build/raygun.js
./app/raygun.ts
./app/page.tsx

Source appears to be here: https://github.com/MindscapeHQ/raygun4node/blob/v0.13.0/lib/raygun.ts#L51

Not sure what the fix is, but if I navigate to the file in VS Code, I get a warning that module.parent is deprecated:

image

@rob-mcgrail
Copy link

We've got the same issue

@miquelbeltran miquelbeltran self-assigned this May 16, 2024
@miquelbeltran
Copy link
Contributor

Hello, sorry we took so long to respond here. I am now taking care of keeping this project up to date.
Thanks a lot for the sample project with the issue, that will help me debug and fix.
I'll see what I can do today.

@miquelbeltran
Copy link
Contributor

After looking into it, the main issue is how the package attempts to load the raygun-apm dependency.
As it tries to load it, and if fails. This is wrapped by a try-catch block, but still causes warnings to appear.

This causes two warnings when building the app:

1. module.parent.require is not supported by webpack.
2. Module not found: Can't resolve 'raygun-apm/lib/src/crash_reporting' in '...

I think a proper solution would be to change the way we provide the apmBridge internally, instead of trying to attempt to load it, I think we should expose a setter and let users provide it externally rather than attempt to load in internally.

I'll have to consult with the rest of the team on how to move forward with this.

@miquelbeltran
Copy link
Contributor

With the changes in the PR #222 the build output should be:

➜  raygun-webpack-issue-repro git:(main) ✗ npm run build

> raygun-webpack-issue-repro@0.1.0 build
> next build

   ▲ Next.js 14.1.0

   Creating an optimized production build ...
 ✓ Compiled successfully
 ✓ Linting and checking validity of types    
 ✓ Collecting page data    
   Generating static pages (0/5)  [    ]paste_your_api_key_here
paste_your_api_key_here
 ✓ Generating static pages (5/5) 
 ✓ Collecting build traces    
 ✓ Finalizing page optimization    

Route (app)                              Size     First Load JS
┌ ○ /                                    5.14 kB        89.3 kB
└ ○ /_not-found                          882 B            85 kB
+ First Load JS shared by all            84.1 kB
  ├ chunks/69-1b6d135f94ac0e36.js        28.9 kB
  ├ chunks/fd9d1056-cc48c28d170fddc2.js  53.4 kB
  └ other shared chunks (total)          1.87 kB


○  (Static)  prerendered as static content

miquelbeltran added a commit that referenced this issue May 20, 2024
* fix: New APM Bridge Setup

removed ignored files

* update package.json

* fix indentation
@miquelbeltran miquelbeltran mentioned this issue May 23, 2024
10 tasks
miquelbeltran added a commit that referenced this issue May 27, 2024
@miquelbeltran miquelbeltran reopened this May 27, 2024
miquelbeltran added a commit that referenced this issue May 27, 2024
* Revert "fix: #138 New APM Bridge Setup (#222)"

This reverts commit c322f01.

* docs: add webpack info in README
miquelbeltran added a commit that referenced this issue May 28, 2024
* Revert "fix: #138 New APM Bridge Setup (#222)"

This reverts commit c322f01.

* docs: add webpack info in README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Merged
4 participants