Skip to content

Commit

Permalink
fix(resolve): stop searching when module is resolved (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrm007 committed Jan 9, 2023
1 parent f91da0d commit f10e797
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
node_modules
!test/fixture/package/node_modules
dist
*.log
3 changes: 3 additions & 0 deletions src/resolve.ts
Expand Up @@ -104,6 +104,9 @@ function _resolve(id: string, options: ResolveOptions = {}): string {
break;
}
}
if (resolved) {
break;
}
}

// Throw error if not found
Expand Down
14 changes: 14 additions & 0 deletions test/exports.test.ts
Expand Up @@ -280,6 +280,20 @@ describe("resolveModuleExportNames", () => {
`);
});

it("star exports with package", async () => {
expect(
await resolveModuleExportNames(
new URL("fixture/package/exports.mjs", import.meta.url).toString()
)
).toMatchInlineSnapshot(`
[
"StaticRouter",
"unstable_StaticRouterProvider",
"unstable_createStaticRouter",
]
`);
});

it("multiple inline", () => {
const code = `
export { foo } from 'foo1';export { bar } from 'foo2';export * as foobar from 'foo2';
Expand Down
1 change: 1 addition & 0 deletions test/fixture/package/exports.mjs
@@ -0,0 +1 @@
export * from "react-router-dom/server";
12 changes: 12 additions & 0 deletions test/fixture/package/node_modules/react-router-dom/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions test/fixture/package/node_modules/react-router-dom/server.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions test/fixture/package/node_modules/react-router-dom/server.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions test/fixture/package/package.json
@@ -0,0 +1,5 @@
{
"name": "package",
"private": true,
"dependencies": {}
}

0 comments on commit f10e797

Please sign in to comment.