I'm migrating my Next.js project from Babel compiler to Next.js SWC-powered compiler - https://nextjs.org/docs/architecture/nextjs-compiler
After the necessary changes the app itself works fine, however inside the app there are imports that were powered by Babel's Module Resolver plugin - https://github.com/tleunen/babel-plugin-module-resolver
The .babelrc
config itself is defining these aliases like this -
[
"module-resolver",
{
"root": ["./"],
"alias": {
"~": "./src",
"~~": "./"
}
}
],
but ESLint cannot resolve the imports defined either with ~
or ~~
e.g. -
Unable to resolve path to module '~/services/my-service'. eslintimport/no-unresolved
Inside .eslintrc
there's import/resolver
settings (Babel import resolver removed - https://github.com/tleunen/eslint-import-resolver-babel-module) e.g. -
settings: {
'import/resolver': {
'node': {
// 'babel-module': {
// 'extensions': ['.js', '.jsx', '.ts', '.tsx']
// },
'extensions': ['.js', '.ts', '.tsx']
}
}
}
Not sure what is missing in this setup. How does SWC knows the correct aliases ~
or ~~
and what should be done to make ESLint happy again?