My current setup in nextjs is configured to handle ES6 code for IE11.
module.exports = {
poweredByHeader: false,
distDir: "ssr_build",
webpack(config) {
config.node = { fs: "empty", net: "empty", tls: "empty" }
config.plugins = config.plugins || []
config.module.rules.push({
test: /\.js$/,
include: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: [
[
"next/babel",
{
targets: { ie: 11 },
},
],
],
},
},
})
return config
},
}
I am looking for a way to transpile only the ES6 modules within node_modules, without wasting time transpiling everything. Can anyone provide guidance?
Update1.0:
After using https://github.com/obahareth/are-you-es5 to identify ES5 dependencies needing conversion, I attempted creating an exclusion regex without success. I will revisit this to check for any missed nested dependencies.
I also tested https://github.com/martpie/next-transpile-modules, but found that it required manual insertion of all node_modules, which appeared to be a cumbersome process. As a result, I abandoned this approach.