Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
fix: Quantum - replaces property require with fsx
Browse files Browse the repository at this point in the history
  • Loading branch information
nchanged committed Feb 7, 2018
1 parent 34ad034 commit 71ba880
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/quantum/core/AstUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,14 @@ export function matchesRequireFunction(node: any) {
if (parent.callee && parent.callee.name === "require") {
return false;
}

if (parent.type && parent.type === "MemberExpression" &&
parent.object && parent.object.name === "require") {
return false;
if (parent.type) {
if (parent.type === "MemberExpression" &&
parent.object && parent.object.name === "require") {
return false;
}
if (parent.type === "Property" && parent.key && parent.key.name === "require") {
return;
}
}
return true;
}
Expand Down
22 changes: 22 additions & 0 deletions src/quantum/tests/GlobalVariable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,26 @@ export class GlobalVariableTEst {
}));
}

public "Should not replace require statement"() {
return FuseTestEnv.create(

{
testFolder: "_current_test",
project: {
files: {
"index.ts": `
module.exports = {require : 1};
`
},
plugins: [QuantumPlugin({
target: "browser"
})]
}
}
).simple().then(test => test.browser((window, env) => {
const app = env.getScript("app.js");
app.shouldFindString("{ require: 1 }");
}));
}

}

0 comments on commit 71ba880

Please sign in to comment.