Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
"./package.json": "./package.json",
".": {
"types": "./build/types/index.types.d.ts",
"workerd": {
Comment thread
isaacs marked this conversation as resolved.
Resolved
"import": "./build/esm/cloudflare/index.js",
"require": "./build/cjs/cloudflare/index.js",
"default": "./build/esm/cloudflare/index.js"
},
"browser": {
"import": "./build/esm/index.client.js",
"require": "./build/cjs/index.client.js",
Expand Down
1 change: 1 addition & 0 deletions packages/remix/src/cloudflare/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export { browserTracingIntegration } from '../client';
export { ErrorBoundary } from '@sentry/react';
export { makeWrappedCreateRequestHandler, sentryHandleError };
export { generateSentryServerTimingHeader } from '../server/serverTimingTracePropagation';
export { captureRemixServerException } from '../server/errors';

/**
* Instruments a Remix build to capture errors and performance data.
Expand Down
39 changes: 39 additions & 0 deletions packages/remix/test/cloudflare-exports.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { execFileSync } from 'node:child_process';
import * as path from 'node:path';
import { describe, expect, it } from 'vitest';

import * as cloudflare from '../src/cloudflare';
import * as client from '../src/index.client';

const packageRoot = path.resolve(__dirname, '..');

function resolveRoot(conditions: string[]): string {
return execFileSync(
process.execPath,
[
...conditions.map(condition => `--conditions=${condition}`),
'--input-type=module',
'-e',
"console.log(import.meta.resolve('@sentry/remix'))",
],
{ cwd: packageRoot, encoding: 'utf8' },
).trim();
}

// Cloudflare resolves a bare `@sentry/remix` to the `workerd` entry, where
// it used to get the client build. A name only the client exports would
// break the build of an app that imports it in Worker code.
describe('Cloudflare entry', () => {
it('is what a bare import resolves to with the conditions Cloudflare bundlers set', () => {
expect(resolveRoot(['workerd', 'worker', 'browser'])).toMatch(/\/build\/esm\/cloudflare\/index\.js$/);
});

it('is not what a browser bundle resolves to', () => {
expect(resolveRoot(['browser'])).toMatch(/\/build\/esm\/index\.client\.js$/);
});

it('exports every name the client entry exports', () => {
const missing = Object.keys(client).filter(name => !(name in cloudflare));
expect(missing).toEqual([]);
});
});
Loading