How to import ES module in Tailwind config file?

I am configuring my own plugins in Tailwind config file by import ES module with CommonJS syntax require('/my-plugin'); but I get an error when trying to build:

SyntaxError: Cannot use import statement outside a module
    at compileFunction (<anonymous>)

Since I am using ES6 statements in the my-plugin file (e.g import, export default) so these causing to throw errors even though I use regular require statements to import it in my Tailwind config file.

How do I resolve this problem?

My code:

tailwind.config.js

const myPlugin = require('./my-plugin');

module.exports = {
    mode: 'jit',
    darkMode: 'class',
    content: [
        './pages/**/*.{js,ts,jsx,tsx}',
        './components/**/*.{js,ts,jsx,tsx}',
    ],
    theme: {
    }   
    plugins: [
        myPlugin(),       
    ],
};

./my-plugin

import ... from ...

const MyPlugin = () => {}

export default MyPlugin