VSCODE Quick Fix (`cmd + .`), der meine Bibliothek nicht vorschlägt, wenn er von` .tgz` installiert istJavaScript

Javascript-Forum
Anonymous
 VSCODE Quick Fix (`cmd + .`), der meine Bibliothek nicht vorschlägt, wenn er von` .tgz` installiert ist

Post by Anonymous »

Ich entwickle eine React Native + TypeScript Bibliothek und installiere sie lokal in einem anderen Projekt mit einer .tgz -Datei. Die Bibliothek funktioniert , wenn ich den Import manuell schreibe, aber vscode schlägt ihn nicht mit CMD + vor.

Code: Select all

react-native-builder-bob
[/b] Um die Bibliothek zu erstellen.

Code: Select all

yarn add file:./my-library-v1.0.0.tgz
Ich habe auch versucht, es ohne @File zu installieren, nur den Pfad direkt verwendet:

Code: Select all

yarn add ./my-library-v1.0.0.tgz
< /code>
< /li>
[*] Die Build -Ausgabestruktur sieht so aus:
lib/
├── commonjs/
│   ├── index.js
│   ├── components/
│   ├── constants/
│   ├── helpers/
│   ├── types/
├── module/
│   ├── index.js
│   ├── components/
│   ├── constants/
│   ├── helpers/
│   ├── types/
├── typescript/
├── commonjs/src/index.d.ts
├── module/src/index.d.ts
< /code>
< /li>
 mein [b]package.json
[/b] Konfiguration:

Code: Select all

"main": "./lib/commonjs/index.js",
"module": "./lib/module/index.js",
"types": "./lib/typescript/commonjs/src/index.d.ts",
"exports": {
".": {
"import": {
"types": "./lib/typescript/module/src/index.d.ts",
"default": "./lib/module/index.js"
},
"require": {
"types": "./lib/typescript/commonjs/src/index.d.ts",
"default": "./lib/commonjs/index.js"
}
}
}
< /code>
< /li>
< /ul>

 [b] ✅ Was funktioniert < /strong> < /h3>

  Wenn ich den Import manuell schreibe, funktioniert alles fein: < /strong>
   🚨 Was funktioniert nicht < /strong> < /h3>

  VSCODE schlägt den Import mit CMD +. < /code> (Schnellfix) < /strong> nicht vor:
[code]react/jsx-no-undef
< /code>
< /li>
  Es werden keine automatischen Importvorschläge angezeigt. Alles: < /strong>
rm -rf node_modules && yarn install
[*] Starten Sie den Typscript -Server in VSCODE [/b] (

Code: Select all

⇧ Shift + ⌘ Cmd + P
→ "TS -Server neu starten").
[*] Sicherstellen, dass Index.d.ts korrekt lokalisiert ist in lib/Typscript/CommonJS/src/src/index.d.ts . class = "Lang-Bash PrettyPrint-Override">

Code: Select all

yarn add my-library@file:./my-library-v1.0.0.tgz
Importieren direkt aus lib/Commonjs , um zu überprüfen, ob Exporte das Problem waren:

Code: Select all

import MyComponent from "my-library/lib/commonjs";
< /code>
→ [b] Dies funktioniert, aber es ist nicht der richtige Weg, um das Paket zu importieren.  Fehlt mir etwas in package.json 
oder tsconfig.build.json , um das VSCODE das Paket für Quick Fix zu erkennen ((

Code: Select all

cmd + .
)? [/b]

🔹 Könnte dies ein Problem mit Garn hinzufügen: .tgz anstatt von NPM zu installieren? 🚀

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post