-
Notifications
You must be signed in to change notification settings - Fork 36
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
Support async System.import (should count as dependency) #129
Comments
Thanks, will test tomorrow morning. This is an interesting case I haven't actually thought about. Assuming the bug you're seeing is fixed, I'm not sure how I will be able to determine that |
I debugged a bit and noticed that the function I think that it would be nice if SystemJs would add dependencies for System.import statements, too. asyncImport(module.id, "app-import.js")
function asyncImport(importer, moduleName) {
System.loads[System.resolveSync(importer)].deps.push(moduleName)
System.loads[System.resolveSync(importer)].depMap[moduleName] = System.resolveSync(moduleName)
return System.import(moduleName)
} |
@mpfau, that could work, but I have a feeling System.import = function(moduleName, parentName) {
if (parentName) {
// add to depMap
}
return System.proto.import.apply(System, [moduleName, parentName])
} Then you could import via // see https://github.com/systemjs/systemjs/blob/master/docs/system-api.md#systemjsimportmodulename--normalizedparentname---promisemodule
System.import('./app-import.js', __moduleName) perhaps @guybedford could rewrite |
Either way, having this in the trace API would be very useful. |
I'm getting a very similar error, but with normal ES6-style imports. In fact I think it's a basically identical error, except that the compiled version of system.js is being used instead of the debuggable source (I don't know how to change this):
I assumed I was doing something wrong, but seeing this bug report made me not so sure. The first line of the stack trace (userutil.js line 1) seems unrelated to which source file was modified. The line referenced is The above is what I get the first time a source file is modified after the app is loaded. After that any additional changes result in this error:
|
Fix coming in the next 30 min or so. |
Just recovering from a typo. Ran |
Fixed in |
Refurbishing this issue for async import support |
@alexisvincent thanks for fixing! I just tested successfully against system-hmr 2.0.8. It looks like deps and depMap are reset every time. However, that is not a problem as the file is re-imported on change (and the dependencies are re-written to deps/depMap). It would be nice, if @guybedford could adapt System.import according to your ideas when |
Something else we could do is save these import mappings in a side table. However I think the best place for this would belong in the ES-Module-Loader trace implementation. @guybedford, would appreciate your input here. |
I've been experimenting with a dynamic deps trace in ModuleLoader/es-module-loader@4f23167. What we can do is catch all calls to the dynamic I'm also not sure what use this information is to the hot reloader as well - there's no way to refresh the references once they have been returned from the import promise? Perhaps just a direct tracing of top-level imports is all that is needed. |
@guybedford Awesome! Is there a reason that you would only support this for This would work for the hot-reloader as follows. In the example that @mpfau at the top of this issue, by listing Not sure what you mean by
|
Ok, then the implementation I've got there should be a good start to play around with. It's not possible to tell when System.import with a parent key can be used for arbitrary relative normalization, without implying that it is within the given module. |
Right, of course. Awesome, would this be able to make its way into a version of SystemJS? Perhaps via a flag, for general testing? |
@alexisvincent this will be shipping in the next SystemJS release, which should be soon. |
I'm currently switching over to the current release... :-)
Normal imports are resolved perfectly when a file is changed. However, everything imported via a System.import fails with the following error:
Steps to reproduce
app.js
app-import.js
test.html
The text was updated successfully, but these errors were encountered: