Skip to content

Commit

Permalink
fix building @electric-sql/react (#2131)
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews authored Dec 9, 2024
1 parent 951a97c commit 255da54
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
1 change: 0 additions & 1 deletion packages/react-hooks/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ module.exports = {
ignorePatterns: [
`**/node_modules/**`,
`**/dist/**`,
`tsup.config.ts`,
`vitest.config.ts`,
`.eslintrc.js`,
],
Expand Down
7 changes: 6 additions & 1 deletion packages/react-hooks/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -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"]
}
}
}
29 changes: 15 additions & 14 deletions packages/react-hooks/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ import { defineConfig } from 'tsup'
export default defineConfig((options: Options) => {
const commonOptions: Partial<Options> = {
entry: {
index: 'src/index.ts',
index: `src/index.ts`,
},
tsconfig: `./tsconfig.build.json`,
sourcemap: true,
external: [`@electric-sql/client`],
...options,
}

return [
// ESM build with .d.ts
{
...commonOptions,
format: ['esm'],
outExtension: () => ({ js: '.mjs' }),
format: [`esm`],
outExtension: () => ({ js: `.mjs` }),
dts: {
entry: commonOptions.entry,
resolve: true,
Expand All @@ -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,
Expand All @@ -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<string, string>,
outExtension: () => ({ js: `.js` }),
entry: { 'index.legacy-esm': `src/index.ts` } as Record<string, string>,
},
// 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<string, string>,
},
]
Expand Down

0 comments on commit 255da54

Please sign in to comment.