-
-
Notifications
You must be signed in to change notification settings - Fork 272
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
First tx... + an issue... lazy loading...EXCEPTION: TypeError: AMD module #1504
Comments
if I run: any help is appreciated |
anyone? |
Can you share your contents of |
Hi Guy,
I no longer got the AMD error, which is good! I am using Angular2 so my lazy load is:
but on the alert I just get {} I think the issue is that maybe the 2nd statement of:
as it just returns an empty object... by the way I moved my project to jspm and love it... it kicks ass compare to Webpack. and if you want to see the code I use to load, it's here (commented out now :( ) loadComponent async: which is being called from AsyncRoute: tx again Sean |
let me know if any ideas... good stuff... |
@born2net note that is the correct behaviour - bundle files are empty modules, which define other modules into the registry. You need to load the bundle itself and then load the module you wanted from the bundle. |
I understand, I wish it actaully loaded my module :) if we could just get ng2 to lazy load separate bundles we would be golden!!! PS I believe you would need to add a feature to support it as what I am seeing is that the ng2 Injector does not know how to instantiate the imported component from the lazy loaded bundle. Sean. |
@born2net did you try using the |
I do use the
which helped as I don't get the amd error anymore. however I am still not able to get an instance of my module. I am going to give the bundles config a try again... |
I must be getting close, the issue I am having is that after creating the bundle config I get an error of:
basically System.js is trying to load the module from the drive instead of from the bundle I added bundle config as:
figured it will catch App1 with one of the entries but still no luck (but feel like getting close) |
and here is my import in ng2:
and use
any tips? |
Make sure you are including your configuration file after including SystemJS in production and before loading the bundle. |
well my config.js is injected into my bundles... :/ |
@born2net does it come at the top, before any of the System.register statements? The point is that the config needs to be already called, before running System.register or System.import. |
maybe I am wrong, but all I do is include my index.html file via:
which is the bundle created by
and so since I am using -sfx the config and System.js will already be inside no? and later in my build process I also run for the App1 bundle:
Sean. |
SFX bundles do not include SystemJS or the configuration. It's a completely different loaderless workflow to bundles. |
I know that SystemJS, the config and all my modules can be bundled into a single self executing file, which means replacing the setup within my HTML file with a script tag loading the compiled file. I run 2 separate commands: jspm bundle-sfx src/App.js " + paths.dist + "/" + paths.targetJS + ' --skip-source-maps first is for the main bundle (95% of the app) the problem is that when I try and lazy load App1, it tries to load it from disk, even though the config was bundled in the first step ... |
I tried to load the config.js inside the html file and still get same old:
|
Well it has the extension now at least! The point is to get the name imported to line up with the name defined by the bundle. If you need to double-check what that should be you can also look at if you've done a bundle inject like that then |
First let me say thank you... I am LOVING jspm. I moved to this from Webpack and will soon release my popular project on: http://ng2.javascriptninja.io/ to jspm, well as soon as I resolve this one issue...
I am trying to load a bundle dynamically.
I have my main bundle, and for the lazy loaded bundle I do:
jspm bundle-sfx src/comps/app1/App1.js out.js --skip-source-maps
and in the angular2 code I run
the problem is that I am getting an error of:
EXCEPTION: TypeError: AMD module http://localhost:8003/dist/public/out.js did not define
Is there something special I need to do to be able to load App1 dynamically (lazy load)?
(if I don't bundle lazy loading is working great by the way)...
my config.js is:
so as you can see I didn't put any special package entry for App1 (don't think I need to?!?!?!)
tx again for an AMAZING project,
I will make sure I push lots of new devs to jspm and plan on making a video tutorial on jspm workflow which kicks ass... I love working close to the metal which is what jspm allows + TS complication in the broswer, + versioning... WOW!!!! Webpack bye bye...!
regards
Sean.
The text was updated successfully, but these errors were encountered: