Skip to content
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

feat: build target up to ES2022 #439

Merged
merged 9 commits into from
Mar 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "eslint-config-egg/typescript",
"extends": [
"eslint-config-egg/typescript",
"eslint-config-egg/lib/rules/enforce-node-prefix"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

],
"parserOptions": {
// recommend to use another config file like tsconfig.eslint.json and extends tsconfig.json in it.
// because you may be need to lint test/**/*.test.ts but no need to emit to js.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
uses: artusjs/github-actions/.github/workflows/node-test.yml@v1
with:
os: 'ubuntu-latest, macos-latest, windows-latest'
version: '14, 16, 18, 19'
version: '14.17.0, 14, 16, 18, 19'
4 changes: 2 additions & 2 deletions src/HttpAgent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dns from 'dns';
import { LookupFunction, isIP } from 'net';
import dns from 'node:dns';
import { LookupFunction, isIP } from 'node:net';
import {
Agent,
} from 'undici';
Expand Down
26 changes: 13 additions & 13 deletions src/HttpClient.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { EventEmitter } from 'events';
import { LookupFunction } from 'net';
import { STATUS_CODES } from 'http';
import { debuglog } from 'util';
import { EventEmitter } from 'node:events';
import { LookupFunction } from 'node:net';
import { STATUS_CODES } from 'node:http';
import type { IncomingHttpHeaders } from 'node:http';
import { debuglog } from 'node:util';
import {
createGunzip,
createBrotliDecompress,
gunzipSync,
brotliDecompressSync,
} from 'zlib';
import { Blob } from 'buffer';
import { Readable, pipeline } from 'stream';
import stream from 'stream';
import { basename } from 'path';
import { createReadStream } from 'fs';
import { format as urlFormat } from 'url';
import { performance } from 'perf_hooks';
} from 'node:zlib';
import { Blob } from 'node:buffer';
import { Readable, pipeline } from 'node:stream';
import stream from 'node:stream';
import { basename } from 'node:path';
import { createReadStream } from 'node:fs';
import { format as urlFormat } from 'node:url';
import { performance } from 'node:perf_hooks';
import {
FormData as FormDataNative,
request as undiciRequest,
Expand All @@ -33,7 +34,6 @@ import { RawResponseWithMeta, HttpClientResponse, SocketInfo } from './Response'
import { parseJSON, sleep, digestAuthHeader, globalId, performanceTime, isReadable } from './utils';
import symbols from './symbols';
import { initDiagnosticsChannel } from './diagnosticsChannel';
import type { IncomingHttpHeaders } from 'http';

type Exists<T> = T extends undefined ? never : T;
type UndiciRequestOption = Exists<Parameters<typeof undiciRequest>[1]>;
Expand Down
4 changes: 2 additions & 2 deletions src/Request.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Readable, Writable } from 'stream';
import type { IncomingHttpHeaders } from 'http';
import { Readable, Writable } from 'node:stream';
import type { IncomingHttpHeaders } from 'node:http';
import type Dispatcher from 'undici/types/dispatcher';
import type {
HttpClientResponse,
Expand Down
4 changes: 2 additions & 2 deletions src/Response.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Readable } from 'stream';
import { IncomingHttpHeaders } from 'http';
import { Readable } from 'node:stream';
import { IncomingHttpHeaders } from 'node:http';

export type SocketInfo = {
id: number;
Expand Down
6 changes: 3 additions & 3 deletions src/diagnosticsChannel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import diagnosticsChannel from 'diagnostics_channel';
import { performance } from 'perf_hooks';
import { debuglog } from 'util';
import diagnosticsChannel from 'node:diagnostics_channel';
import { performance } from 'node:perf_hooks';
import { debuglog } from 'node:util';
import { DiagnosticsChannel } from 'undici';
import symbols from './symbols';
import { globalId, performanceTime } from './utils';
Expand Down
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { randomBytes, createHash } from 'crypto';
import { Readable } from 'stream';
import { performance } from 'perf_hooks';
import { randomBytes, createHash } from 'node:crypto';
import { Readable } from 'node:stream';
import { performance } from 'node:perf_hooks';
import { FixJSONCtlChars } from './Request';

const JSONCtlCharsMap = {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"suppressImplicitAnyIndexErrors": true,
"suppressExcessPropertyErrors": true,
"forceConsistentCasingInFileNames": true,
"target": "ES2020",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

兼容性看起来没问题。

"target": "ES2022",
"sourceMap": true,
"esModuleInterop": true,
"stripInternal": true,
Expand Down