0

I might be missing something obvious here, but how am I supposed to import a third-party library that doesn't export anything.

I tried all of the following

import '../bower_components/asn1js/asn1'; import {ASN1} from '../bower_components/asn1js/asn1'; import ASN1 from '../bower_components/asn1js/asn1'; 

Neither of which worked.

If you take a look at the asn1.js file you can see in the end the following:

// export globals if (typeof module !== 'undefined') { module.exports = ASN1; } else { window.ASN1 = ASN1; } 

It seems that it is trying to export itself. I'm not familiar with this so could you explain me:

  • What decides whether module is undefined? where should it be defined?
  • If it is undefined or api doesn't use export, how can I import/use it?
1

1 Answer 1

0

Since it is exporting a global object you don't need to import it. If anything what you would be importing would be it's TypeScript.definition file but I am not sure there is one yet.

So you should just try the following.

@Component({ selector: 'Component', directives: [], providers: [], template: ` <h3>Component</h3> ` }) export class Componentimplements OnInit{ constructor(private _asn1 : window.ASN1 || ASN1){ } ngOnInit(){} } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.