@mendable/firecrawl-js 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +134 -0
- package/build/index.js +153 -0
- package/package.json +28 -0
- package/src/index.ts +137 -0
- package/tsconfig.json +109 -0
package/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Firecrawl JavaScript SDK
|
|
2
|
+
|
|
3
|
+
The Firecrawl JavaScript SDK is a library that allows you to easily scrape and crawl websites, and output the data in a format ready for use with language models (LLMs). It provides a simple and intuitive interface for interacting with the Firecrawl API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
To install the Firecrawl JavaScript SDK, you can use npm:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @mendableai/firecrawl-js
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
1. Get an API key from [firecrawl.dev](https://firecrawl.dev)
|
|
16
|
+
2. Set the API key as an environment variable named `FIRECRAWL_API_KEY` or pass it as a parameter to the `FirecrawlApp` class.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
Here's an example of how to use the SDK with error handling:
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import { FirecrawlApp } from '@mendableai/firecrawl-js';
|
|
23
|
+
|
|
24
|
+
async function main() {
|
|
25
|
+
try {
|
|
26
|
+
// Initialize the FirecrawlApp with your API key
|
|
27
|
+
const app = new FirecrawlApp({apiKey: "YOUR_API_KEY"});
|
|
28
|
+
|
|
29
|
+
// Scrape a single URL
|
|
30
|
+
const url = 'https://mendable.ai';
|
|
31
|
+
const scrapedData = await app.scrapeUrl(url);
|
|
32
|
+
console.log(scrapedData);
|
|
33
|
+
|
|
34
|
+
// Crawl a website
|
|
35
|
+
const crawlUrl = 'https://mendable.ai';
|
|
36
|
+
const crawlParams = {
|
|
37
|
+
crawlerOptions: {
|
|
38
|
+
excludes: ['blog/'],
|
|
39
|
+
includes: [], // leave empty for all pages
|
|
40
|
+
limit: 1000,
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const crawlResult = await app.crawlUrl(crawlUrl, crawlParams);
|
|
45
|
+
console.log(crawlResult);
|
|
46
|
+
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error('An error occurred:', error.message);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
main();
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Scraping a URL
|
|
56
|
+
|
|
57
|
+
To scrape a single URL with error handling, use the `scrapeUrl` method. It takes the URL as a parameter and returns the scraped data as a dictionary.
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
async function scrapeExample() {
|
|
61
|
+
try {
|
|
62
|
+
const url = 'https://example.com';
|
|
63
|
+
const scrapedData = await app.scrapeUrl(url);
|
|
64
|
+
console.log(scrapedData);
|
|
65
|
+
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error('Error occurred while scraping:', error.message);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
scrapeExample();
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### Crawling a Website
|
|
76
|
+
|
|
77
|
+
To crawl a website with error handling, use the `crawlUrl` method. It takes the starting URL and optional parameters as arguments. The `params` argument allows you to specify additional options for the crawl job, such as the maximum number of pages to crawl, allowed domains, and the output format.
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
async function crawlExample() {
|
|
81
|
+
try {
|
|
82
|
+
const crawlUrl = 'https://example.com';
|
|
83
|
+
const crawlParams = {
|
|
84
|
+
crawlerOptions: {
|
|
85
|
+
excludes: ['blog/'],
|
|
86
|
+
includes: [], // leave empty for all pages
|
|
87
|
+
limit: 1000,
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const waitUntilDone = true;
|
|
91
|
+
const timeout = 5;
|
|
92
|
+
const crawlResult = await app.crawlUrl(crawlUrl, crawlParams, waitUntilDone, timeout);
|
|
93
|
+
|
|
94
|
+
console.log(crawlResult);
|
|
95
|
+
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error('Error occurred while crawling:', error.message);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
crawlExample();
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
### Checking Crawl Status
|
|
106
|
+
|
|
107
|
+
To check the status of a crawl job with error handling, use the `checkCrawlStatus` method. It takes the job ID as a parameter and returns the current status of the crawl job.
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
async function checkStatusExample(jobId) {
|
|
111
|
+
try {
|
|
112
|
+
const status = await app.checkCrawlStatus(jobId);
|
|
113
|
+
console.log(status);
|
|
114
|
+
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.error('Error occurred while checking crawl status:', error.message);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Example usage, assuming you have a jobId
|
|
120
|
+
checkStatusExample('your_job_id_here');
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
## Error Handling
|
|
125
|
+
|
|
126
|
+
The SDK handles errors returned by the Firecrawl API and raises appropriate exceptions. If an error occurs during a request, an exception will be raised with a descriptive error message. The examples above demonstrate how to handle these errors using `try/catch` blocks.
|
|
127
|
+
|
|
128
|
+
## Contributing
|
|
129
|
+
|
|
130
|
+
Contributions to the Firecrawl JavaScript SDK are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
The Firecrawl JavaScript SDK is open-source and released under the [MIT License](https://opensource.org/licenses/MIT).
|
package/build/index.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FirecrawlApp = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
18
|
+
dotenv_1.default.config();
|
|
19
|
+
class FirecrawlApp {
|
|
20
|
+
constructor({ apiKey = null }) {
|
|
21
|
+
this.apiKey = apiKey || process.env.FIRECRAWL_API_KEY || '';
|
|
22
|
+
if (!this.apiKey) {
|
|
23
|
+
throw new Error('No API key provided');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
scrapeUrl(url_1) {
|
|
27
|
+
return __awaiter(this, arguments, void 0, function* (url, params = null) {
|
|
28
|
+
const headers = {
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
31
|
+
};
|
|
32
|
+
let jsonData = { url };
|
|
33
|
+
if (params) {
|
|
34
|
+
jsonData = Object.assign(Object.assign({}, jsonData), params);
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const response = yield axios_1.default.post('https://api.firecrawl.dev/v0/scrape', jsonData, { headers });
|
|
38
|
+
if (response.status === 200) {
|
|
39
|
+
const responseData = response.data;
|
|
40
|
+
if (responseData.success) {
|
|
41
|
+
return responseData.data;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
throw new Error(`Failed to scrape URL. Error: ${responseData.error}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.handleError(response, 'scrape URL');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw new Error(error.message);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
crawlUrl(url_1) {
|
|
57
|
+
return __awaiter(this, arguments, void 0, function* (url, params = null, waitUntilDone = true, timeout = 2) {
|
|
58
|
+
const headers = this.prepareHeaders();
|
|
59
|
+
let jsonData = { url };
|
|
60
|
+
if (params) {
|
|
61
|
+
jsonData = Object.assign(Object.assign({}, jsonData), params);
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
const response = yield this.postRequest('https://api.firecrawl.dev/v0/crawl', jsonData, headers);
|
|
65
|
+
if (response.status === 200) {
|
|
66
|
+
const jobId = response.data.jobId;
|
|
67
|
+
if (waitUntilDone) {
|
|
68
|
+
return this.monitorJobStatus(jobId, headers, timeout);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return { jobId };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
this.handleError(response, 'start crawl job');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
console.log(error);
|
|
80
|
+
throw new Error(error.message);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
checkCrawlStatus(jobId) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const headers = this.prepareHeaders();
|
|
87
|
+
try {
|
|
88
|
+
const response = yield this.getRequest(`https://api.firecrawl.dev/v0/crawl/status/${jobId}`, headers);
|
|
89
|
+
if (response.status === 200) {
|
|
90
|
+
return response.data;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this.handleError(response, 'check crawl status');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
throw new Error(error.message);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
prepareHeaders() {
|
|
102
|
+
return {
|
|
103
|
+
'Content-Type': 'application/json',
|
|
104
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
postRequest(url, data, headers) {
|
|
108
|
+
return axios_1.default.post(url, data, { headers });
|
|
109
|
+
}
|
|
110
|
+
getRequest(url, headers) {
|
|
111
|
+
return axios_1.default.get(url, { headers });
|
|
112
|
+
}
|
|
113
|
+
monitorJobStatus(jobId, headers, timeout) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
while (true) {
|
|
116
|
+
const statusResponse = yield this.getRequest(`https://api.firecrawl.dev/v0/crawl/status/${jobId}`, headers);
|
|
117
|
+
if (statusResponse.status === 200) {
|
|
118
|
+
const statusData = statusResponse.data;
|
|
119
|
+
if (statusData.status === 'completed') {
|
|
120
|
+
if ('data' in statusData) {
|
|
121
|
+
return statusData.data;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
throw new Error('Crawl job completed but no data was returned');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
else if (['active', 'paused', 'pending', 'queued'].includes(statusData.status)) {
|
|
128
|
+
if (timeout < 2) {
|
|
129
|
+
timeout = 2;
|
|
130
|
+
}
|
|
131
|
+
yield new Promise(resolve => setTimeout(resolve, timeout * 1000)); // Wait for the specified timeout before checking again
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
throw new Error(`Crawl job failed or was stopped. Status: ${statusData.status}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
this.handleError(statusResponse, 'check crawl status');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
handleError(response, action) {
|
|
144
|
+
if ([402, 409, 500].includes(response.status)) {
|
|
145
|
+
const errorMessage = response.data.error || 'Unknown error occurred';
|
|
146
|
+
throw new Error(`Failed to ${action}. Status code: ${response.status}. Error: ${errorMessage}`);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
throw new Error(`Unexpected error occurred while trying to ${action}. Status code: ${response.status}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.FirecrawlApp = FirecrawlApp;
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mendable/firecrawl-js",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "JavaScript SDK for Firecrawl API",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/mendableai/firecrawl-js.git"
|
|
13
|
+
},
|
|
14
|
+
"author": "Mendable.ai",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"axios": "^1.6.8",
|
|
18
|
+
"dotenv": "^16.4.5"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/mendableai/firecrawl-js/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/mendableai/firecrawl-js#readme",
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^20.12.7",
|
|
26
|
+
"typescript": "^5.4.5"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import axios, { AxiosResponse, AxiosRequestHeaders } from 'axios';
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
|
|
5
|
+
interface FirecrawlAppConfig {
|
|
6
|
+
apiKey?: string | null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface Params {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
class FirecrawlApp {
|
|
14
|
+
private apiKey: string;
|
|
15
|
+
|
|
16
|
+
constructor({ apiKey = null }: FirecrawlAppConfig) {
|
|
17
|
+
this.apiKey = apiKey || process.env.FIRECRAWL_API_KEY || '';
|
|
18
|
+
if (!this.apiKey) {
|
|
19
|
+
throw new Error('No API key provided');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async scrapeUrl(url: string, params: Params | null = null): Promise<any> {
|
|
24
|
+
const headers: AxiosRequestHeaders = {
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
27
|
+
} as AxiosRequestHeaders;
|
|
28
|
+
let jsonData: Params = { url };
|
|
29
|
+
if (params) {
|
|
30
|
+
jsonData = { ...jsonData, ...params };
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const response: AxiosResponse = await axios.post('https://api.firecrawl.dev/v0/scrape', jsonData, { headers });
|
|
34
|
+
if (response.status === 200) {
|
|
35
|
+
const responseData = response.data;
|
|
36
|
+
if (responseData.success) {
|
|
37
|
+
return responseData.data;
|
|
38
|
+
} else {
|
|
39
|
+
throw new Error(`Failed to scrape URL. Error: ${responseData.error}`);
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
this.handleError(response, 'scrape URL');
|
|
43
|
+
}
|
|
44
|
+
} catch (error: any) {
|
|
45
|
+
throw new Error(error.message);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async crawlUrl(url: string, params: Params | null = null, waitUntilDone: boolean = true, timeout: number = 2): Promise<any> {
|
|
50
|
+
const headers = this.prepareHeaders();
|
|
51
|
+
let jsonData: Params = { url };
|
|
52
|
+
if (params) {
|
|
53
|
+
jsonData = { ...jsonData, ...params };
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const response: AxiosResponse = await this.postRequest('https://api.firecrawl.dev/v0/crawl', jsonData, headers);
|
|
57
|
+
if (response.status === 200) {
|
|
58
|
+
const jobId: string = response.data.jobId;
|
|
59
|
+
if (waitUntilDone) {
|
|
60
|
+
return this.monitorJobStatus(jobId, headers, timeout);
|
|
61
|
+
} else {
|
|
62
|
+
return { jobId };
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
this.handleError(response, 'start crawl job');
|
|
66
|
+
}
|
|
67
|
+
} catch (error: any) {
|
|
68
|
+
console.log(error)
|
|
69
|
+
throw new Error(error.message);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async checkCrawlStatus(jobId: string): Promise<any> {
|
|
74
|
+
const headers: AxiosRequestHeaders = this.prepareHeaders();
|
|
75
|
+
try {
|
|
76
|
+
const response: AxiosResponse = await this.getRequest(`https://api.firecrawl.dev/v0/crawl/status/${jobId}`, headers);
|
|
77
|
+
if (response.status === 200) {
|
|
78
|
+
return response.data;
|
|
79
|
+
} else {
|
|
80
|
+
this.handleError(response, 'check crawl status');
|
|
81
|
+
}
|
|
82
|
+
} catch (error: any) {
|
|
83
|
+
throw new Error(error.message);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
prepareHeaders(): AxiosRequestHeaders {
|
|
88
|
+
return {
|
|
89
|
+
'Content-Type': 'application/json',
|
|
90
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
91
|
+
} as AxiosRequestHeaders;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
postRequest(url: string, data: Params, headers: AxiosRequestHeaders): Promise<AxiosResponse> {
|
|
95
|
+
return axios.post(url, data, { headers });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
getRequest(url: string, headers: AxiosRequestHeaders): Promise<AxiosResponse> {
|
|
99
|
+
return axios.get(url, { headers });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async monitorJobStatus(jobId: string, headers: AxiosRequestHeaders, timeout: number): Promise<any> {
|
|
103
|
+
while (true) {
|
|
104
|
+
const statusResponse: AxiosResponse = await this.getRequest(`https://api.firecrawl.dev/v0/crawl/status/${jobId}`, headers);
|
|
105
|
+
if (statusResponse.status === 200) {
|
|
106
|
+
const statusData = statusResponse.data;
|
|
107
|
+
if (statusData.status === 'completed') {
|
|
108
|
+
if ('data' in statusData) {
|
|
109
|
+
return statusData.data;
|
|
110
|
+
} else {
|
|
111
|
+
throw new Error('Crawl job completed but no data was returned');
|
|
112
|
+
}
|
|
113
|
+
} else if (['active', 'paused', 'pending', 'queued'].includes(statusData.status)) {
|
|
114
|
+
if (timeout < 2) {
|
|
115
|
+
timeout = 2;
|
|
116
|
+
}
|
|
117
|
+
await new Promise(resolve => setTimeout(resolve, timeout * 1000)); // Wait for the specified timeout before checking again
|
|
118
|
+
} else {
|
|
119
|
+
throw new Error(`Crawl job failed or was stopped. Status: ${statusData.status}`);
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
this.handleError(statusResponse, 'check crawl status');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
handleError(response: AxiosResponse, action: string): void {
|
|
128
|
+
if ([402, 409, 500].includes(response.status)) {
|
|
129
|
+
const errorMessage: string = response.data.error || 'Unknown error occurred';
|
|
130
|
+
throw new Error(`Failed to ${action}. Status code: ${response.status}. Error: ${errorMessage}`);
|
|
131
|
+
} else {
|
|
132
|
+
throw new Error(`Unexpected error occurred while trying to ${action}. Status code: ${response.status}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export { FirecrawlApp }
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Projects */
|
|
6
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
+
|
|
13
|
+
/* Language and Environment */
|
|
14
|
+
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
|
+
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
+
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
18
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
19
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
20
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
21
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
22
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
23
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
24
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
|
+
|
|
27
|
+
/* Modules */
|
|
28
|
+
"module": "commonjs", /* Specify what module code is generated. */
|
|
29
|
+
"rootDir": "./src", /* Specify the root folder within your source files. */
|
|
30
|
+
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
31
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
32
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
35
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
36
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
38
|
+
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
39
|
+
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
40
|
+
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
41
|
+
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
42
|
+
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
43
|
+
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
44
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
45
|
+
|
|
46
|
+
/* JavaScript Support */
|
|
47
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
48
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
49
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
50
|
+
|
|
51
|
+
/* Emit */
|
|
52
|
+
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
53
|
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
54
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
55
|
+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
56
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
57
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
58
|
+
"outDir": "./build", /* Specify an output folder for all emitted files. */
|
|
59
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
60
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
62
|
+
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
63
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
64
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
65
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
66
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
67
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
68
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
69
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
70
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
71
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
72
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
73
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
74
|
+
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
75
|
+
|
|
76
|
+
/* Interop Constraints */
|
|
77
|
+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
78
|
+
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
79
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
80
|
+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
81
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
82
|
+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
83
|
+
|
|
84
|
+
/* Type Checking */
|
|
85
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
86
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
87
|
+
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
88
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
89
|
+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
90
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
91
|
+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
92
|
+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
93
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
94
|
+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
95
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
96
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
97
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
98
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
99
|
+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
100
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
101
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
102
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
103
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
104
|
+
|
|
105
|
+
/* Completeness */
|
|
106
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
107
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
108
|
+
}
|
|
109
|
+
}
|