Using Next,js. Got 'earcut' is not defined error

First thing to know : I know I have to download ‘earcut’ lib via npm/cdn

document says I can add earcut in webpack like below, but I don’t know how to do with next.js

module.exports = {
    context: __dirname,
...
    plugins: [
        new webpack.ProvidePlugin({
            'earcut': 'earcut'
        })
    ]
}

I tried other third party library to modify config. but never works.
It is so inconvenient pass earcut to ExtrudePolygon function everytime I call it.

It’s not a question that’s directly related to babylon.js but I need your help.If you are using next.js , please let me know how you using function that require earcut.

thanks

cc @RaananW