Skip to content

Commit 7c329d4

Browse files
committed
review comments; remove server code
1 parent 5feabda commit 7c329d4

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

packages/nuxt/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
"import": "./build/esm/index.client.js",
2525
"require": "./build/cjs/index.client.js"
2626
},
27-
"node": "./build/cjs/index.server.js"
27+
"node": {
28+
"import": "./build/esm/index.server.js",
29+
"require": "./build/cjs/index.server.js"
30+
}
2831
},
2932
"./module": {
3033
"types": "./build/module/types.d.ts",
@@ -51,7 +54,6 @@
5154
},
5255
"devDependencies": {
5356
"@nuxt/module-builder": "0.8.0",
54-
"nitropack": "2.9.6",
5557
"nuxt": "^3.12.2"
5658
},
5759
"scripts": {

packages/nuxt/src/client/sdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { init as initBrowser } from '@sentry/browser';
12
import { applySdkMetadata } from '@sentry/core';
23
import type { Client } from '@sentry/types';
3-
import { init as initBrowser } from '@sentry/browser';
44
import type { SentryVueOptions } from '../common/types';
55

66
/**

packages/nuxt/src/common/snippets.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import * as path from 'path';
44
// todo: tests
55
/** Returns an import snippet */
66
export function buildSdkInitFileImportSnippet(filePath: string): string {
7-
const pathToPosix = (originalPath: string): string => {
8-
return originalPath.split(path.sep).join(path.posix.sep);
9-
};
7+
const posixPath = filePath.split(path.sep).join(path.posix.sep);
108

11-
return `import "${pathToPosix(filePath)}";`;
9+
return `import "${posixPath}";`;
1210
}
1311

1412
// todo: tests
@@ -30,10 +28,10 @@ export function addImportStatement(filePath: string, importStatement: string): v
3028
fs.writeFileSync(filePath, output, 'utf8');
3129
} catch (err) {
3230
// eslint-disable-next-line no-console
33-
console.error(`Error writing file: ${err}`);
31+
console.error(`[Sentry] Error writing file to ${filePath}: ${err}`);
3432
}
3533
} catch (err) {
3634
// eslint-disable-next-line no-console
37-
console.error(`Error reading file: ${err}`);
35+
console.error(`[Sentry] Error reading file at ${filePath}: ${err}`);
3836
}
3937
}

packages/nuxt/src/common/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import type { init } from '@sentry/vue';
22

3+
// Omitting 'app' as the Nuxt SDK will add the app instance in the client plugin (users do not have to provide this)
34
export type SentryVueOptions = Omit<Parameters<typeof init>[0] & object, 'app'>;

packages/nuxt/src/module.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as fs from 'fs';
22
import * as path from 'path';
3-
import { type Resolver, addPlugin, addServerPlugin, createResolver, defineNuxtModule } from '@nuxt/kit';
3+
import { type Resolver, addPlugin, createResolver, defineNuxtModule } from '@nuxt/kit';
44
import { addImportStatement, buildSdkInitFileImportSnippet } from './common/snippets';
55
import type { SentryVueOptions } from './common/types';
66

@@ -27,21 +27,20 @@ export default defineNuxtModule<ModuleOptions>({
2727
addImportStatement(nuxtApp.rootComponent, buildSdkInitFileImportSnippet(pathToClientInit));
2828
} catch (err) {
2929
// eslint-disable-next-line no-console
30-
console.error(err);
30+
console.error(`[Sentry] Could not add import statement to root component. ${err}`);
3131
}
3232
}
3333
});
3434
}
3535

3636
if (resolver) {
3737
addPlugin(resolver.resolve('./runtime/plugins/sentry.client'));
38-
addServerPlugin(resolver.resolve('./runtime/plugins/sentry.server'));
3938
}
4039
},
4140
});
4241

43-
function findDefaultSdkInitFile(type: 'server' | 'client'): string | undefined {
44-
const possibleFileExtensions = ['ts', 'js', 'mjs', 'cjs', 'mts'];
42+
function findDefaultSdkInitFile(type: /* 'server' | */ 'client'): string | undefined {
43+
const possibleFileExtensions = ['ts', 'js', 'mjs', 'cjs', 'mts', 'cts'];
4544

4645
const cwd = process.cwd();
4746
return possibleFileExtensions

packages/nuxt/src/runtime/plugins/sentry.server.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

yarn.lock

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9467,6 +9467,7 @@
94679467
"@types/unist" "*"
94689468

94699469
"@types/history-4@npm:@types/[email protected]", "@types/history-5@npm:@types/[email protected]", "@types/history@*":
9470+
name "@types/history-4"
94709471
version "4.7.8"
94719472
resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.8.tgz#49348387983075705fe8f4e02fb67f7daaec4934"
94729473
integrity sha512-S78QIYirQcUoo6UJZx9CSP0O2ix9IaeAXwQi26Rhr/+mg7qqPy8TzaxHSUut7eGjL8WmLccT7/MXf304WjqHcA==
@@ -25455,7 +25456,7 @@ nise@^5.1.4:
2545525456
just-extend "^4.0.2"
2545625457
path-to-regexp "^1.7.0"
2545725458

25458-
nitropack@2.9.6, nitropack@^2.9.6:
25459+
nitropack@^2.9.6:
2545925460
version "2.9.6"
2546025461
resolved "https://registry.yarnpkg.com/nitropack/-/nitropack-2.9.6.tgz#90af114b796872f34e125e780e6148525149769f"
2546125462
integrity sha512-HP2PE0dREcDIBVkL8Zm6eVyrDd10/GI9hTL00PHvjUM8I9Y/2cv73wRDmxNyInfrx/CJKHATb2U/pQrqpzJyXA==
@@ -28960,6 +28961,7 @@ react-is@^18.0.0:
2896028961
"@remix-run/router" "1.0.2"
2896128962

2896228963
"react-router-6@npm:[email protected]", [email protected]:
28964+
name react-router-6
2896328965
version "6.3.0"
2896428966
resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.3.0.tgz#3970cc64b4cb4eae0c1ea5203a80334fdd175557"
2896528967
integrity sha512-7Wh1DzVQ+tlFjkeo+ujvjSqSJmkt1+8JO+T5xklPlgrh70y7ogx75ODRW0ThWhY7S+6yEDks8TYrtQe/aoboBQ==
@@ -31484,6 +31486,7 @@ string-template@~0.2.1:
3148431486
integrity sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0=
3148531487

3148631488
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
31489+
name string-width-cjs
3148731490
version "4.2.3"
3148831491
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
3148931492
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -34719,6 +34722,7 @@ workerpool@^6.4.0:
3471934722
integrity sha512-i3KR1mQMNwY2wx20ozq2EjISGtQWDIfV56We+yGJ5yDs8jTwQiLLaqHlkBHITlCuJnYlVRmXegxFxZg7gqI++A==
3472034723

3472134724
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
34725+
name wrap-ansi-cjs
3472234726
version "7.0.0"
3472334727
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
3472434728
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==

0 commit comments

Comments
 (0)