preboot / angular-webpack

A complete, yet simple, starter for Angular v2+ using webpack
MIT License
1.29k stars 556 forks source link

how to import vendors ? #343

Open phil123456 opened 7 years ago

phil123456 commented 7 years ago

Hi

I tried to move my "lodash" import to the vendor.ts but as expected,

the compilation gave errors

polyfills.js:7530 [at-loader] ./src/app/auth/auth.service.ts:56:25 
TS2686: '_' refers to a UMD global, but the current file is a module. Consider adding an import instead.

polyfills.js:7530 [at-loader] ./src/vendor.ts:14:13 
TS6133: '_' is declared but never used.

what am I missing ?

vendor.ts

// Angular 2
import '@angular/platform-browser';
import '@angular/platform-browser-dynamic';
import '@angular/core';
import '@angular/common';
import '@angular/http';
import '@angular/router';

import 'rxjs';
import '@angularclass/hmr';

// Other vendors for example jQuery, Lodash or Bootstrap
// You can import js, ts, css, sass, ...
import * as _ from 'lodash';

thanks

maxx0r commented 7 years ago

You should add the declaration in the auth.service.

there's no such thing as global variables as you're trying to use it :)