Skip to content

Commit

Permalink
ATA: node: module resolution (#3191)
Browse files Browse the repository at this point in the history
Co-authored-by: Jake Bailey <[email protected]>
  • Loading branch information
Renegade334 and jakebailey authored Jul 30, 2024
1 parent ce2f2e9 commit 1d0af97
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/plenty-deers-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@typescript/ata": patch
---

Always treat `node:` modules as Node, expand list of known Node modules
3 changes: 2 additions & 1 deletion packages/ata/src/edgeCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const mapModuleNameToModule = (moduleSpecifier: string) => {
"http2",
"https",
"inspector",
"inspector/promises",
"module",
"net",
"os",
Expand Down Expand Up @@ -57,7 +58,7 @@ export const mapModuleNameToModule = (moduleSpecifier: string) => {
"zlib",
]

if (builtInNodeMods.includes(moduleSpecifier.replace("node:", ""))) {
if (moduleSpecifier.indexOf("node:") === 0 || builtInNodeMods.includes(moduleSpecifier)) {
return "node"
}

Expand Down
5 changes: 5 additions & 0 deletions packages/ata/tests/edgeCases.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ describe(mapModuleNameToModule, () => {
expect(mapModuleNameToModule("node:fs")).toEqual("node")
})

it("handles mandatorily-prefixed node: identifiers", () => {
expect(mapModuleNameToModule("node:test")).toEqual("node")
expect(mapModuleNameToModule("test")).toEqual("test")
})

it("strips module filepaths", () => {
expect(mapModuleNameToModule("lodash/identity")).toEqual("lodash")
expect(mapModuleNameToModule("@org/lodash/identity")).toEqual("@org/lodash")
Expand Down

0 comments on commit 1d0af97

Please sign in to comment.