Skip to content

Commit

Permalink
0.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ityuany committed Jun 1, 2024
1 parent a555a4d commit d934f06
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 39 deletions.
30 changes: 0 additions & 30 deletions __test__/fixtures/demo1.ts

This file was deleted.

10 changes: 10 additions & 0 deletions __test__/fixtures/demo13/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Grid as G } from 'antd';


function A() {
return <G>xx</G>
}

function B() {
return <G>xx</G>
}
7 changes: 0 additions & 7 deletions __test__/fixtures/demo2.ts

This file was deleted.

8 changes: 8 additions & 0 deletions __test__/index.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,12 @@ test('should to be 1 when use React.createElement', async (t) => {
const res = await inspectPackageUsage(workspace,["antd"]);
t.is(res.length, 1);
})



test('should to be 1 when use alias', async (t) => {
const workspace = path.join(__dirname,"fixtures/demo13");
const res = await inspectPackageUsage(workspace,["antd"]);
t.is(res.length, 2);
})

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shined/package-exported-usage",
"version": "0.0.5",
"version": "0.0.6",
"main": "index.js",
"types": "index.d.ts",
"napi": {
Expand Down
3 changes: 2 additions & 1 deletion src/vistor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl<'a> Visit<'a> for ImportVisitor<'a> {
if let Some(specifiers) = &decl.specifiers {
specifiers.iter().for_each(|specifier| match specifier {
ImportDeclarationSpecifier::ImportSpecifier(spec) => {
println!("{:?}", spec.local.name.to_string());
self.mapper.insert(
spec.local.name.to_string(),
ImportedNameAndNpmLibName {
Expand Down Expand Up @@ -145,7 +146,7 @@ impl<'a> Visit<'a> for ImportVisitor<'a> {
if let Some(v) = self.mapper.get(&name) {
self.used.push(Location {
lib_name: v.npm_lib_name.to_string(),
member_name: name,
member_name: v.imported_name.to_string(),
start: ident.span.start,
end: ident.span.end,
file_path: self.file_path.to_string(),
Expand Down

0 comments on commit d934f06

Please sign in to comment.