Closed ghost closed 3 years ago
We have a couple of complications. Need input @saghul
transport/postis.js
is in commonjs format
transport/postis.cjs
export default function Postis(options) {
instead of module.exports = Postis;
npm run lint
-> eslint .
-> .eslintrc.js
is in commonjs format (and eslint as well)
.eslintrc.js
to .eslintrc.cjs
Note:
official docs suggest this:
JavaScript (ESM) - use .eslintrc.cjs when running ESLint in JavaScript packages that specify "type":"module" in their package.json. Note that ESLint does not support ESM configuration at this time.
Also, we need to update eslint to support .eslintrc.cjs
.
Origin
While working on a project for Mattermost Hackathon 2020, I encountered this issue. I used a bundler to solve this issue, but I think this will help future dependants of this package.
Purpose:
Node.js now has an experimental support for marking package type as es module. If we mark this package es module, other node.js es module projects that depend upon this package, can start using es imports directly, like this:
Reference:
See https://nodejs.org/docs/latest-v13.x/api/esm.html#esm_package_json_type_field