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
Allow bundling browserify bundles by replacing free requires with undefined #6260
Conversation
This pull request has been linked to and will mark 1 task as "Done" when merged:
|
Benchmark ResultsKitchen Sink 🚨
Timings
Cold BundlesNo bundles found, this is probably a failed build... Cached BundlesNo bundles found, this is probably a failed build... React HackerNews 🚨
Timings
Cold BundlesNo bundles found, this is probably a failed build... Cached BundlesNo bundles found, this is probably a failed build... AtlasKit Editor 🚨
Timings
Cold BundlesNo bundles found, this is probably a failed build... Cached BundlesNo bundles found, this is probably a failed build... Three.js 🚨
Timings
Cold BundlesNo bundles found, this is probably a failed build... Cached BundlesNo bundles found, this is probably a failed build... |
Would it be simpler to only look for |
It now replaces free |
|
||
return node.fold_children_with(self); | ||
fn fold_unary_expr(&mut self, node: ast::UnaryExpr) -> ast::UnaryExpr { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't fold_expr
already take care of this? It should run before fold_unary_expr
I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UnaryExpr
is an enum variant of Expr
, so Expr
is visited before the UnaryExpr
.
Do you mean I should move the logic from fold_unary_expr
to fold_expr
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, we already handle UnaryExpr
inside the fold_expr
visitor, and return without visiting children, so I'm not sure why this additional visitor is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, we already handle UnaryExpr inside the fold_expr visitor
I think you are looking at hoist.rs? All of my current changes are in dependency_collector.rs now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right 🙈
typeof require == "function" && require
} | ||
} | ||
|
||
node.fold_children_with(self) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like fold_member_expr
is missing.
All passes touching identifier should implement it and fold prop
only if computed
is true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a cause of #6323
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wrong. Sorry for the mistake.
…raph * bdo/buffer-backed-graph: (37 commits) Improve resolver performance (#6328) v2.0.0-beta.3.1 Add it to the nightly release workflow as well Configure jemalloc page size for M1 (#6314) Update swc (#6307) Fix parcelDependencies v2.0.0-beta.3 Update swc (#6289) Remove old AdjacencyList, serialize EfficientGraph in Graph, update BundleGraph to use new functions Babel ast location, diagnostic, and source location remapping (#6238) update contributing guide (#6293) Update sourcemap to rc-1.0 (#6279) Serve nearest index.html in case the applications has multiple index files (#6250) Allow bundling browserify bundles by replacing free requires with undefined (#6260) Upgrade flow to 0.151.0 (#6281) Use local require for `@babel/core` and `postcss` (#6264) Resolve helpers relative to JS transformer (#6278) Pure comment for $parcel$interopDefault (#6271) Don't transpile spread in JSX with modern targets (#6274) Update TS validator assertions (#6272) ...
Closes #3933, Closes #4634, Closes T-1002
This replacestypeof require == "function" && require
(and commutative equivalents, or with===
) withundefined
, so that browserify bundles don't throw.require
is never actually called, but still assigned to a local variable.Previously, it was replaced with"function" == "function" && require
.This replaces free
require
s (so everything excepttypeof require
andrequire("some...string")
withundefined
.