-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(remix): Add Remix 3 export subpaths and optional peer deps #24697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chargome
wants to merge
1
commit into
develop
from
charlygomez/js-3765-add-remix-3-export-subpaths-and-optional-peer-deps
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // A named list rather than `export * from '@sentry/browser'`: Remix 3 has no bundler, so a wildcard | ||
| // makes every export reachable and nothing can be tree shaken out of the served module graph. | ||
| // | ||
| // `init` is withheld until the Remix 3 browser SDK lands. Re-exporting `@sentry/browser`'s would give | ||
| // an app History based tracing, which yields no navigation spans in Remix 3, so it would look | ||
| // configured while reporting nothing. | ||
| export { captureException, captureMessage } from '@sentry/browser'; | ||
| export type { BrowserOptions } from '@sentry/browser'; | ||
|
cursor[bot] marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // Placeholder until the Remix 3 server instrumentation lands. `@sentry/node`'s `init` already emits | ||
| // `http.server` spans, so this is useful on its own; route parameterisation and router error capture | ||
| // are what is still missing. | ||
| export * from '@sentry/node'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // Replaces `--import remix/node-tsx` rather than adding a second flag. Sentry's module hook is | ||
| // registered here once the server instrumentation lands, so for now nothing is instrumented. | ||
| await import('remix/node-tsx'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import * as fs from 'node:fs'; | ||
| import * as path from 'node:path'; | ||
| import * as semver from 'semver'; | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import packageJson from '../package.json'; | ||
|
|
||
| const packageRoot = path.resolve(__dirname, '..'); | ||
|
|
||
| // `exports` mixes shapes (`"./package.json"` is a bare string), so it does not fit one index signature. | ||
| const exportsMap = packageJson.exports as unknown as Record<string, { import?: Record<string, string> }>; | ||
|
|
||
| /** | ||
| * A mismatch between the `exports` map and the build output is invisible: the build and lint both | ||
| * pass, and the package is broken only for whoever installs it. Rollup infers its output layout from | ||
| * the module graph, so an unrelated change can relocate these files. | ||
| */ | ||
| describe('Remix 3 exports', () => { | ||
| const subpaths = ['./v3', './v3/client', './v3/node']; | ||
|
|
||
| it.each(subpaths)('%s is declared in the exports map', subpath => { | ||
| expect(packageJson.exports).toHaveProperty([subpath]); | ||
| }); | ||
|
|
||
| it.each(subpaths)('%s only exposes an import condition', subpath => { | ||
| // Remix 3's asset server rejects CommonJS outright, so a `require` condition could never load. | ||
| expect(Object.keys(exportsMap[subpath] ?? {})).toEqual(['import']); | ||
| }); | ||
|
|
||
| it.each(subpaths)('%s points at files that exist in the build output', subpath => { | ||
| const targets = Object.values(exportsMap[subpath]?.import ?? {}); | ||
|
|
||
| expect(targets.length).toBeGreaterThan(0); | ||
|
|
||
| for (const target of targets) { | ||
| expect(fs.existsSync(path.join(packageRoot, target)), `${subpath} -> ${target} is missing`).toBe(true); | ||
| } | ||
| }); | ||
|
|
||
| describe('the Remix 3 peer range', () => { | ||
| const range = packageJson.peerDependencies.remix; | ||
|
|
||
| // Asserted by behaviour, so the range can change after Remix 3 reaches GA without failing here. | ||
| it('accepts release candidates', () => { | ||
| // `3.x` does not match `3.0.0-rc.1`: semver ranges exclude prereleases unless they name one. | ||
| expect(semver.satisfies('3.0.0-rc.1', range)).toBe(true); | ||
| expect(semver.satisfies('3.0.0-rc.2', range)).toBe(true); | ||
| }); | ||
|
|
||
| it('accepts stable 3.x', () => { | ||
| expect(semver.satisfies('3.0.0', range)).toBe(true); | ||
| expect(semver.satisfies('3.4.2', range)).toBe(true); | ||
| }); | ||
|
|
||
| it('rejects the next major', () => { | ||
| expect(semver.satisfies('4.0.0', range)).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| it('marks every peer dependency optional', () => { | ||
| // A Remix 3 app must not have the Remix 2 packages or React installed on its behalf. | ||
| for (const name of Object.keys(packageJson.peerDependencies)) { | ||
| expect(packageJson.peerDependenciesMeta, `${name} should be optional`).toHaveProperty([name, 'optional'], true); | ||
| } | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.