Actually i have a project which i need to include in Next JS as a module. So basically i am trying to use it via npm link
, I am successfully able to add that module into my next JS repo as a component. But it is breaking because of webpack loaders. Should i need to add all the loaders necessary in next JS? what is better way to achieve this ?
By default Next.js doesn't compiles dependencies located at node_modules
.
You should use next-transpile-modules
in order to instruct it to compile specific libs.
// next.config.js
const withTM = require('next-transpile-modules')(['somemodule', 'and-another']);
module.exports = withTM({
...regular next config
});