From 14f7018a34928886ed11a4311e45c169b2c8ef7c Mon Sep 17 00:00:00 2001 From: hrmny <8845940+ForsakenHarmony@users.noreply.github.com> Date: Tue, 24 Sep 2024 23:55:13 +0200 Subject: [PATCH] chore: auto-format generated types with prettier (#70405) ### What? Added a step in both `build-native.cjs` and `build-wasm.cjs` scripts to run Prettier on the generated types file after writing it. Should have been added with #69680, but I didn't think about it. Currently, every time you built the native module you have changes in the git repo (which would be fixed on commit, but graphite might not be happy with uncommitted changes). --- .../next/src/build/swc/generated-wasm.d.ts | 24 +++++++++---------- scripts/build-native.cjs | 8 +++++++ scripts/build-wasm.cjs | 8 +++++++ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/packages/next/src/build/swc/generated-wasm.d.ts b/packages/next/src/build/swc/generated-wasm.d.ts index e1175f6c118e3..19be5f54ba11f 100644 --- a/packages/next/src/build/swc/generated-wasm.d.ts +++ b/packages/next/src/build/swc/generated-wasm.d.ts @@ -3,18 +3,6 @@ /* tslint:disable */ /* eslint-disable */ -/** - * @param {string} value - * @param {any} opts - * @returns {any} - */ -export function mdxCompileSync(value: string, opts: any): any -/** - * @param {string} value - * @param {any} opts - * @returns {Promise} - */ -export function mdxCompile(value: string, opts: any): Promise /** * @param {string} s * @param {any} opts @@ -51,3 +39,15 @@ export function parseSync(s: string, opts: any): any * @returns {Promise} */ export function parse(s: string, opts: any): Promise +/** + * @param {string} value + * @param {any} opts + * @returns {any} + */ +export function mdxCompileSync(value: string, opts: any): any +/** + * @param {string} value + * @param {any} opts + * @returns {Promise} + */ +export function mdxCompile(value: string, opts: any): Promise diff --git a/scripts/build-native.cjs b/scripts/build-native.cjs index 1de8cd81660fa..b073e228778c3 100755 --- a/scripts/build-native.cjs +++ b/scripts/build-native.cjs @@ -5,6 +5,7 @@ const { booleanArg, execAsyncWithOutput, execFn, + exec, namedValueArg, } = require('./pack-util.cjs') const fs = require('fs') @@ -85,4 +86,11 @@ function writeTypes() { vendoredTypes + generatedTypesMarker + generatedNotice + generatedTypes fs.writeFileSync(vendoredTypesPath, vendoredTypes) + + exec('Prettify generated types', [ + 'pnpm', + 'prettier', + '--write', + vendoredTypesPath, + ]) } diff --git a/scripts/build-wasm.cjs b/scripts/build-wasm.cjs index d46793d2699ae..50d4b99b6eb33 100755 --- a/scripts/build-wasm.cjs +++ b/scripts/build-wasm.cjs @@ -5,6 +5,7 @@ const { booleanArg, execAsyncWithOutput, execFn, + exec, namedValueArg, } = require('./pack-util.cjs') const fs = require('fs') @@ -79,4 +80,11 @@ function writeTypes() { const vendoredTypes = generatedNotice + generatedTypes fs.writeFileSync(vendoredTypesPath, vendoredTypes) + + exec('Prettify generated types', [ + 'pnpm', + 'prettier', + '--write', + vendoredTypesPath, + ]) }