Closed ngugcx closed 11 months ago
This is not really a good idea to use:
exports.test = test;
Since:
exports = test;
Will just overwrite exports
variable, not make any exports.
One of third party modules I'm using now uses this way to export. Can putout handle it?
Yes, just landed a new rule nodejs/convert-exports-to-module-exports
. Enable it, and it will do the thing.
Is it works for you?
I want to convert it to es module export.
Upgrade to v33 and try it, should work for you use case.
Tried, lots of plugin not found errors:
No plugin found for a rule: "convert-commonjs-to-esm"
No plugin found for a rule: "convert-commonjs-to-esm/require"
There is no more such plugins (they are merged to @putout/plugin-nodejs
), read release notes.
Here is updated config for your use case:
{
"rules": {
"strict-mode/add-missing": "off",
"package-json/add-type": "off",
"remove-console": "off",
"nodejs/convert-commonjs-to-esm": "on",
"try-catch/sync": "off"
}
}
Is it works for you?
.putout.json
lib.js
package.json
:putout lib.js --fix
exports in lib.js is not modified.