|
1 | 1 | import { defineConfig } from 'tsdown' |
2 | | -import { createRequire } from 'module' |
3 | 2 | import { fileURLToPath } from 'url' |
4 | 3 | import { dirname, join } from 'path' |
5 | 4 |
|
@@ -29,17 +28,21 @@ export default defineConfig([ |
29 | 28 | target: 'es2017', |
30 | 29 | inputOptions: (_options, format) => { |
31 | 30 | if (format === 'cjs') { |
32 | | - // Rolldown always resolves @supabase/tracing via its 'import' export |
33 | | - // condition (ESM source) even for CJS output — so import() ends up in |
34 | | - // index.cjs. hermesc (Hermes bytecode compiler for React Native) rejects |
35 | | - // import() at parse time; browser strict CSP blocks new Function() at |
36 | | - // runtime. Aliasing to the package's 'main' field (dist/main/) gives us |
37 | | - // TypeScript's CJS-compiled require() — safe for both constraints. |
| 31 | + // Rolldown defaults to the 'import' export condition even when emitting |
| 32 | + // CJS, so @supabase/tracing's ESM source (with native `import()`) ends |
| 33 | + // up inlined into dist/index.cjs. hermesc (Hermes bytecode compiler for |
| 34 | + // React Native release builds) rejects `import()` at parse time, before |
| 35 | + // dead-code elimination — so the syntax has to be physically absent |
| 36 | + // from the CJS bundle. |
| 37 | + // |
| 38 | + // Tell Rolldown to honor the 'require' export condition for this build. |
| 39 | + // For @supabase/tracing that resolves to dist/main/index.js — tsc's |
| 40 | + // CJS output, where dynamic `import()` has been lowered to require(). |
| 41 | + // dist/index.mjs intentionally keeps native `import()` (valid ESM, |
| 42 | + // not blocked by browser CSP, and Hermes never sees the ESM bundle). |
38 | 43 | return { |
39 | 44 | resolve: { |
40 | | - alias: { |
41 | | - '@supabase/tracing': createRequire(import.meta.url).resolve('@supabase/tracing'), |
42 | | - }, |
| 45 | + conditionNames: ['require', 'node', 'default'], |
43 | 46 | }, |
44 | 47 | } |
45 | 48 | } |
|
0 commit comments