javascript - How to auto call System or AMD modules? -
this question has answer here:
- how set typescript in symfony? 2 answers
question:
how auto call system or amd modules without manually adding script call registered/defined module ?
description:
when i'm generating es5 file using system module defined in tsconfig, expected output system.register(/* ... */) of course doesn't run when added page.
is there way avoid adding script tag html file manually call modules?
<!-- module script added above --> <script> system.get('module_name_here'); </script> extra:
if i'd forego system/amd module's completely. however, it's required moment decide create 1 outfile while using import/export in typescript. if has solution this, save me big headache. thanks.
since mention amd modules... if produce series of amd modules, use requirejs , make use of support data-main attribute kick off application:
<script src="require.js" data-main="module_name_here"></script> there's deps option can used when configuring requirejs:
require.config({ ... deps: ["module_name_here"], }); data-main takes single module name, whereas deps takes list of modules. these means typically used avoid having additional script element generated kick off module loading.
i don't know of equivalent systemjs. see , forth data-main in systemjs issues on github seems coin flip landed on not implementing now.
if list of modules need load known @ time of building application, have application bundled webpack single script. application start load script.
Comments
Post a Comment