Skip to content

Commit 47528a9

Browse files
authored
Merge pull request #3 from alexpota/fix/build-config-exports-map
fix: correct package exports map and build configuration
2 parents d8737e6 + c6fcbb1 commit 47528a9

File tree

2 files changed

+23
-42
lines changed

2 files changed

+23
-42
lines changed

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,19 @@
3535
},
3636
"homepage": "https://github.com/alexpota/nestjs-redlock-universal#readme",
3737
"type": "module",
38-
"main": "./dist/index.js",
38+
"main": "./dist/index.cjs",
3939
"module": "./dist/index.js",
4040
"types": "./dist/index.d.ts",
4141
"exports": {
4242
".": {
43-
"types": "./dist/index.d.ts",
44-
"import": "./dist/index.js",
45-
"require": "./dist/index.cjs"
43+
"import": {
44+
"types": "./dist/index.d.ts",
45+
"default": "./dist/index.js"
46+
},
47+
"require": {
48+
"types": "./dist/index.d.cts",
49+
"default": "./dist/index.cjs"
50+
}
4651
}
4752
},
4853
"files": [

tsup.config.ts

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,23 @@ export default defineConfig({
44
// Entry points
55
entry: ['src/index.ts'],
66

7-
// Output formats
8-
format: ['esm', 'cjs'],
7+
// Output formats - Build both formats for proper metadata
8+
format: ['cjs', 'esm'],
99

10-
// Output options
11-
outDir: 'dist',
12-
clean: true,
13-
14-
// Code generation
15-
target: 'es2022',
16-
minify: false, // Keep readable for debugging
17-
sourcemap: false, // Following redlock-universal best practice
10+
// TypeScript - Generate declaration files
11+
dts: true,
1812

19-
// TypeScript
20-
dts: true, // Generate .d.ts files
21-
splitting: false, // Keep simple for library
22-
23-
// Bundling
24-
treeshake: true,
25-
external: [
26-
// Peer dependencies should be external
27-
'@nestjs/common',
28-
'@nestjs/core',
29-
'redlock-universal',
30-
'reflect-metadata',
31-
],
13+
// Build configuration
14+
splitting: false,
15+
sourcemap: true,
16+
clean: true,
3217

33-
// Banner for CJS compatibility
34-
banner: {
35-
js: `
36-
/**
37-
* nestjs-redlock-universal
38-
* NestJS integration for redlock-universal
39-
*/`.trim(),
40-
},
18+
// CRITICAL: Preserve decorator metadata
19+
keepNames: true,
4120

42-
// Platform
43-
platform: 'node',
21+
// Explicitly use tsconfig for decorator settings
22+
tsconfig: './tsconfig.json',
4423

45-
// esbuild options
46-
esbuildOptions(options) {
47-
options.conditions = ['node'];
48-
options.mainFields = ['module', 'main'];
49-
},
24+
// External dependencies - don't bundle peer deps
25+
external: ['@nestjs/common', '@nestjs/core', 'redlock-universal', 'reflect-metadata'],
5026
});

0 commit comments

Comments
 (0)