Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix building @electric-sql/react #2131

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading