-
-
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
Add support for worklets and fix pipeline bugs #6495
Conversation
|
asset.bundleBehavior === 'inline' | ||
? false | ||
: dependency.isEntry || dependency.needsStableName, | ||
isInline: asset.bundleBehavior === 'inline', | ||
bundleBehavior: dependency.bundleBehavior ?? asset.bundleBehavior, |
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.
Which one should win? 😉
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 would say keep it bundleBehavior
, it's easier to search since it's all the same feature
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 think @devongovett is asking if the dependency's behavior or asset's behavior should be preferred
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 must be going crazy, I swore I commented on the comment asking #6495 (comment)
Maybe the 👁️ doctor messed up this morning hah.
In this case, what's more regular case to test against an asset being inline or isolate or a dependency being inline or isolated? And what's the expectation if the dep and asset's bundle behavior were separate.
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.
yeah I think the dep should win because the importing code might have an expectation about what the asset exposes.
* - isolated: The resolved asset will be isolated from its parents in a separate bundle. | ||
* Shared assets will be duplicated. | ||
*/ | ||
+bundleBehavior?: BundleBehavior, |
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.
API wise I'm not too sure about this. I considered combining bundleBehavior and priority, but I think it's possible to have an isolated bundle that is either parallel or lazy (but probably not sync), and it's possible to have an inline sync or async (though parallel vs lazy doesn't really matter). 🤔
packages/core/types/index.js
Outdated
@@ -1106,8 +1130,7 @@ export interface Bundle { | |||
+env: Environment; | |||
/** Whether this is an entry (e.g. should not be hashed). */ | |||
+isEntry: ?boolean; | |||
/** Whether this bundle should be inlined into the parent bundle(s), */ | |||
+isInline: ?boolean; | |||
+bundleBehavior: ?BundleBehavior; |
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.
Is bundle.bundleBehavior
too redundant? bundle.behavior
??
loc: convertLoc(dep.loc), | ||
}); | ||
} else if (dep.kind === 'File') { | ||
asset.invalidateOnFileChange(dep.specifier); | ||
} else { | ||
if (dep.kind === 'DynamicImport' && isURL(dep.specifier)) { |
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.
This was broken already because we already replaced the import()
with a require()
in rust. The isUrl check was interfering with usage of pipelines in dynamic import.
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 bundle changes detected. Cached BundlesNo bundle changes detected. 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 bundle changes detected. Cached BundlesNo bundle changes detected. |
…endencies # Conflicts: # packages/bundlers/default/src/DefaultBundler.js # packages/core/core/src/dumpGraphToGraphViz.js # packages/core/core/src/public/MutableBundleGraph.js # packages/core/core/src/types.js # packages/core/core/test/PublicBundle.test.js # packages/core/types/index.js
Fixes #1093, Fixes #2083, Fixes #4174, Closes #5837, Closes #6510
This adds support for worklets including the
CSS.paintWorklet.addModule
syntax, as well as for audio worklets via theworklet:
pipeline. The pipeline is needed in that case because the API is not statically analyzable. Worklets are a new environment context. While they are similar to web workers, they have some unique constraints: only ESM is supported (not scripts), but dynamicimport()
is not supported (as with other networking APIs like fetch). Parcel will give you a build time error for this.This also fixes several other issues that are somewhat related.
url:
pipeline with a JavaScript file was broken because theurl:
pipeline did not run other transformers before the raw transformer, meaning the JS wasn't transformed.new URL
with a JS file was also broken because the generated JS would never run its entry asset. This was because it was not marked as isolated, and so thought the parent bundle wouldparcelRequire
it like with normal async imports. Also, it assumed it had access to the modules in parent bundles, but this wasn't necessarily true. We now mark URL dependencies in JS files as isolated. This required exposingbundleBehavior
to dependencies like we do for assets.bundle-text:
or other pipelines that trigger inline bundles was broken when HMR was enabled. This was because we took the first entry asset rather than the main entry when checkingasset.meta.inlineType
.import('bundle-text:./foo')
. Previously this was just broken, but now it returns aPromise.resolve(contents)
.