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 #1528. Closes #926. Closes #1017. Closes #1016.
Fixes #848. Fixes #178.
This is based on some of the work listed in the above PRs. Thanks @pierredavidbelanger and @stevengill.
Enables both async and "sync" HTML imports into JS.
import('./some.html')
import html from './some.html'
orrequire('./some.html')
The reason "sync" is in quotes there is because it currently actually isn't sync. It works like "sync" WASM imports:
some.html
is still written out as a separate file, and the JS bundle preloads it before executing the bundle so that it appears synchronous to the code importing it but is actually async under the covers.This may not be the desired outcome in all cases - sometimes you might actually want HTML to be inlined into the JS so it is actually synchronous (unlike WASM). This could be a future improvement. For now, that is too hard to implement since we need to actually run the HTML packager inside the JS packager to get the final HTML contents (not currently possible). In Parcel 2 we will be looking at doing composable packagers, which would solve both this and other issues like inlining JS/CSS into HTML (#1456).