Skip to content

Commit b673c21

Browse files
committed
sentry/nextjsをexternalPackagesにしてみる
1 parent 0267ef6 commit b673c21

1 file changed

Lines changed: 13 additions & 17 deletions

File tree

next.config.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,18 @@ const nextConfig: NextConfig = {
1515
typescript: {
1616
ignoreBuildErrors: true,
1717
},
18-
serverExternalPackages: ["@prisma/client", ".prisma/client"],
18+
serverExternalPackages: [
19+
"@prisma/client",
20+
".prisma/client",
21+
// 普通にimportするとこれが4回バンドルされてcloudflareの3MB制限を超えてしまう
22+
"@sentry/nextjs",
23+
],
24+
outputFileTracingIncludes: {
25+
// sentryのバージョン違うけど、serverExternalPackagesに@sentry/nextjsを追加したら
26+
// https://github.com/getsentry/sentry-javascript/issues/14931#issuecomment-3641871022
27+
// と同じエラーが出たので、そこに書かれていたのと同じでっちあげをしてみる
28+
"*": ["node_modules/@sentry/nextjs/build/**/*"],
29+
},
1930
async headers() {
2031
return [
2132
{
@@ -43,7 +54,7 @@ const nextConfig: NextConfig = {
4354
},
4455
];
4556
},
46-
webpack: (config, { isServer }) => {
57+
webpack: (config) => {
4758
config.plugins.push(
4859
new PyodidePlugin({
4960
// public/ 以下に書き出すと404
@@ -52,21 +63,6 @@ const nextConfig: NextConfig = {
5263
outDirectory: `static/pyodide/v${pyodideVersion}`,
5364
})
5465
);
55-
if (isServer) {
56-
config.optimization.splitChunks.cacheGroups = {
57-
...config.optimization.splitChunks.cacheGroups,
58-
sentry: {
59-
test: /@sentry/,
60-
priority: 10,
61-
enforce: true,
62-
},
63-
opentelemetry: {
64-
test: /(?<!compiled\/@?)opentelemetry/,
65-
priority: 10,
66-
enforce: true,
67-
},
68-
};
69-
}
7066
// import hoge from "./file?raw" でfileの中身を文字列としてインポート
7167
for (const rule of config.module.rules) {
7268
if (rule.resourceQuery instanceof RegExp) {

0 commit comments

Comments
 (0)