question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for import via es6 import

See original GitHub issue

Is there a way we can import it via npm similar to how react does it?

import React, {Component} from 'react';
import ReactDOM from 'react-dom';

I tried these four and it didn’t work:

import numbro from 'numbro';
import {numbro} from 'numbro';
import * as numbro from 'numbro';
import 'numbro'

Thanks.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
stijnherremancommented, Oct 21, 2016

I’m having trouble getting this to work in combination with TypeScript and webpack. It might just be an issue with the TypeScript Definition file, though.

When using import numbro from "numbro" or import {default as numbro} from "numbro":

  • IntelliSense says numbro is of type NumbroStatic and numbro(1000) should work
  • At runtime, numbro is undefined

When using import * as numbro from "numbro";:

  • IntelliSense says numbro is the whole module/package (not sure which term to use) with the 3 interfaces and the exported default listed
  • At runtime, numbro is the function defined under Top Level Functions as numbro = function(input) {
  • This code works: return ((numbro as any)(1000) as numbro.Numbro).format("0.0")

Any idea what I’m doing wrong? Or is this a bug in the Definition file?

1reaction
mmollickcommented, Jul 12, 2016

I use import numbro from 'numbro'; just fine with webpack + babel. What are you using to transpile your ES6?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use an ES6 import in Node.js? - GeeksforGeeks
Introduction to ES6 import: The import statement is used to import modules that are exported by some other module. A module is a...
Read more >
JavaScript modules: dynamic import() - CanIUse
"Can I use" provides up-to-date browser support tables for support of front-end web ... Loading JavaScript modules dynamically using the import() syntax.
Read more >
ES6 Modules and How to Use Import and Export in JavaScript
The ES2015 (ES6) edition of the JavaScript standard gives us native support for modules with the import and export syntax.
Read more >
import - JavaScript - MDN Web Docs - Mozilla
The static import declaration is used to import read-only live bindings which are exported by another module. The imported bindings are ...
Read more >
How can I use an ES6 import in Node.js? [duplicate]
You can also use npm package called esm which allows you to use ES6 modules in Node.js. It needs ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found