Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion modules/dev-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ packages under `modules/`.

## Requirements

- Node.js 22 or newer
- Node.js 22.15 or newer
- A root `.ocularrc.js`, `.ocularrc.cjs`, `.ocular.config.js`, or `.ocular.config.cjs` for commands
that load repository configuration
- A root `vitest.config.ts` when using `ocular-test`
Expand Down
8 changes: 4 additions & 4 deletions modules/dev-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
"esbuild": "^0.28.1",
"esbuild-plugin-external-global": "^1.0.1",
"glob": "^7.1.4",
"lerna": "^8.1.0",
"lerna": "^10.0.0",
"minimatch": "^3.0.0",
"semver": "^7.6.0",
"ts-node": "~10.9.0",
"ts-patch": "^3.1.2",
"ts-patch": "^4.0.1",
"tsconfig-paths": "^4.1.1",
"typescript": "^5.2.2"
"typescript": "^6.0.3"
},
"peerDependencies": {
"@vitest/coverage-v8": "^4.0.18",
Expand All @@ -69,6 +69,6 @@
}
},
"engines": {
"node": ">= 22"
"node": "^22.15.0 || ^24.0.0 || ^26.0.0"
}
}
6 changes: 3 additions & 3 deletions modules/ts-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
"dependencies": {
"@luma.gl/constants": "^9.0.0",
"minimatch": "^3.0.0",
"ts-patch": "^3.1.2",
"typescript": "^5.2.2"
"ts-patch": "^4.0.1",
"typescript": "^6.0.3"
},
"engines": {
"node": ">= 18"
"node": ">= 22.15"
}
}
61 changes: 40 additions & 21 deletions modules/ts-plugins/test/test-transformer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Project, ts} from 'ts-morph';
import ts from 'typescript';
import type {PluginConfig} from 'ts-patch';

/**
Expand All @@ -19,37 +19,56 @@ export function transpile({
}): string {
const dts = outputType === 'd.ts';

const project = new Project({
compilerOptions: {
target: ts.ScriptTarget.ESNext,
module: ts.ModuleKind.ESNext,
declaration: dts
}
});
const compilerOptions: ts.CompilerOptions = {
target: ts.ScriptTarget.ESNext,
module: ts.ModuleKind.ESNext,
declaration: dts,
emitDeclarationOnly: dts,
alwaysStrict: false
};
const sourceFile = ts.createSourceFile(
sourceFileName,
source,
ts.ScriptTarget.ESNext,
true,
ts.ScriptKind.TS
);
const host = ts.createCompilerHost(compilerOptions);
const getSourceFile = host.getSourceFile.bind(host);
host.getSourceFile = (requestedFileName, languageVersion, ...args) =>
requestedFileName === sourceFileName
? sourceFile
: getSourceFile(requestedFileName, languageVersion, ...args);
host.fileExists = (requestedFileName) =>
requestedFileName === sourceFileName || ts.sys.fileExists(requestedFileName);
host.readFile = (requestedFileName) =>
requestedFileName === sourceFileName ? source : ts.sys.readFile(requestedFileName);

project.createSourceFile(sourceFileName, source);
const program = ts.createProgram([sourceFileName], compilerOptions, host);

const customTransformers: ts.CustomTransformers = {};
const transform: ts.TransformerFactory<ts.SourceFile> = transformer(
project.getProgram(),
config,
{ts}
);
const transform: ts.TransformerFactory<ts.SourceFile> = transformer(program, config, {ts});
if (config.after) {
customTransformers.after = [transform];
} else if (config.afterDeclarations) {
// @ts-expect-error
customTransformers.afterDeclarations = [transform];
} else {
customTransformers.before = [transform];
}

const result = project.emitToMemory({
customTransformers,
emitOnlyDtsFiles: dts
});

return result.getFiles()[0].text;
let output = '';
program.emit(
undefined,
(outputFileName, text) => {
if (outputFileName.endsWith(dts ? '.d.ts' : '.js')) {
output = text;
}
},
undefined,
dts,
customTransformers
);
return output;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion modules/ts-plugins/test/ts-transform-webgpu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ function transpileWithProgram({
const fileName = '/test.ts';
const compilerOptions: ts.CompilerOptions = {
module: ts.ModuleKind.ESNext,
target: ts.ScriptTarget.ESNext
target: ts.ScriptTarget.ESNext,
alwaysStrict: false
};
const sourceFile = ts.createSourceFile(
fileName,
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"@vitest/coverage-v8": "^4.0.18",
"playwright": "^1.58.0",
"pre-commit": "^1.2.2",
"ts-morph": "^21.0.0",
"vitest": "^4.0.18"
},
"pre-commit": "pre-commit",
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"allowJs": true,
"checkJs": false,
"moduleResolution": "node",
"ignoreDeprecations": "6.0",
"types": ["node"],
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
Expand Down
Loading
Loading