Skip to content

Commit 32ee9c8

Browse files
committed
refactor: remix vite plugin imports
1 parent f65f0e2 commit 32ee9c8

File tree

6 files changed

+19
-32
lines changed

6 files changed

+19
-32
lines changed

dev-packages/e2e-tests/test-applications/create-remix-app-express-vite-dev/vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { installGlobals } from '@remix-run/node';
22
import { vitePlugin as remix } from '@remix-run/dev';
3-
import { sentryRemixVitePlugin } from '@sentry/remix';
3+
import Sentry from '@sentry/remix';
44
import { defineConfig } from 'vite';
55
import tsconfigPaths from 'vite-tsconfig-paths';
66

@@ -9,7 +9,7 @@ installGlobals();
99
export default defineConfig({
1010
plugins: [
1111
remix(),
12-
sentryRemixVitePlugin(),
12+
Sentry.sentryRemixVitePlugin(),
1313
tsconfigPaths({
1414
// The dev server config errors are not relevant to this test app
1515
// https://github.com/aleclarson/vite-tsconfig-paths?tab=readme-ov-file#options

dev-packages/e2e-tests/test-applications/create-remix-app-express/vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { installGlobals } from '@remix-run/node';
22
import { vitePlugin as remix } from '@remix-run/dev';
3-
import { sentryRemixVitePlugin } from '@sentry/remix';
3+
import Sentry from '@sentry/remix';
44
import { defineConfig } from 'vite';
55
import tsconfigPaths from 'vite-tsconfig-paths';
66

@@ -9,7 +9,7 @@ installGlobals();
99
export default defineConfig({
1010
plugins: [
1111
remix(),
12-
sentryRemixVitePlugin(),
12+
Sentry.sentryRemixVitePlugin(),
1313
tsconfigPaths({
1414
// The dev server config errors are not relevant to this test app
1515
// https://github.com/aleclarson/vite-tsconfig-paths?tab=readme-ov-file#options
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { vitePlugin as remix } from '@remix-run/dev';
2-
import { sentryRemixVitePlugin } from '@sentry/remix';
2+
import Sentry from '@sentry/remix';
33
import { defineConfig } from 'vite';
44
import tsconfigPaths from 'vite-tsconfig-paths';
55

@@ -9,7 +9,7 @@ export default defineConfig({
99
ignoredRouteFiles: ['**/.*'],
1010
serverModuleFormat: 'cjs',
1111
}),
12-
sentryRemixVitePlugin(),
12+
Sentry.sentryRemixVitePlugin(),
1313
tsconfigPaths(),
1414
],
1515
});

dev-packages/e2e-tests/test-applications/remix-hydrogen/vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { vitePlugin as remix } from '@remix-run/dev';
2-
import { sentryRemixVitePlugin } from '@sentry/remix';
2+
import Sentry from '@sentry/remix';
33
import { hydrogen } from '@shopify/hydrogen/vite';
44
import { oxygen } from '@shopify/mini-oxygen/vite';
55
import { defineConfig } from 'vite';
@@ -17,7 +17,7 @@ export default defineConfig({
1717
v3_throwAbortReason: true,
1818
},
1919
}),
20-
sentryRemixVitePlugin(),
20+
Sentry.sentryRemixVitePlugin(),
2121
tsconfigPaths({
2222
// The dev server config errors are not relevant to this test app
2323
// https://github.com/aleclarson/vite-tsconfig-paths?tab=readme-ov-file#options

packages/remix/src/config/vite.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ const MANIFEST_GLOBAL_KEY = '_sentryRemixRouteManifest' as const;
3838
* // vite.config.ts
3939
* import { defineConfig } from 'vite';
4040
* import { vitePlugin as remix } from '@remix-run/dev';
41-
* import { sentryRemixVitePlugin } from '@sentry/remix';
41+
* import Sentry from '@sentry/remix';
4242
*
4343
* export default defineConfig({
4444
* plugins: [
4545
* remix(),
46-
* sentryRemixVitePlugin({
46+
* Sentry.sentryRemixVitePlugin({
4747
* appDirPath: './app',
4848
* }),
4949
* ],

packages/remix/test/config/vite.test.ts

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as os from 'os';
33
import * as path from 'path';
44
import type { Plugin, ResolvedConfig } from 'vite';
55
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
6+
import Sentry from '../../src';
67
import { sentryRemixVitePlugin } from '../../src/config/vite';
78

89
describe('sentryRemixVitePlugin', () => {
@@ -35,21 +36,21 @@ describe('sentryRemixVitePlugin', () => {
3536

3637
describe('plugin configuration', () => {
3738
it('should return a valid Vite plugin with correct name', () => {
38-
const plugin = sentryRemixVitePlugin();
39+
const plugin = Sentry.sentryRemixVitePlugin();
3940

4041
expect(plugin).toBeDefined();
4142
expect(plugin.name).toBe('sentry-remix-route-manifest');
4243
expect(plugin.enforce).toBe('post');
4344
});
4445

4546
it('should accept custom appDirPath option', () => {
46-
const plugin = sentryRemixVitePlugin({ appDirPath: '/custom/path' });
47+
const plugin = Sentry.sentryRemixVitePlugin({ appDirPath: '/custom/path' });
4748

4849
expect(plugin).toBeDefined();
4950
});
5051

5152
it('should work with no options', () => {
52-
const plugin = sentryRemixVitePlugin();
53+
const plugin = Sentry.sentryRemixVitePlugin();
5354

5455
expect(plugin).toBeDefined();
5556
});
@@ -62,9 +63,7 @@ describe('sentryRemixVitePlugin', () => {
6263
fs.writeFileSync(path.join(routesDir, 'about.tsx'), '// about');
6364
fs.writeFileSync(path.join(routesDir, 'users.$id.tsx'), '// users');
6465

65-
const plugin = sentryRemixVitePlugin() as Plugin & {
66-
configResolved: (config: ResolvedConfig) => void;
67-
};
66+
const plugin = Sentry.sentryRemixVitePlugin();
6867

6968
const mockConfig: Partial<ResolvedConfig> = {
7069
root: tempDir,
@@ -83,9 +82,7 @@ describe('sentryRemixVitePlugin', () => {
8382
fs.writeFileSync(path.join(routesDir, 'index.tsx'), '// index');
8483
fs.writeFileSync(path.join(routesDir, 'users.$id.tsx'), '// users');
8584

86-
const plugin = sentryRemixVitePlugin() as Plugin & {
87-
configResolved: (config: ResolvedConfig) => void;
88-
};
85+
const plugin = Sentry.sentryRemixVitePlugin();
8986

9087
const mockConfig: Partial<ResolvedConfig> = {
9188
root: tempDir,
@@ -101,9 +98,7 @@ describe('sentryRemixVitePlugin', () => {
10198
});
10299

103100
it('should handle errors gracefully and set empty manifest', () => {
104-
const plugin = sentryRemixVitePlugin({ appDirPath: '/nonexistent/path' }) as Plugin & {
105-
configResolved: (config: ResolvedConfig) => void;
106-
};
101+
const plugin = Sentry.sentryRemixVitePlugin({ appDirPath: '/nonexistent/path' });
107102

108103
const mockConfig: Partial<ResolvedConfig> = {
109104
root: tempDir,
@@ -124,9 +119,7 @@ describe('sentryRemixVitePlugin', () => {
124119
fs.mkdirSync(customRoutesDir, { recursive: true });
125120
fs.writeFileSync(path.join(customRoutesDir, 'index.tsx'), '// index');
126121

127-
const plugin = sentryRemixVitePlugin({ appDirPath: customAppDir }) as Plugin & {
128-
configResolved: (config: ResolvedConfig) => void;
129-
};
122+
const plugin = Sentry.sentryRemixVitePlugin({ appDirPath: customAppDir });
130123

131124
const mockConfig: Partial<ResolvedConfig> = {
132125
root: tempDir,
@@ -144,13 +137,7 @@ describe('sentryRemixVitePlugin', () => {
144137
it('should inject manifest into HTML with <head> tag', () => {
145138
fs.writeFileSync(path.join(routesDir, 'index.tsx'), '// index');
146139

147-
const plugin = sentryRemixVitePlugin() as Plugin & {
148-
configResolved: (config: ResolvedConfig) => void;
149-
transformIndexHtml: {
150-
order: string;
151-
handler: (html: string) => string;
152-
};
153-
};
140+
const plugin = Sentry.sentryRemixVitePlugin();
154141

155142
const mockConfig: Partial<ResolvedConfig> = {
156143
root: tempDir,

0 commit comments

Comments
 (0)