From b06c12f03b42d665bc56362a325cb2990edb5c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Wed, 28 Aug 2024 12:02:17 +0200 Subject: [PATCH] @php-wasm/util: Publish TypeScript types https://github.com/WordPress/wordpress-playground/pull/1593 caused the `@php-wasm/util` package to be published without the `index.d.ts` type declarations file which causes the following TypeScript error: ``` Could not find a declaration file for module '@php-wasm/node'. ``` This PR adds the missing `dts()` plugin to vite.config.ts and enables publishing the declarations file. Before we can say https://github.com/WordPress/wordpress-playground/issues/1662 is fixed, we'll need to merge this PR, release new packages, and confirm they import cleanly without any TypeScript errors. Ideally we'd have a smoke test for that right in the CI. --- packages/php-wasm/util/vite.config.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/php-wasm/util/vite.config.ts b/packages/php-wasm/util/vite.config.ts index de7702ed45..836b2c0470 100644 --- a/packages/php-wasm/util/vite.config.ts +++ b/packages/php-wasm/util/vite.config.ts @@ -1,6 +1,9 @@ /// import { defineConfig } from 'vite'; +import dts from 'vite-plugin-dts'; +import { join } from 'path'; + import viteTsConfigPaths from 'vite-tsconfig-paths'; // eslint-disable-next-line @nx/enforce-module-boundaries import { getExternalModules } from '../../vite-extensions/vite-external-modules'; @@ -9,6 +12,11 @@ export default defineConfig({ cacheDir: '../../../node_modules/.vite/php-wasm-util', plugins: [ + dts({ + entryRoot: 'src', + tsconfigPath: join(__dirname, 'tsconfig.lib.json'), + }), + viteTsConfigPaths({ root: '../../../', }),