-
-
Couldn't load subscription status.
- Fork 162
Description
ES6 modules are supposed to be an object, however this package exports a function by default.
To make it work in TypeScript it requires this option set to true, which means extra code in the build... and would be nice not requiring it.
now:
import clsx from 'clsx';after:
import { clsx } from 'clsx';Since this would be a breaking change, I would suggest applying this fix in a way that the old version is also supported -which requires a bit of dirty code- and then apply the clean version in a major version up release :)
// the dirty hack would look like this (types also required)
module.exports.clsx = module.exports;
// so you actually can do both in this version preserving compatibility
import clsx from 'clsx';
import { clsx } from 'clsx';next version (let's say a major version up) could just export the function like this:
function clsx () {
var i=0, tmp, x, str='';
while (i < arguments.length) {
if (tmp = arguments[i++]) {
if (x = toVal(tmp)) {
str && (str += ' ');
str += x
}
}
}
return str;
}
module.exports = { clsx };With this migration we are achieving two things:
- Following ES6 standards
- Requiring less code when compiling in typescript since
esModuleInteropwouldn't be required anymore
Metadata
Metadata
Assignees
Labels
No labels