I get an error when following the usage for vite-plugin-plain-text:
import plainText from 'vite-plugin-plain-text';
console.log(plainText); // Check what we imported.
let config = plainText(/LICENSE$/);
The output is:
{ default: [Function: plainText] }
> plainTextPlugin is not a function
Instead of importing a function, the import statement imported an object with a function named default. In the module JS file, plainText was exported like this:
Object.defineProperty(exports, "__esModule", { value: true });
...
exports.default = plainText;
I was able to successfully import like this:
import plainTextPlugin from 'vite-plugin-plain-text';
let plainText = plainTextPlugin.default;
let config = plainText(/LICENSE$/);
Is there a more elegant way to accomplish this import? JavaScript Module Cheatsheet doesn't have any pattern for importing a library that was exported like this library. Interestingly, the TS source code exports the module like this:
export default function plainText (...)