-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #2107 From running `npm pack` locally on PR: <img width="671" alt="Screenshot 2024-12-06 at 9 24 58 AM" src="https://github.com/user-attachments/assets/322af457-bcd0-4f66-b355-e07545207ab1"> The change is making exports explicit for esm or cjs: ```json "exports": { ".": { "import": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" }, "require": { "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } } ``` And generating separate type declarations.
- Loading branch information
1 parent
abad10e
commit dae3b0d
Showing
11 changed files
with
160 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@electric-sql/client": patch | ||
"@electric-sql/react": patch | ||
--- | ||
|
||
Fix node 16 cjs import |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,4 @@ export async function GET(request: Request) { | |
}) | ||
} | ||
return resp | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json" | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"paths": { | ||
"@electric-sql/client": ["../typescript-client/src"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,61 @@ | ||
import type { Options } from 'tsup' | ||
import { defineConfig } from 'tsup' | ||
|
||
export default defineConfig(options => { | ||
export default defineConfig((options: Options) => { | ||
const commonOptions: Partial<Options> = { | ||
entry: { | ||
index: 'src/index.ts' | ||
index: 'src/index.ts', | ||
}, | ||
tsconfig: `./tsconfig.build.json`, | ||
// esbuildPlugins: [mangleErrorsTransform], | ||
sourcemap: true, | ||
...options | ||
...options, | ||
} | ||
|
||
return [ | ||
// Standard ESM, embedded `process.env.NODE_ENV` checks | ||
// ESM build with .d.ts | ||
{ | ||
...commonOptions, | ||
format: ['esm'], | ||
outExtension: () => ({ js: '.mjs' }), // Add dts: '.d.ts' when egoist/tsup#1053 lands | ||
dts: true, | ||
clean: true | ||
outExtension: () => ({ js: '.mjs' }), | ||
dts: { | ||
entry: commonOptions.entry, | ||
resolve: true, | ||
}, | ||
clean: true, | ||
}, | ||
// Support Webpack 4 by pointing `"module"` to a file with a `.js` extension | ||
// CJS build with .d.cts | ||
{ | ||
...commonOptions, | ||
format: ['cjs'], | ||
outDir: './dist/cjs/', | ||
outExtension: () => ({ js: '.cjs' }), | ||
dts: { | ||
entry: commonOptions.entry, | ||
resolve: true, | ||
}, | ||
clean: false, | ||
}, | ||
// Support Webpack 4 by pointing "module" to a file with a .js extension | ||
{ | ||
...commonOptions, | ||
format: ['esm'], | ||
target: 'es2017', | ||
dts: false, | ||
outExtension: () => ({ js: '.js' }), | ||
entry: { 'index.legacy-esm': 'src/index.ts' } as Record<string, string> | ||
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' }), | ||
minify: true, | ||
entry: { | ||
'index.browser': 'src/index.ts' | ||
}, | ||
'index.browser': 'src/index.ts', | ||
} as Record<string, string>, | ||
}, | ||
{ | ||
...commonOptions, | ||
format: 'cjs', | ||
outDir: './dist/cjs/', | ||
outExtension: () => ({ js: '.cjs' }) | ||
} | ||
] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.