From d40c00eb858273e5b64b85acc5dcf2fa796c9b8c Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Fri, 14 Nov 2025 16:49:17 +0900 Subject: [PATCH] feat: add `await` before async functions --- .../guide/usage/minifier/dead-code-elimination.md | 12 ++++++------ src/docs/guide/usage/minifier/mangling.md | 6 +++--- .../guide/usage/minifier/syntax-normalization.md | 6 +++--- .../usage/transformer/global-variable-replacement.md | 6 +++--- .../guide/usage/transformer/isolated-declarations.md | 2 +- src/docs/guide/usage/transformer/jsx.md | 4 ++-- src/docs/guide/usage/transformer/lowering.md | 4 ++-- src/docs/guide/usage/transformer/plugins.md | 2 +- src/docs/guide/usage/transformer/typescript.md | 10 +++++----- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/docs/guide/usage/minifier/dead-code-elimination.md b/src/docs/guide/usage/minifier/dead-code-elimination.md index 01f597be4a..167b0b4053 100644 --- a/src/docs/guide/usage/minifier/dead-code-elimination.md +++ b/src/docs/guide/usage/minifier/dead-code-elimination.md @@ -27,7 +27,7 @@ const bar = window.bar(); // Example import { minify } from "oxc-minify"; -const result = minify("lib.js", code, { +const result = await minify("lib.js", code, { compress: { dropConsole: true, }, @@ -55,7 +55,7 @@ debugger; // Example import { minify } from "oxc-minify"; -const result = minify("lib.js", code, { +const result = await minify("lib.js", code, { compress: { dropDebugger: true, }, @@ -79,7 +79,7 @@ console.log("bar"); // Example import { minify } from "oxc-minify"; -const result = minify("lib.js", code, { +const result = await minify("lib.js", code, { compress: { dropLabels: ["DEV"], }, @@ -103,7 +103,7 @@ All unused function / class / variable declarations are removed by default. You // Example import { minify } from "oxc-minify"; -const result = minify("lib.js", code, { +const result = await minify("lib.js", code, { compress: { unused: true, // or "keep_assign" }, @@ -128,7 +128,7 @@ var bar = function foo() {}; // Example import { minify } from "oxc-minify"; -const result = minify("lib.js", code, { +const result = await minify("lib.js", code, { compress: { keepNames: true, // shorthand of { function: true, class: true } }, @@ -219,7 +219,7 @@ bar(); // Example import { minify } from "oxc-minify"; -const result = minify("lib.js", code, { +const result = await minify("lib.js", code, { compress: { treeshake: { manualPureFunctions: ["foo", "bar.baz"], diff --git a/src/docs/guide/usage/minifier/mangling.md b/src/docs/guide/usage/minifier/mangling.md index 43cb31b036..e66ab70f4c 100644 --- a/src/docs/guide/usage/minifier/mangling.md +++ b/src/docs/guide/usage/minifier/mangling.md @@ -20,7 +20,7 @@ var e = 1; // Example import { minify } from "oxc-minify"; -const result = minify("lib.js", code, { +const result = await minify("lib.js", code, { module: false, // non-module code compress: { mangle: { @@ -46,7 +46,7 @@ var foo = function() {}; // Example import { minify } from "oxc-minify"; -const result = minify("lib.js", code, { +const result = await minify("lib.js", code, { compress: { mangle: { keepNames: true, // shorthand of { function: true, class: true } @@ -77,7 +77,7 @@ var slot_0 = 1; // Example import { minify } from "oxc-minify"; -const result = minify("lib.js", code, { +const result = await minify("lib.js", code, { compress: { mangle: { debug: true, diff --git a/src/docs/guide/usage/minifier/syntax-normalization.md b/src/docs/guide/usage/minifier/syntax-normalization.md index 899d40f013..7917b95366 100644 --- a/src/docs/guide/usage/minifier/syntax-normalization.md +++ b/src/docs/guide/usage/minifier/syntax-normalization.md @@ -11,7 +11,7 @@ Oxc minifier uses some syntaxes that are only supported in newer environments. Y ```js import { minify } from "oxc-minify"; -const result = minify("lib.js", code, { +const result = await minify("lib.js", code, { compress: { target: "chrome87", }, @@ -35,7 +35,7 @@ var foo = 1, bar = 2; // Example import { minify } from "oxc-minify"; -const result = minify("lib.js", code, { +const result = await minify("lib.js", code, { compress: { joinVars: false, }, @@ -59,7 +59,7 @@ foo(), bar(); // Example import { minify } from "oxc-minify"; -const result = minify("lib.js", code, { +const result = await minify("lib.js", code, { compress: { sequences: false, }, diff --git a/src/docs/guide/usage/transformer/global-variable-replacement.md b/src/docs/guide/usage/transformer/global-variable-replacement.md index 20056a4c11..e0a0760c11 100644 --- a/src/docs/guide/usage/transformer/global-variable-replacement.md +++ b/src/docs/guide/usage/transformer/global-variable-replacement.md @@ -18,7 +18,7 @@ const foo = 1; // Example import { transform } from "oxc-transform"; -const result = transform("lib.js", sourceCode, { +const result = await transform("lib.js", sourceCode, { define: { __DEV__: "true", }, @@ -50,7 +50,7 @@ console.log(foo.bar); // undefined // Example import { transform } from "oxc-transform"; -const result = transform("lib.js", sourceCode, { +const result = await transform("lib.js", sourceCode, { define: { __OBJECT__: "{}", }, @@ -76,7 +76,7 @@ const foo = new P((resolve) => resolve(1)); // Example import { transform } from "oxc-transform"; -const result = transform("lib.js", sourceCode, { +const result = await transform("lib.js", sourceCode, { inject: { P: ["es6-promise", "Promise"], }, diff --git a/src/docs/guide/usage/transformer/isolated-declarations.md b/src/docs/guide/usage/transformer/isolated-declarations.md index 3ec39145c4..f162c11eb5 100644 --- a/src/docs/guide/usage/transformer/isolated-declarations.md +++ b/src/docs/guide/usage/transformer/isolated-declarations.md @@ -32,7 +32,7 @@ export declare enum Bar { ```ts import { isolatedDeclaration } from "oxc-transform"; -const result = isolatedDeclaration("lib.ts", sourceCode, { +const result = await isolatedDeclaration("lib.ts", sourceCode, { sourcemap: false, stripInternal: false, }); diff --git a/src/docs/guide/usage/transformer/jsx.md b/src/docs/guide/usage/transformer/jsx.md index ed8e78f33d..9420466113 100644 --- a/src/docs/guide/usage/transformer/jsx.md +++ b/src/docs/guide/usage/transformer/jsx.md @@ -7,7 +7,7 @@ Oxc transformer supports transforming JSX. ```js import { transform } from "oxc-transform"; -const result = transform("App.jsx", sourceCode, { +const result = await transform("App.jsx", sourceCode, { jsx: { runtime: "automatic", // or "classic" development: false, // or true @@ -93,7 +93,7 @@ To enable React Refresh transformation, set `jsx.refresh` option: ```javascript import { transform } from "oxc-transform"; -const result = transform("App.jsx", sourceCode, { +const result = await transform("App.jsx", sourceCode, { jsx: { development: true, refresh: true, diff --git a/src/docs/guide/usage/transformer/lowering.md b/src/docs/guide/usage/transformer/lowering.md index 8d20b3ae8e..be6a750d56 100644 --- a/src/docs/guide/usage/transformer/lowering.md +++ b/src/docs/guide/usage/transformer/lowering.md @@ -27,7 +27,7 @@ The values that are supported by [esbuild's target option](https://esbuild.githu ```js import { transform } from "oxc-transform"; -const result = transform("lib.js", "const foo = a ?? b;", { +const result = await transform("lib.js", "const foo = a ?? b;", { target: ["chrome87", "es2022"], }); ``` @@ -108,7 +108,7 @@ You can specify assumptions for the compiler to make the output more smaller. ```js import { transform } from "oxc-transform"; -const result = transform("lib.js", "const foo = a ?? b;", { +const result = await transform("lib.js", "const foo = a ?? b;", { target: ["chrome87", "es2022"], assumptions: { noDocumentAll: true, diff --git a/src/docs/guide/usage/transformer/plugins.md b/src/docs/guide/usage/transformer/plugins.md index bdb5df61ac..9aa9b1151e 100644 --- a/src/docs/guide/usage/transformer/plugins.md +++ b/src/docs/guide/usage/transformer/plugins.md @@ -11,7 +11,7 @@ The styled-components plugin adds comprehensive support for styled-components wi ```javascript import { transform } from "oxc-transform"; -const result = transform("Component.jsx", sourceCode, { +const result = await transform("Component.jsx", sourceCode, { plugins: { styledComponents: { displayName: true, diff --git a/src/docs/guide/usage/transformer/typescript.md b/src/docs/guide/usage/transformer/typescript.md index 6a1450b484..11a0e40afa 100644 --- a/src/docs/guide/usage/transformer/typescript.md +++ b/src/docs/guide/usage/transformer/typescript.md @@ -5,7 +5,7 @@ Oxc transformer supports transforming TypeScript to JavaScript. ```js import { transform } from "oxc-transform"; -const result = transform("lib.ts", sourceCode, { +const result = await transform("lib.ts", sourceCode, { typescript: { jsxPragma: "React.createElement", jsxPragmaFrag: "React.Fragment", @@ -27,7 +27,7 @@ If you are using this option, make sure to set `typescript.onlyRemoveTypeImports ```js import { transform } from "oxc-transform"; -const result = transform("lib.ts", sourceCode, { +const result = await transform("lib.ts", sourceCode, { typescript: { onlyRemoveTypeImports: true, }, @@ -43,7 +43,7 @@ If you are disabling this option, make sure to set `typescript.removeClassFields ```js import { transform } from "oxc-transform"; -const result = transform("lib.ts", sourceCode, { +const result = await transform("lib.ts", sourceCode, { typescript: { removeClassFieldsWithoutInitializer: true, }, @@ -63,7 +63,7 @@ If you are using the [`emitDecoratorMetadata`](https://www.typescriptlang.org/ts ```js import { transform } from "oxc-transform"; -const result = transform("lib.ts", sourceCode, { +const result = await transform("lib.ts", sourceCode, { decorators: { legacy: true, emitDecoratorMetadata: true, @@ -160,7 +160,7 @@ If you are using the [`rewriteImportExtensions`](https://www.typescriptlang.org/ ```js import { transform } from "oxc-transform"; -const result = transform("lib.ts", sourceCode, { +const result = await transform("lib.ts", sourceCode, { typescript: { rewriteImportExtensions: "rewrite", // or "remove" },