在我的react/typescript应用程序中,我使用graphql-request,一切都很好。就在编译应用程序时,我在终端中收到了一些警告。有人也经历过同样的事吗?触发警告的代码部分如下:
import { gql, request } from "graphql-request"
const [id, setId] = useState<number | undefined>(undefined);
const query = gql
`query {
id
}`;
useEffect(() =>
{
request(`${endpoint}/maps`, query).then((data) => setId(data.id))
.catch((error) => console.error("Could not load id", error))
.finally(() => setLoading(false));
}, [query]);
以下是我收到的警告:
WARNING in ./node_modules/graphql-request/dist/createRequestBody.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lukas/projects/bubble/bubble-os/node_modules/graphql-request/src/createRequestBody.ts' file: Error: ENOENT: no such file or directory, open '/home/lukas/projects/bubble/bubble-os/node_modules/graphql-request/src/createRequestBody.ts'
@ ./node_modules/graphql-request/dist/index.js 217:42-72
@ ./src/map_viewer/map_overview.tsx 23:0-47 61:16-19 80:4-11
@ ./src/dashboard/dashboard.tsx 25:0-51 299:46-55
@ ./src/App.tsx 4:0-46 10:35-44
@ ./src/index.tsx 7:0-24 25:33-36
WARNING in ./node_modules/graphql-request/dist/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lukas/projects/bubble/bubble-os/node_modules/graphql-request/src/index.ts' file: Error: ENOENT: no such file or directory, open '/home/lukas/projects/bubble/bubble-os/node_modules/graphql-request/src/index.ts'
@ ./src/map_viewer/map_overview.tsx 23:0-47 61:16-19 80:4-11
@ ./src/dashboard/dashboard.tsx 25:0-51 299:46-55
@ ./src/App.tsx 4:0-46 10:35-44
@ ./src/index.tsx 7:0-24 25:33-36
WARNING in ./node_modules/graphql-request/dist/types.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lukas/projects/bubble/bubble-os/node_modules/graphql-request/src/types.ts' file: Error: ENOENT: no such file or directory, open '/home/lukas/projects/bubble/bubble-os/node_modules/graphql-request/src/types.ts'
@ ./node_modules/graphql-request/dist/index.js 219:14-32
@ ./src/map_viewer/map_overview.tsx 23:0-47 61:16-19 80:4-11
@ ./src/dashboard/dashboard.tsx 25:0-51 299:46-55
@ ./src/App.tsx 4:0-46 10:35-44
@ ./src/index.tsx 7:0-24 25:33-36
3 warnings have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
webpack 5.66.0 compiled with 3 warnings in 5142 ms
我已经查过互联网了,但没有找到解决办法。另外,在graphql的GitHub问题-请求中,我找不到任何东西。我试图在codesandbox.io中重现这个问题,但没有收到任何警告。
也许我所使用的软件包的版本提供了一个线索,说明问题可能是什么:
我会感谢任何关于可能发生的问题的暗示。
发布于 2022-01-21 20:41:05
若要忽略警告,可以在webpack.config.js文件中使用以下配置。(查看这里获取更多信息。)
module.exports = {
module: {
rules: [
{
test: /\.js$/,
enforce: "pre",
use: ["source-map-loader"],
},
],
},
ignoreWarnings: [/Failed to parse source map/],
};
2.另一种类似警告的解决方案可能是在包含.env的项目根目录中添加一个GENERATE_SOURCEMAP=false文件,从而禁用源映射。
https://stackoverflow.com/questions/70688442
复制相似问题