Skip to content

Commit

Permalink
Upgrade dev dependencies to latest (alangpierce#702)
Browse files Browse the repository at this point in the history
Some of them were a bit out of date, and this also helps address some dependabot
alerts.
  • Loading branch information
alangpierce authored and 1Lighty committed Aug 14, 2022
1 parent 9665166 commit 0d3c2b6
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 75 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ module.exports = {
// This rule has TypeScript false positives, so just disable for now.
"import/named": "off",
"import/no-cycle": "off",
// Currently we need to do relative imports for cross-project references.
// This could be resolved by switching to lerna or yarn workspaces.
"import/no-relative-packages": "off",
"import/order": [
"error",
{
Expand Down Expand Up @@ -82,6 +85,7 @@ module.exports = {
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-shadow": "error",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ jobs:
strategy:
matrix:
include:
- node_version: '10'
- node_version: '12'
# We support down to node 8, but mocha requires node 14.
- node_version: '14'
steps:
- uses: actions/checkout@v2
Expand Down
121 changes: 68 additions & 53 deletions benchmark/benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,34 +214,40 @@ async function benchmarkFiles(benchmarkOptions: BenchmarkOptions): Promise<void>
console.log(`Testing against ${numLines(benchmarkOptions)} LOC`);
}
/* eslint-disable @typescript-eslint/require-await */
await runBenchmark("Sucrase", benchmarkOptions, async (code: string, path: string) => {
return sucrase.transform(code, {
transforms: path.endsWith(".ts")
? ["imports", "typescript"]
: ["jsx", "imports", "typescript"],
}).code;
});
await runBenchmark(
"Sucrase",
benchmarkOptions,
async (code: string, path: string) =>
sucrase.transform(code, {
transforms: path.endsWith(".ts")
? ["imports", "typescript"]
: ["jsx", "imports", "typescript"],
}).code,
);
if (benchmarkOptions.sucraseOnly) {
return;
}
// To run swc in single-threaded mode, we call into it repeatedly using
// transformSync, which seems to have minimal overhead.
await runBenchmark("swc", benchmarkOptions, async (code: string, path: string) => {
return swc.transformSync(code, {
jsc: {
parser: {
syntax: "typescript",
tsx: !path.endsWith(".ts"),
dynamicImport: true,
decorators: true,
await runBenchmark(
"swc",
benchmarkOptions,
async (code: string, path: string) =>
swc.transformSync(code, {
jsc: {
parser: {
syntax: "typescript",
tsx: !path.endsWith(".ts"),
dynamicImport: true,
decorators: true,
},
target: "es2019",
},
target: "es2019",
},
module: {
type: "commonjs",
},
}).code;
});
module: {
type: "commonjs",
},
}).code,
);
// esbuild's transformSync has significant overhead since it spins up an
// external process, so instead create a "service" process and communicate to
// it. One way to force a single-threaded behavior is to sequentially call
Expand All @@ -251,40 +257,49 @@ async function benchmarkFiles(benchmarkOptions: BenchmarkOptions): Promise<void>
process.env.GOMAXPROCS = "1";
const esbuildService = await esbuild.startService();
try {
await runBenchmark("esbuild", benchmarkOptions, async (code: string, path: string) => {
return (
await esbuildService.transform(code, {
loader: path.endsWith(".ts") ? "ts" : "tsx",
format: "cjs",
})
).code;
});
await runBenchmark(
"esbuild",
benchmarkOptions,
async (code: string, path: string) =>
(
await esbuildService.transform(code, {
loader: path.endsWith(".ts") ? "ts" : "tsx",
format: "cjs",
})
).code,
);
} finally {
esbuildService.stop();
}
await runBenchmark("TypeScript", benchmarkOptions, async (code: string) => {
return TypeScript.transpileModule(code, {
compilerOptions: {
module: TypeScript.ModuleKind.CommonJS,
jsx: TypeScript.JsxEmit.React,
target: TypeScript.ScriptTarget.ESNext,
},
}).outputText;
});
await runBenchmark("Babel", benchmarkOptions, async (code: string, path: string) => {
return babel.transformSync(code, {
filename: path.endsWith(".ts") ? "sample.ts" : "sample.tsx",
presets: path.endsWith(".ts")
? ["@babel/preset-typescript"]
: ["@babel/preset-react", "@babel/preset-typescript"],
plugins: [
"@babel/plugin-transform-modules-commonjs",
"@babel/plugin-syntax-top-level-await",
"@babel/plugin-proposal-export-namespace-from",
["@babel/plugin-proposal-decorators", {legacy: true}],
],
}).code;
});
await runBenchmark(
"TypeScript",
benchmarkOptions,
async (code: string) =>
TypeScript.transpileModule(code, {
compilerOptions: {
module: TypeScript.ModuleKind.CommonJS,
jsx: TypeScript.JsxEmit.React,
target: TypeScript.ScriptTarget.ESNext,
},
}).outputText,
);
await runBenchmark(
"Babel",
benchmarkOptions,
async (code: string, path: string) =>
babel.transformSync(code, {
filename: path.endsWith(".ts") ? "sample.ts" : "sample.tsx",
presets: path.endsWith(".ts")
? ["@babel/preset-typescript"]
: ["@babel/preset-react", "@babel/preset-typescript"],
plugins: [
"@babel/plugin-transform-modules-commonjs",
"@babel/plugin-syntax-top-level-await",
"@babel/plugin-proposal-export-namespace-from",
["@babel/plugin-proposal-decorators", {legacy: true}],
],
}).code,
);
/* eslint-enable @typescript-eslint/require-await */
}

Expand Down
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,26 @@
"url": "https://github.com/Astra-mod/sucrase/issues"
},
"devDependencies": {
"@types/glob": "7.1.1",
"@types/mocha": "^5.2.7",
"@types/mz": "^0.0.32",
"@types/node": "^12.12.7",
"@typescript-eslint/eslint-plugin": "^4.11.1",
"@typescript-eslint/parser": "^4.11.1",
"chalk": "2.4.1",
"codecov": "^3.8.1",
"eslint": "^6.6.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.5.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.1.1",
"mocha": "^7.1.1",
"nyc": "^14.1.1",
"prettier": "^2.0.5",
"@types/glob": "^7",
"@types/mocha": "^9.1.1",
"@types/mz": "^2.7.4",
"@types/node": "^17.0.41",
"@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1",
"chalk": "^4",
"codecov": "^3.8.3",
"eslint": "^8.17.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"mocha": "^10.0.0",
"nyc": "^15.1.0",
"prettier": "^2.6.2",
"sucrase": "^3.21.0",
"test262-harness": "^6.5.0",
"ts-interface-builder": "^0.2.1",
"typescript": "^4.1.3"
"test262-harness": "^10.0.0",
"ts-interface-builder": "^0.3.3",
"typescript": "^4.7.3"
},
"dependencies": {
"@astra-mod/pirates": "^4.2.0",
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export function transform(code: string, options: Options): TransformResult {
};
}
return result;
} catch (e) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
if (options.filePath) {
e.message = `Error transforming ${options.filePath}: ${e.message}`;
}
Expand Down

0 comments on commit 0d3c2b6

Please sign in to comment.