How to import a module that extends another in the same namespace

Simple road block. I need to use the Flyer and Draw flyer poster in some of my services.

I do not know how to import the complete module (kernel and plugin)

// the core import * as L from 'leaflet'; // extension import 'leaflet-draw'; export class LeafletConsumerService {} 

I have a solution that I don't like. I load libraries by linking them tightly in index.html , and the consumer just has a link ad for sample files

 /// <reference path="../typings/index.d.ts" /> export class LeafletConsumerService {} 

Is there any other way I can do this? Is there a way to import a single file, which should just cause a side effect on an already loaded module?

+2
source share
1 answer

Good, quick and dirty solution. This answer will work if you start your project with quickstart repo . Go to system.config.extras.js and expand your configuration as such:

 System.config({ map: { 'leaflet': 'npm:leaflet/dist/leaflet.js' }, packages: { leaflet: { defaultExtension: 'js' }, } }); 

this means that we can now import the booklet as such

 import * as L from 'leaflet'; 

and add the appropriate extension files as described

 import 'your-leaflet-extension'; 

Remember to expand the type information for your extensions (via a typing file or make your own)

+1
source

All Articles