Skip to content

Commit

Permalink
Fix build-ts step (#9439)
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Dec 14, 2023
1 parent 5628da2 commit c6177da
Show file tree
Hide file tree
Showing 10 changed files with 708 additions and 26 deletions.
660 changes: 660 additions & 0 deletions flow-libs/perf_hooks.js.flow

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@khanacademy/flow-to-ts": "^0.5.2",
"@napi-rs/cli": "^2.15.2",
"@parcel/babel-register": "*",
"@types/node": "^15.12.4",
"@types/node": ">= 18",
"cross-env": "^7.0.0",
"eslint": "^7.20.0",
"flow-bin": "0.184.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/core/profiler/build-ts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const fs = require('fs');

let contents = fs.readFileSync(__dirname + '/lib/Tracer.d.ts', 'utf8');

// Some fixups of typescript output
contents = contents.replace(/^\s*#private;\s*$/gm, '');

fs.writeFileSync(__dirname + '/lib/Tracer.d.ts', contents);
4 changes: 4 additions & 0 deletions packages/core/profiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"engines": {
"node": ">= 12.0.0"
},
"scripts": {
"build-ts": "flow-to-ts src/*.js --write && tsc --emitDeclarationOnly --declaration --esModuleInterop --target es2015 --moduleResolution node16 --module node16 src/*.ts && mkdir -p lib && mv src/*.d.ts lib/. && rm src/*.ts && node build-ts.js",
"check-ts": "tsc --noEmit lib/index.d.ts"
},
"dependencies": {
"@parcel/diagnostic": "2.10.3",
"@parcel/events": "2.10.3",
Expand Down
9 changes: 6 additions & 3 deletions packages/core/profiler/src/SamplingProfiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ export default class SamplingProfiler {
]);
}

sendCommand(method: string, params: mixed): Promise<{profile: Profile, ...}> {
sendCommand(
method: string,
params?: mixed,
): Promise<{profile: Profile, ...}> {
invariant(this.session != null);
return new Promise((resolve, reject) => {
this.session.post(method, params, (err, params) => {
this.session.post(method, params, (err, p) => {
if (err == null) {
resolve(params);
resolve((p: {profile: Profile, ...}));
} else {
reject(err);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/profiler/src/Trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class Trace {
});
}

pipe(writable: Writable): stream$Writable {
pipe(writable: Writable): Writable {
return this.tracer.pipe(writable);
}

Expand Down
24 changes: 12 additions & 12 deletions packages/core/profiler/src/Tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import type {
TraceMeasurement as ITraceMeasurement,
TraceMeasurementData,
} from './types';
// @ts-ignore
import {ValueEmitter} from '@parcel/events';

// $FlowFixMe
import {performance as _performance} from 'perf_hooks';
import {performance} from 'perf_hooks';

let tid;
try {
Expand All @@ -21,16 +21,16 @@ try {
tid = 0;
}

const performance: Performance = _performance;
const pid = process.pid;

class TraceMeasurement implements ITraceMeasurement {
#active /* boolean */ = true;
#name /* string */;
#pid /* number */;
#tid /* number */;
#start /* number */;
#data /* any */;
#active: boolean = true;
#name: string;
#pid: number;
#tid: number;
#start: number;
// $FlowFixMe
#data: any;
constructor(tracer: Tracer, name, pid, tid, data) {
this.#name = name;
this.#pid = pid;
Expand All @@ -56,9 +56,9 @@ class TraceMeasurement implements ITraceMeasurement {
}

export default class Tracer {
#traceEmitter /* ValueEmitter<TraceEvent> */ = new ValueEmitter();
#traceEmitter: ValueEmitter<TraceEvent> = new ValueEmitter();

#enabled /* boolean */ = false;
#enabled: boolean = false;

onTrace(cb: (event: TraceEvent) => mixed): IDisposable {
return this.#traceEmitter.addListener(cb);
Expand All @@ -75,7 +75,7 @@ export default class Tracer {

createMeasurement(
name: string,
category?: string = 'Core',
category: string = 'Core',
argumentName?: string,
otherArgs?: {[key: string]: mixed},
): ITraceMeasurement | null {
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/parcel-lsp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"vscode-languageserver-textdocument": "^1.0.0"
},
"devDependencies": {
"@types/node": "^15.12.4",
"@types/node": ">= 18",
"@typescript-eslint/eslint-plugin": "^4.14.1",
"@typescript-eslint/parser": "^4.14.1",
"eslint": "^7.19.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/parcelforvscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"@parcel/lsp-protocol": "2.10.3",
"@types/glob": "^7.1.3",
"@types/mocha": "^8.0.4",
"@types/node": "^15.12.4",
"@types/node": ">= 18",
"@types/vscode": "^1.67.0",
"@typescript-eslint/eslint-plugin": "^4.14.1",
"@typescript-eslint/parser": "^4.14.1",
Expand Down
21 changes: 14 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2636,10 +2636,12 @@
resolved "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.2.tgz#91daa226eb8c2ff261e6a8cbf8c7304641e095e0"
integrity sha512-Lwh0lzzqT5Pqh6z61P3c3P5nm6fzQK/MMHl9UKeneAeInVflBSz1O2EkX6gM6xfJd7FBXBY5purtLx7fUiZ7Hw==

"@types/node@*", "@types/node@>= 8", "@types/node@^15.12.4":
version "15.12.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-15.12.4.tgz#e1cf817d70a1e118e81922c4ff6683ce9d422e26"
integrity sha512-zrNj1+yqYF4WskCMOHwN+w9iuD12+dGm0rQ35HLl9/Ouuq52cEtd0CH9qMgrdNmi5ejC1/V7vKEXYubB+65DkA==
"@types/node@*", "@types/node@>= 18", "@types/node@>= 8":
version "20.10.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.4.tgz#b246fd84d55d5b1b71bf51f964bd514409347198"
integrity sha512-D08YG6rr8X90YB56tSIuBaddy/UXAA9RKJoFvrsnogAum/0pmjkgi4+2nx96A330FmioegBWmEYQ+syqCFaveg==
dependencies:
undici-types "~5.26.4"

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
Expand Down Expand Up @@ -13414,9 +13416,9 @@ typedarray@^0.0.6:
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript@>=3.0.0:
version "5.3.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.2.tgz#00d1c7c1c46928c5845c1ee8d0cc2791031d4c43"
integrity sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==
version "5.3.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.3.tgz#b3ce6ba258e72e6305ba66f5c9b452aaee3ffe37"
integrity sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==

uc.micro@^1.0.1, uc.micro@^1.0.5:
version "1.0.6"
Expand Down Expand Up @@ -13481,6 +13483,11 @@ undertaker@^1.2.1:
object.reduce "^1.0.0"
undertaker-registry "^1.0.0"

undici-types@~5.26.4:
version "5.26.5"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==

unherit@^1.0.4:
version "1.1.2"
resolved "https://registry.yarnpkg.com/unherit/-/unherit-1.1.2.tgz#14f1f397253ee4ec95cec167762e77df83678449"
Expand Down

0 comments on commit c6177da

Please sign in to comment.