-
-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error while loading rule 'import/no-cycle': Package subpath './adapters/next/app' is not defined by "exports" #691
Comments
Thanks for the report, the bundling looks and works fine on my end. What's your ESLint version? Could you paste your tsconfig.json here please? |
removing nuqs and adding again did not solve the issue. If it's not a bug in nuqs, no problem to close this issue, you don't have to fix my local issues, but I was worried that more users would face this whilst updating to the latest jsconfig.json {
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/assets/*": ["src/assets/*"],
"@/auth/*": ["src/auth/*"],
"@/components/*": ["src/components/*"],
"@/hooks/*": ["src/hooks/*"],
"@/layouts/*": ["src/layouts/*"],
"@/locales/*": ["src/locales/*"],
"@/handlers/*": ["src/handlers/*"],
"@/routes/*": ["src/routes/*"],
"@/sections/*": ["src/sections/*"],
"@/theme/*": ["src/theme/*"],
"@/utils/*": ["src/utils/*"]
}
}
} |
Ah I think I see what the problem might be. For some TypeScript configs (that didn't support/honor export paths), the import needed to have top-level .d.ts files that point to the correct ones in the Looks like the ESLint rule chokes on those files, where: I'll see in what cases we need those intermediate top-level declaration files. If we could do without, I'd be happy, they are a pain to maintain. What happens if you delete |
after deleting Error while loading rule 'import/no-cycle': Package subpath './adapters/next/app' is not defined by "exports" on my end |
The following eslint rules are throwing this error: {
'import/named': 0,
'import/order': 0,
'import/no-cycle': 0,
'import/extensions': 0,
'import/no-unresolved': 0,
'import/no-duplicates': 0,
'import/no-self-import': 0,
'import/no-relative-packages': 0,
'import/no-extraneous-dependencies': 0,
} All of these point to the same file: /**
* Given
* @param p - module path
* @param context - ESLint context
* @return - the full module filesystem path; null if package is core; undefined if not found
* @type {import('./resolve').default}
*/
function resolve(p, context) {
try {
return relative(p, getPhysicalFilename(context), context.settings);
} catch (err) {
if (!erroredContexts.has(context)) {
// The `err.stack` string starts with `err.name` followed by colon and `err.message`.
// We're filtering out the default `err.name` because it adds little value to the message.
// @ts-expect-error this might be an Error
let errMessage = err.message;
// @ts-expect-error this might be an Error
if (err.name !== ERROR_NAME && err.stack) {
// @ts-expect-error this might be an Error
errMessage = err.stack.replace(/^Error: /, '');
}
context.report({
message: `Resolve error: ${errMessage}`,
loc: { line: 1, column: 0 },
});
erroredContexts.add(context);
}
}
} |
Almost same problem here I think. Same eslint
Seems a problem of how node |
Could you show me your eslint config please? I'm trying to reproduce on a fresh repo. |
packages:
config (I think you can cut it a bit, error is in 'import/no-cycle'):
|
With that config & packages, running |
@franky47 that is strange, I cloned the exact same repo: and did
And it threw Error while loading rule 'import/no-cycle': Package subpath './adapters/next/app' is not defined by "exports" Further config maybe? I'm running on
|
Ah I see, |
OK I found the issue: eslint 8 only supports CJS exports in package.json, and nuqs 2 is ESM only. Adding this in nuqs's {
"exports": {
"./adapters/next/app": {
"types": "./dist/adapters/next/app.d.ts",
"import": "./dist/adapters/next/app.js",
"require": "./dist/adapters/next/app.js" // Line added
}
}
} |
Ahh, got it, makes sense! Are you planning on releasing a patch with this in the package.json, or do you expect us to edit the package.json locally? I saw 2.0.2 landed, which is still without |
Yes, the fix is correct! (damn, I saw that file but I didn't think about that..) |
I can't add this as-is to the package.json, as there isn't a valid CJS bundle to point to, and pointing to the ESM one just for ESLint to be happy seems like opening a can of worms. I just tried replacing them with Looks like updating to ESLint 9 won't help, as the error comes from Unfortunately, Node.js 23's CJS/ESM interop doesn't seem to help here either. So yeah the best course of action would be to do a local patch-package to add this hack (we can add that to the caveats section in the docs, and link back to this issue) |
One other thing that works: pointing the {
"exports": {
"./adapters/next/app": {
"types": "./dist/adapters/next/app.d.ts",
"import": "./dist/adapters/next/app.js",
"require": "./dist/empty-file-for-eslint.cjs"
}
}
} |
Uhm, strange. Setting this line
makes eslint to works correctly in my case. |
Can y'all try this? pnpm add https://pkg.pr.new/nuqs@701 |
It works |
Yes! Great!
As far as I can see no problems! |
🎉 This issue has been resolved in version 2.0.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Context
What's your version of
nuqs
?What framework are you using?
Which version of your framework are you using?
Description
eslint fails on
import { NuqsAdapter } from 'nuqs/adapters/next/app'
with message:Reproduction
import { NuqsAdapter } from 'nuqs/adapters/next/app'
"eslint": "^8.57.0"
"eslint-plugin-import": "^2.31.0"
"eslint-import-resolver-alias": "^1.1.2"
The text was updated successfully, but these errors were encountered: