@@ -30,20 +30,28 @@ export default defineConfig({
3030 if ( source === '../../binding/index.js' || source === '../binding/index.js' ) {
3131 return true ;
3232 }
33+ if ( source === '../versions.js' ) {
34+ return true ;
35+ }
3336 return false ;
3437 } ,
3538 plugins : [
3639 {
37- name : 'fix-binding-path' ,
38- // Rewrite the binding import path for the output directory.
39- // Source files import from ../../binding/index.js (relative to src/*/).
40- // Output is in dist/global/, so the correct path is ../../binding/index.js (two dirs up).
41- // Rolldown normalizes it to ../binding/index.js which is wrong.
40+ name : 'fix-external-paths' ,
41+ // Rewrite external import paths for the output directory (dist/global/).
42+ // Rolldown normalizes relative paths from source locations, but the output
43+ // is two directories deep (dist/global/), so the paths need adjustment.
4244 renderChunk ( code ) {
43- if ( code . includes ( '../binding/index.js' ) ) {
44- return { code : code . replaceAll ( '../binding/index.js' , '../../binding/index.js' ) } ;
45+ let result = code ;
46+ // ../../binding/index.js → Rolldown normalizes to ../binding/index.js, needs ../../
47+ if ( result . includes ( '../binding/index.js' ) ) {
48+ result = result . replaceAll ( '../binding/index.js' , '../../binding/index.js' ) ;
4549 }
46- return null ;
50+ // ../versions.js → Rolldown normalizes to ./versions.js, needs ../
51+ if ( result . includes ( './versions.js' ) ) {
52+ result = result . replaceAll ( './versions.js' , '../versions.js' ) ;
53+ }
54+ return result !== code ? { code : result } : null ;
4755 } ,
4856 } ,
4957 {
0 commit comments