anatine / zod-plugins

Plugins and utilities for Zod
622 stars 87 forks source link

[zod-mock] Source map warning showing in console when using zod-mock #151

Open johndatserakis opened 1 year ago

johndatserakis commented 1 year ago

Hi there. When using zod-mock in my project, I am getting the following warnings in the console. (I have @anatine/zod-mock 3.13.2 installed.)

WARNING in ../../node_modules/@anatine/zod-mock/src/index.js
Module Warning (from ../../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '$X/packages/zod-mock/src/index.ts' file: Error: ENOENT: no such file or directory, open '$X/packages/zod-mock/src/index.ts'

WARNING in ../../node_modules/@anatine/zod-mock/src/lib/zod-mock.js
Module Warning (from ../../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '$X/packages/zod-mock/src/lib/zod-mock.ts' file: Error: ENOENT: no such file or directory, open '$X/packages/zod-mock/src/lib/zod-mock.ts'

WARNING in ../../node_modules/@anatine/zod-mock/src/lib/zod-mockery-map.js
Module Warning (from ../../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '$X/packages/zod-mock/src/lib/zod-mockery-map.ts' file: Error: ENOENT: no such file or directory, open '$X/packages/zod-mock/src/lib/zod-mockery-map.ts'

I traced one of these back and see the issue - the sources path is relative and points to a location that doesn't exist. See attached screenshots.

Screenshot 2023-08-01 at 11 08 50 AM Screenshot 2023-08-01 at 11 09 15 AM

Because of the path, the location tries to reach into my actual project to resolve the path, which is incorrect.

I looked in the Nx repo and found a few people mentioning similar issues. I assume this is an NX setting that can be tweaked somewhere.

Potentially related Nx issues:

johndatserakis commented 11 months ago

While the issue still remains, the following is a way to at least silence the warnings. In your webpack config, use something like this:

config.ignoreWarnings = [
  ...config.ignoreWarnings,
  { module: /node_modules\/@anatine\/zod-mock\// },
];

This worked for me as a temporary solution.