Closed schetnikovich closed 7 years ago
Looks like a bug, but I can see why it is happening. It looks like client.js
is already part of the initial page load and because of that there is nothing to asynchronously load. Because there is nothing to asynchronously load there is no writing of the metadata required for async loading. As a result of no metadata, you are seeing an error.
I'll look into a fix. Thank you for reporting the problem!
Thank you, Patrick! Just a small comment to help you understand my "real" problem. Minimal page setup presented above is not a "real-world" problem. What i'm trying to do is the following:
file1.js
:
exports.load = function() {
require("lasso-loader").async(function(err) {
var client = require('./file2.js');
});
};
file2.js
:
exports.load = function() {
require("lasso-loader").async(function(err) {
var client = require('./file1.js');
});
};
Both file1.js
and file2.js
can be loaded asynchronously by each other or as part of initial page load. Hope that this is possible with Lasso!
I fixed this issue and published lasso@2.7.2
Just checked new lasso@2.7.2
and it works as expected! Thank you, Phillip and Patrick!
When using
require('lasso-loader').async(...)
for already loaded resources (JS, CSS etc), Lasso throws error similar to:Loader metadata missing for "_0"
.The minimal page setup that reproduces this behavior is the following.
Content of
browser.json
:Content of
client.js
(the only client script):The following error is thrown on page load:
But it works when you add not yet loaded resource
The same code will work when you add some not yet loaded resource. Here is
client.js
with single line added:In this case, no errors are thrown.
I have faced with this error in a context when two bundles load asynchronously each other.
Bundle1
successfully loadsBundle2
, but thenBundle2
fails to loadBundle1
. It seems that the fact thatBundle1
was already loaded, somehow prevents this operation to complete. Error message is the same as the one shown above.Let me know if I'm doing something wrong. Thank you!
Environment: