Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default export #106

Closed
wants to merge 1 commit into from
Closed

Add default export #106

wants to merge 1 commit into from

Conversation

andywer
Copy link

@andywer andywer commented Mar 7, 2018

Make ES module - compatible and allow TypeScript users to easily use the package.

This will work after merging the PR:

import ms from 'ms'

I am not a big fan of those double CJS / ES exports myself, but there are a couple of scenarios when you have basically got no other choice.

@andywer
Copy link
Author

andywer commented Mar 7, 2018

Update: I just learned there is now finally a way around that issue, see this tweet.

Feel free to turn down the PR if you want :)

@leo
Copy link
Contributor

leo commented Mar 9, 2018

Glad you found a fix! Generally, this should be resolved by Webpack anyway... 😊

@leo leo closed this Mar 9, 2018
@ericsnap
Copy link

ericsnap commented Dec 3, 2018

@andywer how did you get this to work? in NodeJS? Angular?

@andywer
Copy link
Author

andywer commented Dec 4, 2018

@ericsnap Just set the esModuleInterop option to true in your tsconfig.json. See here. It's a TypeScript thing, so it works everywhere: frontend, backend, wherever you use TS.

@ericsnap
Copy link

ericsnap commented Dec 4, 2018

@andywer thanks. yeah, I was having issues compiling it kept saying that it did not have a default export. I did have to also set allowSyntheticDefaultImports. Does the module setting or the target have any impact on this?

@andywer
Copy link
Author

andywer commented Dec 5, 2018

@ericsnap Try:

{
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "module": "commonjs",
    // ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants