-
-
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 a html bundleloader #178
Comments
This issue looks interesting to me, although I don't know much about it. I shall read about it. |
@abiduzz420 Sounds good! |
@davidnagli @devlux I am going to add support for |
@davidnagli @devongovett I have done some reading and got a bit of understanding. Want to share the code on the lines I'm thinking. Would like to know if I'm doing it properly:
Also mention if there is any certain detail I've not taken care of. |
@abiduzz420 thanks for taking over this story! :-) I've read into the code myself today and I think the loadHTMLBundle method receives an URL to load the HTML fragment from. The purpose of this method is to load the content from that URL, e.g. by using HTML import as follows: function loadHTMLBundle(bundle) {
return new Promise(function (resolve, reject) {
var link = document.createElement('link');
link.rel = 'import';
link.href = bundle;
link.onerror = function (e) {
link.onerror = link.onload = null;
reject(e);
};
link.onload = function () {
link.onerror = link.onload = null;
resolve();
};
document.getElementsByTagName('head')[0].appendChild(link);
});
} The content may then be accessed by calling: var content = document.querySelector('link[rel="import"]').import; Unfortunately HTML import it is not yet supported by all browsers, but there is a polyfill: https://caniuse.com/#search=html%20import I'm still trying to understand how the bundle model is created initially. And in the end the content needs to be resolved by the require promise. Therefore the above snippet seems to be only one part of the solution... ;-) |
@devlux Thanks for sharing the update. |
@devlux Have you looked at Webpack, browserify source code on how they solve this problem ? Perhaps we can take inspiration from there. I will look into how this problem is solved by webpack. Do let me know if you've found something exciting 😄 |
I'm reading about Polyfills-Web components, looking into Polymer as well. Will update my progress soon @davidnagli |
Sounds good to me |
I wrote the test for the below, not able to figure why it throws TypeError:
|
@abiduzz420 hmu on slack would love to help you out with implementing this |
Just wanted to make sure everyone knows Polymer 3 abandons HTML Imports in favor of ES modules NPM. You can glean an example of Polymer 3 pre.12, PSK (Polymer Starter Kit) with Webpack at: https://goo.gl/9KSRr7 Would love to see Parcel for Polymer 3. 🤗 |
🙋 feature request
Add a html bundleloader to allow html fragments to be loaded dynamically, like already possible with js or css content.
🤔 Expected Behavior
Add a html bundleloader to allow html fragments to be loaded dynamically, like already possible with js or css content.
import('view.html')
😯 Current Behavior
Currently the following exception is thrown as no html bundleloader is implemented yet:
bundleLoaders[type] is not a function
💁 Possible Solution
Add a new html bundleloader to the existing bundleloaders:
parcel/src/builtins/bundle-loader.js
Line 24 in c8295de
🔦 Context
I'm migrating a small spa from requirejs to parcel-bundler.
The text was updated successfully, but these errors were encountered: