Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Import with Typescript and Babel VS import with just Typescript #3650
I'm using Moment 2.17.1 with TypeScript 2.1.1, OS X (10.11.6) and Node 6.3.0. I'm having trouble importing moment consistently.
In our dev and prod environments, we use Babel to compile. In that scenario, this import statement works:
This works in the browser but causes
Our test code is built without babel, just
This makes node happy but brings back the dreaded
Naturally, I need to find one import to rule them all if I want to test any code that uses moment.
I have enabled
@opavader I've been struggling with this for weeks now. It finally just dawned on me.
So my complete file looks like this:
YMMV but this seems to work with my configuration with Webpack, Typescript, and all the other stuff my template created for me.
Edit; This broke some functionality such as isometric-fetch in my site.
@darkbasic I was running into this issue as well, but just discovered a fix for my own situation. I deleted the entire node_modules directory and the package-lock.json file, then reinstalled all of the modules, rebuilt the project and the error went away. The Sr. dev on my team thinks that one of the packages was slightly out of sync and causing the issue, this may not be the case for everyone but it might help.
added a commit
Aug 8, 2018
@subvertallchris @rawrmaan @vittau hello guys, is there any one fixed this issue? i just run into this issue, you can reproduce it with project here. Of cause, you can fix it by modify es6 module to commonjs module in tsconfig.json or just rewrite