From 255da548488005cbeb91f0289840656eba9033a0 Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Mon, 9 Dec 2024 10:19:42 -0700 Subject: [PATCH] fix building @electric-sql/react (#2131) --- packages/react-hooks/.eslintrc.cjs | 1 - packages/react-hooks/tsconfig.build.json | 7 +++++- packages/react-hooks/tsup.config.ts | 29 ++++++++++++------------ 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/packages/react-hooks/.eslintrc.cjs b/packages/react-hooks/.eslintrc.cjs index 6df77a988f..49e377f535 100644 --- a/packages/react-hooks/.eslintrc.cjs +++ b/packages/react-hooks/.eslintrc.cjs @@ -34,7 +34,6 @@ module.exports = { ignorePatterns: [ `**/node_modules/**`, `**/dist/**`, - `tsup.config.ts`, `vitest.config.ts`, `.eslintrc.js`, ], diff --git a/packages/react-hooks/tsconfig.build.json b/packages/react-hooks/tsconfig.build.json index c147f4334f..cab6e40eaf 100644 --- a/packages/react-hooks/tsconfig.build.json +++ b/packages/react-hooks/tsconfig.build.json @@ -1,5 +1,10 @@ { "extends": "../../tsconfig.build.json", "include": ["src/**/*"], - "exclude": ["node_modules", "tests", "dist"] + "exclude": ["node_modules", "tests", "dist"], + "compilerOptions": { + "paths": { + "@electric-sql/client": ["../typescript-client/src"] + } + } } diff --git a/packages/react-hooks/tsup.config.ts b/packages/react-hooks/tsup.config.ts index 855d7d5288..102edb88d6 100644 --- a/packages/react-hooks/tsup.config.ts +++ b/packages/react-hooks/tsup.config.ts @@ -4,10 +4,11 @@ import { defineConfig } from 'tsup' export default defineConfig((options: Options) => { const commonOptions: Partial = { entry: { - index: 'src/index.ts', + index: `src/index.ts`, }, tsconfig: `./tsconfig.build.json`, sourcemap: true, + external: [`@electric-sql/client`], ...options, } @@ -15,8 +16,8 @@ export default defineConfig((options: Options) => { // ESM build with .d.ts { ...commonOptions, - format: ['esm'], - outExtension: () => ({ js: '.mjs' }), + format: [`esm`], + outExtension: () => ({ js: `.mjs` }), dts: { entry: commonOptions.entry, resolve: true, @@ -26,9 +27,9 @@ export default defineConfig((options: Options) => { // CJS build with .d.cts { ...commonOptions, - format: ['cjs'], - outDir: './dist/cjs/', - outExtension: () => ({ js: '.cjs' }), + format: [`cjs`], + outDir: `./dist/cjs/`, + outExtension: () => ({ js: `.cjs` }), dts: { entry: commonOptions.entry, resolve: true, @@ -38,23 +39,23 @@ export default defineConfig((options: Options) => { // Support Webpack 4 by pointing "module" to a file with a .js extension { ...commonOptions, - format: ['esm'], - target: 'es2017', + format: [`esm`], + target: `es2017`, dts: false, - outExtension: () => ({ js: '.js' }), - entry: { 'index.legacy-esm': 'src/index.ts' } as Record, + outExtension: () => ({ js: `.js` }), + entry: { 'index.legacy-esm': `src/index.ts` } as Record, }, // Browser-ready ESM, production + minified { ...commonOptions, define: { - 'process.env.NODE_ENV': JSON.stringify('production'), + 'process.env.NODE_ENV': JSON.stringify(`production`), }, - format: ['esm'], - outExtension: () => ({ js: '.mjs' }), + format: [`esm`], + outExtension: () => ({ js: `.mjs` }), minify: true, entry: { - 'index.browser': 'src/index.ts', + 'index.browser': `src/index.ts`, } as Record, }, ]