Ich verwende visuellen Studio-Code IDE und TypeScript. Wie kann ich den Knoten node_modules während des Builds ignorieren? Oder lassen sich .ts
-Dateien beim Speichern erstellen? Es zeigt viele Fehler, weil es versucht, node_modules tsd zu kompilieren.
Derzeit ist meine Aufgaben.json
{
"version": "0.1.0",
// The command is tsc.
"command": "tsc",
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Under windows use tsc.exe. This ensures we don't need a Shell.
"windows": {
"command": "tsc.exe"
},
"isShellCommand": true,
// args is the HelloWorld program to compile.
"args": [],
// use the standard tsc problem matcher to find compile problems
// in the output.
"problemMatcher": "$tsc"
}
Sie können jetzt exclude
in Ihrer Datei tsconfig.json verwenden:
{
"exclude": [
"node_modules",
],
"compilerOptions": {
...
}
}
https://github.com/Microsoft/TypeScript/wiki/tsconfig.json
Beachten Sie, dass es sich bei compilerOptions um ein Geschwister handelt, nicht um ein Kind davon.
In Version 0.5 können Sie Dateien und Ordner ausblenden
Öffnen Sie Files-> Preferences-> User Settings und fügen Sie etwas hinzu
{
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"jspm_packages" : true,
"node_modules" : true
}
}
Wenn Sie keine Dateiliste angeben, wird Code alle kompilieren.
{
"compilerOptions": {
"target": "ES5"
}
}
Sie können dies ändern, indem Sie nur die Dateien angeben, die Sie kompilieren möchten.
{
"compilerOptions": {
"target": "ES6"
},
"files": [
"app.ts",
"other.ts",
"more.ts"
]
}
Hoffentlich unterstützt Code bald filesGlob
, wodurch Sie Muster verwenden können, um alle Dateien aus bestimmten Ordnern abzurufen. Das bedeutet, dass Sie keine vollständige Liste aller Dateien erstellen müssen.
Hier ist eine Möglichkeit, Sie zu erreichen, verwenden Sie nicht tsconfig.json. Jetzt werden keine Ausschlüsse unterstützt, die Sie benötigen. Was ich möchte, ist einfach, die Datei, in der Sie sich befinden, mit options.json zu kompilieren. Für jetzt müssen Sie STRG + UMSCHALT + B erstellen, es gibt noch keine schöne Möglichkeit, beim Speichern zu bauen.
{
"version": "0.1.0",
// The command is tsc. Assumes that tsc has been installed using npm install -g TypeScript
"command": "tsc",
// The command is a Shell script
"isShellCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "always",
// args is the HelloWorld program to compile.
"args": ["${file}", "--module", "AMD", "--target", "ES5"],
// use the standard tsc problem matcher to find compile problems
// in the output.
"problemMatcher": "$tsc"
}