-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix magic export deprecation messaging (#4661)
* Revert "Deprecate all functions & types exported from `magicExports` (#3284)" This reverts commit 848d8b0. * Single deprecation warning per remix index file * Revert "Single deprecation warning per remix index file" This reverts commit 7774492. * Add back in TS deprecation typings * Warn on deprecated remix imports via esbuild plugin * add chgangeset
- Loading branch information
1 parent
d361ad4
commit a5fb1f6
Showing
6 changed files
with
55 additions
and
47 deletions.
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