-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix magic export deprecation messaging #4661
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e6a5373
Revert "Deprecate all functions & types exported from `magicExports` …
brophdawg11 8ae9166
Single deprecation warning per remix index file
brophdawg11 12ae44f
Revert "Single deprecation warning per remix index file"
brophdawg11 5083780
Add back in TS deprecation typings
brophdawg11 229503e
Warn on deprecated remix imports via esbuild plugin
brophdawg11 72a22c9
add chgangeset
brophdawg11 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 was deleted.
Oops, something went wrong.
This file contains 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,6 @@ | ||
--- | ||
"remix": patch | ||
"@remix-run/dev": patch | ||
--- | ||
|
||
Importing functions and types from the `remix` package is deprecated, and all exported modules will be removed in the next major release. For more details,[see the release notes for 1.4.0](https://github.com/remix-run/remix/releases/tag/v1.4.0) where these changes were first announced. |
This file contains 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 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
29 changes: 29 additions & 0 deletions
29
packages/remix-dev/compiler/plugins/deprecatedRemixPackagePlugin.ts
This file contains 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,29 @@ | ||
import path from "path"; | ||
import type { Plugin } from "esbuild"; | ||
|
||
/** | ||
* A plugin to warn users when importing from the deprecated `remix` package | ||
*/ | ||
export function deprecatedRemixPackagePlugin( | ||
onWarning?: (warning: string, key: string) => void | ||
): Plugin { | ||
return { | ||
name: "deprecated-remix-package", | ||
setup(build) { | ||
build.onResolve({ filter: /.*/ }, ({ importer, path: filePath }) => { | ||
// Warn on deprecated imports from the remix package | ||
if (filePath === "remix") { | ||
let relativePath = path.relative(process.cwd(), importer); | ||
let warningMessage = | ||
`WARNING: All \`remix\` exports are considered deprecated as of v1.3.3. ` + | ||
`Please change your import in "${relativePath}" to come from the respective ` + | ||
`underlying \`@remix-run/*\` package. ` + | ||
`Run \`npx @remix-run/dev@latest codemod replace-remix-magic-imports\` ` + | ||
`to automatically migrate your code.`; | ||
onWarning?.(warningMessage, importer); | ||
} | ||
return undefined; | ||
}); | ||
}, | ||
}; | ||
} |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can keep the JSDoc deprecation here as well to have an extra IDE warning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MichaelDeBoey I'm having trouble actually seeing this JSDoc warning anywhere in my VSCode IDE 🤔
If I create a fresh Remix JS project, VSCode still shows me the deprecation from our
.d.ts
file innode_modules/remix
in my.jsx
files:If I build with this JSDoc comment included and I remove the
.d.ts
file, then I don't see the deprecation, and I just see the JSDoc from the internal definition of the method, not the JSDoc of the re-exported version fromremix
:So for now I'm going to merge this without the CJS JSDoc updates since I can't quite prove that they're picked up. It does seem that even in non-TS projects, at least VScode will pick up our
.d.ts
deprecation warning.If we can find specific cases where the JSDoc enhances the DX I'm all for a subsequent PR before we release
1.8.0
stable, but for now I want to get1.8.0-pre.1
out so folks can help test the new@remix-run/router
work inside of Remix 👍