-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
RFC: Scope hoisting: support bundling browserify-built bundles #3933
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wbinnssmith
requested review from
DeMoorJasper,
devongovett,
gorakong,
mischnic and
padmaia
December 20, 2019 00:08
wbinnssmith
force-pushed
the
wbinnssmith/scope-hoist-browserify-compat
branch
3 times, most recently
from
December 20, 2019 00:15
da87fe8
to
9520b67
Compare
Benchmark ResultsKitchen Sink ✅
Timings
Cold Bundles
Cached BundlesNo bundle changes detected. React HackerNews ✅
Timings
Cold Bundles
Cached BundlesNo bundle changes detected. AtlasKit Editor ✅
Timings
Cold Bundles
Cached Bundles
Three.js x4 🚨
Timings
Cold BundlesNo bundles found, this is probably a failed build... Cached BundlesNo bundles found, this is probably a failed build... |
wbinnssmith
force-pushed
the
wbinnssmith/scope-hoist-browserify-compat
branch
2 times, most recently
from
December 20, 2019 00:46
86a31ba
to
ee7d027
Compare
wbinnssmith
changed the title
Scope hoisting: support bundling browserify-built bundles
RFC: Scope hoisting: support bundling browserify-built bundles
Dec 20, 2019
cc @mischnic |
wbinnssmith
force-pushed
the
wbinnssmith/scope-hoist-browserify-compat
branch
from
December 20, 2019 02:31
ee7d027
to
a9be8a4
Compare
I think the best solution would be: diff --git packages/shared/scope-hoisting/src/hoist.js packages/shared/scope-hoisting/src/hoist.js
index e87bea3d..04f75017 100644
--- packages/shared/scope-hoisting/src/hoist.js
+++ packages/shared/scope-hoisting/src/hoist.js
@@ -279,26 +279,31 @@ const VISITOR: Visitor<MutableAsset> = {
ReferencedIdentifier(path, asset: MutableAsset) {
if (
path.node.name === 'exports' &&
!path.scope.hasBinding('exports') &&
!path.scope.getData('shouldWrap')
) {
path.replaceWith(getCJSExportsIdentifier(asset, path.scope));
asset.meta.isCommonJS = true;
}
if (path.node.name === 'global' && !path.scope.hasBinding('global')) {
path.replaceWith(t.identifier('$parcel$global'));
}
+
+ if (path.node.name === 'require' && !path.scope.hasBinding('require')) {
+ // require() calls were already handled.
+ path.replaceWith(t.identifier('undefined'));
+ }
}, |
mischnic
force-pushed
the
wbinnssmith/scope-hoist-browserify-compat
branch
from
December 9, 2020 22:47
448dbaf
to
55246f3
Compare
I've implemented that but some situations are still broken (because JSRuntime inserts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #4634
This adds support for bundling bundles that have already been built using browserify.
The browserify prelude tests for an existing global
require
usingtypeof require === 'function'
,which we previously statically rewrote toleading it to attempt to invoke a require that does not exist. Should we find a way of conditionally rewriting these, maybe only if'function' === 'function'
,require
is only used as a function in a statically analyzable way?Test Plan: Added a test using a browserify bundle as a fixture.