-
Notifications
You must be signed in to change notification settings - Fork 15
New Workload: TypeScript standalone #117
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
Open
camillobruni
wants to merge
29
commits into
WebKit:main
Choose a base branch
from
camillobruni:2025-08-07_typescript
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
7b51b30
adding files
camillobruni 0dc1c0a
adding more
camillobruni c1cc62d
wip
camillobruni a8ef519
fix
camillobruni 96b1bd0
add
camillobruni 899976a
add sources
camillobruni 00b3823
adding files
camillobruni 62a0a93
wup
camillobruni b570cd0
wip
camillobruni 46b5497
use importer class
camillobruni 83c5ce8
wip
camillobruni 5d4640f
adding more files
camillobruni c5d1b78
adding more files
camillobruni 6d924f8
fixes
camillobruni 9a3c26c
adding more
camillobruni 52bb2d9
adding gen files
camillobruni 843977d
adding project files
camillobruni 91245d4
fix
camillobruni 78964f2
addin gdist fiels
camillobruni 43bb5d0
adding benchmark
camillobruni ad6a881
lowercase fs names
camillobruni 0038ac1
better import script handling tsconfig extends
camillobruni 0ab3fb9
update
camillobruni e814985
adding files
camillobruni f3d0085
moving files
camillobruni 5046d81
Merge branch 'main' into 2025-08-07_typescript
camillobruni 73b4c37
updateing
camillobruni 7138ae7
Merge branch 'main' into 2025-08-07_typescript
camillobruni 8e34764
fix workload
camillobruni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
build/*.git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
|
||
console.log = () => {}; | ||
|
||
class Benchmark { | ||
runIteration() { | ||
TypeScriptCompileTest.compileTest(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const { spawnSync } = require("child_process"); | ||
const glob = require("glob"); | ||
const assert = require('assert/strict'); | ||
|
||
|
||
class Importer { | ||
constructor({ projectName, size, repoUrl, srcFolder, extraFiles, extraDirs }) { | ||
this.projectName = projectName; | ||
assert(projectName.endsWith(`-${size}`), "missing size annotation in projectName"); | ||
this.repoUrl = repoUrl; | ||
this.baseDir = path.resolve(__dirname); | ||
let repoName = path.basename(this.repoUrl); | ||
if (!repoName.endsWith(".git")) { | ||
repoName = `${repoName}.git`; | ||
} | ||
this.repoDir = path.resolve(__dirname, repoName); | ||
this.srcFolder = srcFolder; | ||
this.outputDir = path.resolve(__dirname, `../src/gen/${this.projectName}`); | ||
fs.mkdirSync(this.outputDir, { recursive: true }); | ||
this.srcFileData = Object.create(null); | ||
this.extraFiles = extraFiles; | ||
this.extraDirs = extraDirs; | ||
} | ||
run() { | ||
this.cloneRepo(); | ||
this.readSrcFileData(); | ||
this.addExtraFilesFromDirs(); | ||
this.addSpecificFiles(); | ||
this.writeTsConfig(); | ||
this.writeSrcFileData(); | ||
} | ||
|
||
cloneRepo() { | ||
if (fs.existsSync(this.repoDir)) return; | ||
console.info(`Cloning src data repository to ${this.repoDir}`); | ||
spawnSync("git", ["clone", this.repoUrl, this.repoDir]); | ||
} | ||
|
||
readSrcFileData() { | ||
const patterns = [`${this.srcFolder}/**/*.ts`, `${this.srcFolder}/**/*.d.ts`, `${this.srcFolder}/*.d.ts`]; | ||
patterns.forEach(pattern => { | ||
const files = glob.sync(pattern, { cwd: this.repoDir, nodir: true }); | ||
files.forEach(file => { | ||
const filePath = path.join(this.repoDir, file); | ||
const relativePath = path.relative(this.repoDir, filePath).toLowerCase(); | ||
const fileContents = fs.readFileSync(filePath, "utf8"); | ||
this.addFileContents(relativePath, fileContents); | ||
}); | ||
}); | ||
} | ||
|
||
addExtraFilesFromDirs() { | ||
this.extraDirs.forEach(({ dir, nameOnly = false }) => { | ||
const absoluteSourceDir = path.resolve(__dirname, dir); | ||
let allFiles = glob.sync("**/*.d.ts", { cwd: absoluteSourceDir, nodir: true }); | ||
allFiles = allFiles.concat(glob.sync("**/*.d.mts", { cwd: absoluteSourceDir, nodir: true })); | ||
|
||
allFiles.forEach(file => { | ||
const filePath = path.join(absoluteSourceDir, file); | ||
let relativePath = path.join(dir, path.relative(absoluteSourceDir, filePath)); | ||
if (nameOnly) { | ||
relativePath = path.basename(relativePath); | ||
} | ||
this.addFileContents(relativePath, fs.readFileSync(filePath, "utf8")) | ||
}); | ||
}); | ||
} | ||
|
||
addFileContents(relativePath, fileContents) { | ||
if (relativePath in this.srcFileData) { | ||
if (this.srcFileData[relativePath] !== fileContents) { | ||
throw new Error(`${relativePath} was previously added with different contents.`); | ||
} | ||
} else { | ||
this.srcFileData[relativePath] = fileContents; | ||
} | ||
} | ||
|
||
addSpecificFiles() { | ||
this.extraFiles.forEach(file => { | ||
const filePath = path.join(this.baseDir, file); | ||
this.srcFileData[file] = fs.readFileSync(filePath, "utf8"); | ||
}); | ||
} | ||
|
||
writeSrcFileData() { | ||
const filesDataPath = path.join(this.outputDir, "src_file_data.cjs"); | ||
fs.writeFileSync( | ||
filesDataPath, `// Generated src file data from existing node modules and | ||
// ${this.repoUrl} | ||
// See LICENSEs in the sources. | ||
module.exports = ${JSON.stringify(this.srcFileData, null, 2)}; | ||
` | ||
); | ||
const stats = fs.statSync(filesDataPath); | ||
const fileSizeInKiB = (stats.size / 1024) | 0; | ||
console.info(`Exported ${this.projectName}`); | ||
console.info(` File Contents: ${path.relative(process.cwd(), filesDataPath)}`); | ||
console.info(` Total Size: ${fileSizeInKiB} KiB`); | ||
} | ||
|
||
writeTsConfig() { | ||
const tsconfigInputPath = path.join(this.repoDir, "tsconfig.json"); | ||
const mergedTsconfig = this.loadAndMergeTsconfig(tsconfigInputPath); | ||
const tsconfigOutputPath = path.join(this.outputDir, "src_tsconfig.cjs"); | ||
fs.writeFileSync( | ||
tsconfigOutputPath, `// Exported from ${this.repoUrl} | ||
// See LICENSEs in the sources. | ||
module.exports = ${JSON.stringify(mergedTsconfig, null, 2)}; | ||
` | ||
); | ||
} | ||
|
||
loadAndMergeTsconfig(configPath) { | ||
const tsconfigContent = fs.readFileSync(configPath, "utf8"); | ||
const tsconfigContentWithoutComments = tsconfigContent.replace(/(?:^|\s)\/\/.*$|\/\*[\s\S]*?\*\//gm, ""); | ||
const tsconfig = JSON.parse(tsconfigContentWithoutComments); | ||
let baseConfigPath = tsconfig.extends; | ||
if (!baseConfigPath) return tsconfig; | ||
if (!baseConfigPath.startsWith('./') && !baseConfigPath.startsWith('../')) return tsconfig; | ||
|
||
baseConfigPath = path.resolve(path.dirname(configPath), baseConfigPath); | ||
const baseConfig = this.loadAndMergeTsconfig(baseConfigPath); | ||
|
||
const mergedConfig = { ...baseConfig, ...tsconfig }; | ||
if (baseConfig.compilerOptions && tsconfig.compilerOptions) { | ||
mergedConfig.compilerOptions = { ...baseConfig.compilerOptions, ...tsconfig.compilerOptions }; | ||
} | ||
delete mergedConfig.extends; | ||
return mergedConfig; | ||
} | ||
} | ||
|
||
new Importer({ | ||
projectName: "jestjs-large", | ||
size: "large", | ||
repoUrl: "https://github.com/jestjs/jest.git", | ||
srcFolder: "packages", | ||
extraFiles: [ | ||
"../../node_modules/@babel/types/lib/index.d.ts", | ||
"../../node_modules/callsites/index.d.ts", | ||
"../../node_modules/camelcase/index.d.ts", | ||
"../../node_modules/chalk/types/index.d.ts", | ||
"../../node_modules/execa/index.d.ts", | ||
"../../node_modules/fast-json-stable-stringify/index.d.ts", | ||
"../../node_modules/get-stream/index.d.ts", | ||
"../../node_modules/strip-json-comments/index.d.ts", | ||
"../../node_modules/tempy/index.d.ts", | ||
"../../node_modules/tempy/node_modules/type-fest/index.d.ts", | ||
"../node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts", | ||
"../node_modules/@types/eslint/index.d.ts", | ||
"../node_modules/ansi-regex/index.d.ts", | ||
"../node_modules/ansi-styles/index.d.ts", | ||
"../node_modules/glob/dist/esm/index.d.ts", | ||
"../node_modules/jest-worker/build/index.d.ts", | ||
"../node_modules/lru-cache/dist/esm/index.d.ts", | ||
"../node_modules/minipass/dist/esm/index.d.ts", | ||
"../node_modules/p-limit/index.d.ts", | ||
"../node_modules/path-scurry/dist/esm/index.d.ts", | ||
"../node_modules/typescript/lib/lib.dom.d.ts", | ||
], | ||
extraDirs: [ | ||
{ dir: "../node_modules/@types/" }, | ||
{ dir: "../node_modules/typescript/lib/", nameOnly: true }, | ||
{ dir: "../node_modules/jest-worker/build/" }, | ||
{ dir: "../node_modules/@jridgewell/trace-mapping/types/" }, | ||
{ dir: "../node_modules/minimatch/dist/esm/" }, | ||
{ dir: "../node_modules/glob/dist/esm/" }, | ||
{ dir: "../../node_modules/tempy/node_modules/type-fest/source/" } | ||
], | ||
}).run(); | ||
|
||
new Importer({ | ||
projectName: "zod-medium", | ||
size: "medium", | ||
repoUrl: "https://github.com/colinhacks/zod.git", | ||
srcFolder: "packages", | ||
extraFiles: [], | ||
extraDirs: [ | ||
{ dir: "../node_modules/typescript/lib/", nameOnly: true }, | ||
], | ||
}).run(); | ||
|
||
// Import tiny-sized project sources: | ||
new Importer({ | ||
projectName: "immer-tiny", | ||
size: "tiny", | ||
repoUrl: "https://github.com/immerjs/immer.git", | ||
srcFolder: "src", | ||
extraFiles: [], | ||
extraDirs: [ | ||
{ dir: "../node_modules/typescript/lib/", nameOnly: true }, | ||
], | ||
}).run(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
console.log("Creating importable source string") | ||
const bundlePath = path.join(__dirname, "..", "dist", "typescript-compile-test.js"); | ||
const srcOutPath = path.join(__dirname, "..", "dist", "typescript-compile-test.src.js"); | ||
|
||
const bundleContent = fs.readFileSync(bundlePath, "utf8"); | ||
const srcContent = `REACT_RENDER_TEST_SRC = ${JSON.stringify(bundleContent)};`; | ||
fs.writeFileSync(srcOutPath, srcContent); | ||
console.log(`Successfully created ${srcOutPath}`); |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want a copyright here?