Extract to parser helpers extended#3846
Conversation
|
Need to sync up branch again after merging #3843 |
f423f8d to
dbf54e7
Compare
| }); | ||
| IGNORES.forEach(key => { | ||
| parser.plugin(key, () => true); | ||
| parser.plugin(key, ParserHelpers.returnTrue); |
There was a problem hiding this comment.
Really? This is not an optimization?
There was a problem hiding this comment.
I probably went a bit too far here 😨
All those lonely () => true, i thought i give them a new home.
(at least it only creates one function instead of many. but thats the best excuse I can come up with.)
that being said, happy to revert :)
There was a problem hiding this comment.
Actually doesn't this yield better performance simply for the case of the same hidden class being reused by the JIT Optimizer? Maybe that is just for the case of property access. I'm on the fence really. Either work. Less dedupe but also less flexible.
There was a problem hiding this comment.
it should, but probably so small if even measurable, that it is kind of premature if it doesnt have any other advantages.
except those functions get called a lot, because they would need to be created on each call, not sure if that counts for this code?
There was a problem hiding this comment.
If you are extracting this into a helper, it's probably better to describe what it actually does in the context of the parser instead of just "returns true". ParserHelpers.skipTraversal?
There was a problem hiding this comment.
would ParserHelpers.skipTraversal be acceptable @sokra ?
would describe a lot better what it would do in this context than a simple "return true", no?
There was a problem hiding this comment.
well I guess the only problem with skipTraversal is that it is only true in 3 cases, and in the other cases it just "confirmes" can-rename.
Would it be ok for me to add two helper functions, one approve and one skip so they semantically work? given that a simple () => true can have these meanings make the code hard to read imho
| }); | ||
| IGNORES.forEach(key => { | ||
| parser.plugin(key, () => true); | ||
| parser.plugin(key, ParserHelpers.returnTrue); |
There was a problem hiding this comment.
If you are extracting this into a helper, it's probably better to describe what it actually does in the context of the parser instead of just "returns true". ParserHelpers.skipTraversal?
| parser.plugin("call require.config", remove); | ||
| parser.plugin("call requirejs.config", remove); | ||
| parser.plugin("call require.config", ParserHelpers.toConstantDependency(";")); | ||
| parser.plugin("call requirejs.config", ParserHelpers.toConstantDependency(";")); |
There was a problem hiding this comment.
(unrelated) this probably should resolve to undefined instead of ;; CallExpression is an expression after all.
There was a problem hiding this comment.
Good point. But we could do this in a seprate PR, as this also require tests...
Do you want to open one?
|
|
Urgs will fix! |
9891c24 to
cf7bb83
Compare
|
Let's sync master and see how this guess against new benchmarks for perf against master. |
- rename module and file from ModuleParserHelpers to ParserHelpers - change imports and usages - rename addParsedVariable to addParsedVariableToModule to add module context again
- reduces sideeffects as parser is called outside of helper - allows better reuse
convert all usages of new BasicEvaluatedExpression().setBoolean to ParserHelper.evaluateToBoolean
changes usages of toConstantDependency so far
the initial method does not need really another name
…ate methods - skipTraversal if a "return true" indicates to break walking - approve if "return true" means to approve a "parse request" such as "can-rename"
…d of `undefined` this may lead to potential Syntaxerrors as `const x = requirejs.config();` would be transformed to `const x = ;;`
cf7bb83 to
f46dac8
Compare
|
ill resolve the conflicts |
Conflicts: lib/dependencies/AMDPlugin.js
|
|
done |
|
Thanks |
What kind of change does this PR introduce?
refactoring
Did you add tests for your changes?
Is covered by existing tests
If relevant, link to documentation update:
N/A
Summary
See #3843
Does this PR introduce a breaking change?
No
Other information
extends/continues #3843