Skip to content
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

fix(concatenate): nested named fn expr conflicted #1357

Merged
merged 4 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ impl Visit for FnExprIdentCollector {
if let Some(fn_ident) = fn_expr.ident.as_ref() {
self.idents.insert(fn_ident.to_id());
}

fn_expr.visit_children_with(self);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const {
injectSimpleJest,
parseBuildResult
} = require("../../../scripts/test-utils");
Comment on lines +1 to +4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

确保测试工具的正确集成

../../../scripts/test-utils 导入的 injectSimpleJest 函数未在 scripts/test-utils.js 文件中找到。请确认该函数是否存在或名称是否正确。

  • injectSimpleJest 函数缺失
Analysis chain

确保测试工具的正确集成

请确保从 ../../../scripts/test-utils 导入的 injectSimpleJestparseBuildResult 函数已经正确实现,并且与当前测试场景兼容。

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the existence and correctness of the imported functions.

# Test: Search for the function definitions. Expect: Definitions of injectSimpleJest and parseBuildResult.
rg --type javascript 'function injectSimpleJest|function parseBuildResult' ../../../scripts/test-utils

Length of output: 139



Script:

#!/bin/bash
# Description: Verify the existence and correctness of the imported functions.

# Test: Search for the function definitions. Expect: Definitions of injectSimpleJest and parseBuildResult.
rg --type js 'function injectSimpleJest|function parseBuildResult' ../../../scripts/test-utils

Length of output: 164



Script:

#!/bin/bash
# Description: Locate the test-utils file and verify the existence and correctness of the imported functions.

# Step 1: Locate the test-utils file.
test_utils_file=$(fd test-utils.js)

# Step 2: If the file is found, search for the function definitions within the located file.
if [ -n "$test_utils_file" ]; then
  rg --type js 'function injectSimpleJest|function parseBuildResult' "$test_utils_file"
else
  echo "test-utils.js file not found."
fi

Length of output: 218



Script:

#!/bin/bash
# Description: Verify the existence of the injectSimpleJest function in the scripts/test-utils.js file.

# Search for the injectSimpleJest function definition.
rg --type js 'function injectSimpleJest' scripts/test-utils.js

Length of output: 64

const { files } = parseBuildResult(__dirname);
injectSimpleJest();

require("./dist/index.js");
stormslowly marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function addTarget() {
return "ok";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const root = require("./module");

it("should detect nested named fn expr ident", () => {
let target = root.c.addTarget();

expect(target).toBe("OK");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"entry": {
"index": "./index.js"
},
"optimization": {
"skipModules": true,
"concatenateModules": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { addTarget as _addTarget } from "./file1";

const createC = function () {
const methods = [
{
key: "addTarget",
// the nested function expression
value: function addTarget() {
_addTarget();
return "OK";
},
},
];

return {
[methods[0].key]: methods[0].value,
};
};

const c = createC();

export { c };
Loading