deepl-node
deepl-node copied to clipboard
Circular dependency index.js ➜ parsing.js ➜ index.js
Describe the bug
When building my Svelte app that uses deepl-node, I get a warning about circular dependencies:
Circular dependency: node_modules/.pnpm/[email protected]/node_modules/deepl-node/dist/index.js -> node_modules/.pnpm/[email protected]/node_modules/deepl-node/dist/parsing.js -> node_modules/.pnpm/[email protected]/node_modules/deepl-node/dist/index.js
To Reproduce Steps to reproduce the behavior:
- Create a (Svelte) app
- Install, import (and use?) deepl-node in your code
- Build it
Expected behavior The warning not to appear by refactoring your code
Desktop (please complete the following information):
- OS: macOS
- Browser: Arc
- Version: 1.39.0
Hi, could you provide more detailed steps how to reproduce this? I just did the following (with node v18.18.2 and deepl-node v1.13.0) in a new directory:
npm create svelte@latest test-appcd test-appnpm add deepl-nodenpm install- Edit
src/app.d.tsto look like the following
import * as deepl from 'deepl-node';
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface PageState {}
// interface Platform {}
}
}
async function translate() {
let t = deepl.Translator('auth_key');
let result = await t.translateText('sample text', null, 'de');
return result;
}
export {};
- npm run dev
And I dont get this warning.
Hi, I don't have access to my code right now, but it didn't show up on a dev server, only on a full prod build (npm run build).
It's pretty easy to spot though, the index.js file imports stuff from parsing.js, and parsing.js also imports stuff from index.js, thus creating a circular import.
It's not a big problem as you only import specific functions from one another but it's just a "bad practice", hence the warning
Ah sorry, I didn't get that it's just a warning. I agree, we should move a bunch of definitions into types.ts. I'll take a look.
Sorry about the wording, thanks!