Closed nganlamsong closed 7 years ago
everyone forgets to install the underscore types library npm install \@types/underscore
also import * as _ from 'underscore';
should go at the top of your *.component.ts files as needed. you should not need to import underscore in your vendor.ts file.
@strictd could you please elaborate why underscore should not be in vendor.ts ? How do you decide what goes where?
It seems to boil down to what file your third party module is packed in when compiled. Think of vendor.js as the shared third party module pack for your main app.js and any lazy loaded packs.
it works with or without import 'underscore';
inside vendor.js .. Look at the file sizes of your output dist/js/*.js files running it both ways.
I will kill vendor.ts soon, probably. Doesn't work well with lazy loading.
I cannot use underscore in my project:
I tried to add 'import * as _ from 'underscore';' in vendor.ts but it no use! When I tried to run "npm run build", I got error message ""Can not find module 'underscore' "". Am I missing something? Please provide the correct way to use underscore! Thanks!