felixge / felixge/node-dateformat

Unable to import dateformat using browserify

未关闭
#170 7 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
1.3k
派生
155
PR 合并指标
30 天内没有已合并 PR

描述

I am unable to import dateformat using the latest version 5.0.1.
However, with version 4.6.3, it does work. I guess, that's as starting from 5.0.1, the module is not common js module anymore (?)

```
import dateFormat from "dateformat";
```
gave me the following error :
```
ParseError: 'import' and 'export' may appear only with 'sourceType: module'
```

I use TypeScript and bundle modules with browserify using tsify as plugin in Node.js, like this:
`` browserify ./client/src/js/main.ts -p [ tsify -p ./client/src/tsconfig.json] -o client/src/temp/main.js ``

Here's part of my tsconfig.json:
```
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"esModuleInterop": true
}
```

I already tried importing the module using a different Typescript import form, but with no success.

As far as I saw, I use other ES modules and there was no problem, so far. So, I wonder, what am I missing here?

Thank you in advance.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。