-
Notifications
You must be signed in to change notification settings - Fork 92
feat: add module-replacements support first class #268
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
Merged
danielroe
merged 22 commits into
npmx-dev:main
from
lino-levan:lino/add-module-replacements
Jan 30, 2026
+120
−2
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
34280db
feat: add module-replacements support first class
lino-levan 7674b61
Merge branch 'main' into lino/add-module-replacements
lino-levan f0921ac
[autofix.ci] apply automated fixes
autofix-ci[bot] e57f930
fix: don't introduce a bigger gap than already exists in prod
lino-levan 6abd7d1
Merge branch 'main' into lino/add-module-replacements
lino-levan 93ece99
chore: fix knip
lino-levan ff87129
Merge branch 'main' into lino/add-module-replacements
lino-levan 5e453a3
chore: fix spacing
lino-levan bd412b0
Merge branch 'main' into lino/add-module-replacements
lino-levan 4d67222
Update i18n/locales/en.json
lino-levan a279030
Update i18n/locales/en.json
lino-levan 4304d53
[autofix.ci] apply automated fixes
autofix-ci[bot] 483b7b2
Merge branch 'main' into lino/add-module-replacements
lino-levan 3948fc7
Merge branch 'main' into lino/add-module-replacements
lino-levan 09a9a95
Update i18n/locales/en.json
lino-levan c0ba5c3
Merge branch 'main' into lino/add-module-replacements
lino-levan f7a61bd
[autofix.ci] apply automated fixes
autofix-ci[bot] 2f004ee
Update i18n/locales/en.json
lino-levan a80e61b
Merge branch 'main' into lino/add-module-replacements
lino-levan ee157d1
[autofix.ci] apply automated fixes
autofix-ci[bot] ea9c240
Merge branch 'main' into lino/add-module-replacements
danielroe 3151035
Merge branch 'main' into lino/add-module-replacements
lino-levan 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| <script setup lang="ts"> | ||
| import type { ModuleReplacement } from 'module-replacements' | ||
| const props = defineProps<{ | ||
| replacement: ModuleReplacement | ||
| }>() | ||
| const { t } = useI18n() | ||
| const message = computed(() => { | ||
| switch (props.replacement.type) { | ||
| case 'native': | ||
| return t('package.replacement.native', { | ||
| replacement: props.replacement.replacement, | ||
| nodeVersion: props.replacement.nodeVersion, | ||
| }) | ||
| case 'simple': | ||
| return t('package.replacement.simple', { | ||
| replacement: props.replacement.replacement, | ||
| }) | ||
| case 'documented': | ||
| return t('package.replacement.documented') | ||
| case 'none': | ||
| return t('package.replacement.none') | ||
| } | ||
| }) | ||
| const mdnUrl = computed(() => { | ||
| if (props.replacement.type !== 'native' || !props.replacement.mdnPath) return null | ||
| return `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/${props.replacement.mdnPath}` | ||
| }) | ||
| const docPath = computed(() => { | ||
| if (props.replacement.type !== 'documented' || !props.replacement.docPath) return null | ||
| return `https://github.com/es-tooling/module-replacements/blob/main/docs/modules/${props.replacement.docPath}.md` | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div | ||
| class="border border-amber-600/40 bg-amber-500/10 rounded-lg px-3 py-2 text-base text-amber-700 dark:text-amber-400" | ||
| > | ||
| <h2 class="font-medium mb-1 flex items-center gap-2"> | ||
| <span class="i-carbon-idea w-4 h-4" aria-hidden="true" /> | ||
| {{ $t('package.replacement.title') }} | ||
| </h2> | ||
| <p class="text-sm m-0"> | ||
| {{ message }} | ||
| <a | ||
| v-if="mdnUrl" | ||
| :href="mdnUrl" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| class="inline-flex items-center gap-1 ml-1 underline underline-offset-4 decoration-amber-600/60 dark:decoration-amber-400/50 hover:decoration-fg transition-colors" | ||
| > | ||
| {{ $t('package.replacement.mdn') }} | ||
| <span class="i-carbon-launch w-3 h-3" aria-hidden="true" /> | ||
| </a> | ||
| <a | ||
| v-if="docPath" | ||
| :href="docPath" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| class="inline-flex items-center gap-1 ml-1 underline underline-offset-4 decoration-amber-600/60 dark:decoration-amber-400/50 hover:decoration-fg transition-colors" | ||
| > | ||
| {{ $t('package.replacement.learn_more') }} | ||
| <span class="i-carbon-launch w-3 h-3" aria-hidden="true" /> | ||
| </a> | ||
| </p> | ||
| </div> | ||
| </template> |
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,6 @@ | ||
| import type { ModuleReplacement } from 'module-replacements' | ||
|
|
||
| /** @public */ | ||
| export function useModuleReplacement(packageName: MaybeRefOrGetter<string>) { | ||
| return useLazyFetch<ModuleReplacement | null>(() => `/api/replacements/${toValue(packageName)}`) | ||
| } |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,11 @@ | ||
| import { all, type ModuleReplacement } from 'module-replacements' | ||
|
|
||
| const replacementMap = new Map<string, ModuleReplacement>( | ||
| all.moduleReplacements.map(r => [r.moduleName, r]), | ||
| ) | ||
|
|
||
| export default defineEventHandler((event): ModuleReplacement | null => { | ||
| const pkg = getRouterParam(event, 'pkg') | ||
| if (!pkg) return null | ||
| return replacementMap.get(pkg) ?? null | ||
| }) |
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.