1+ // cache buster x6
12import { createRequire } from 'node:module' ;
23import { fileURLToPath } from 'node:url' ;
34
@@ -22,19 +23,63 @@ const babelConfigPath = fileURLToPath(
2223) ;
2324
2425// Read `name` from the current package's package.json
25- const { name } = createRequire ( import . meta. url ) (
26- path . resolve ( process . cwd ( ) , 'package.json' ) ,
27- ) ;
26+ const {
27+ name,
28+ dependencies = { } ,
29+ devDependencies = { } ,
30+ } = createRequire ( import . meta. url ) ( path . resolve ( process . cwd ( ) , 'package.json' ) ) ;
2831
2932const external = [ / n o d e _ m o d u l e s / ] ;
3033
34+ // Diagnostic logging for externalization
35+ console . log ( '[DIAGNOSTIC] Rollup config: Package info' , {
36+ packageName : name ,
37+ dependenciesCount : Object . keys ( dependencies ) . length ,
38+ devDependenciesCount : Object . keys ( devDependencies ) . length ,
39+ timestamp : new Date ( ) . toISOString ( ) ,
40+ cwd : process . cwd ( ) ,
41+ } ) ;
42+
3143const moduleFormatToDirectory = {
3244 esm : 'dist/esm' ,
3345 umd : 'dist/umd' ,
3446} ;
3547
3648const doTestUtilsExist = glob . sync ( testUtilsFilename ) . length > 0 ;
3749
50+ // Custom nodeExternals plugin with logging
51+ const createLoggingExternalsPlugin = ( ) => {
52+ const originalPlugin = nodeExternals ( { deps : true } ) ;
53+ const externalizedModules = new Set ( ) ;
54+
55+ return {
56+ ...originalPlugin ,
57+ resolveId : function ( id , importer ) {
58+ const result = originalPlugin . resolveId . call ( this , id , importer ) ;
59+
60+ if ( result === false ) {
61+ externalizedModules . add ( id ) ;
62+ console . log ( '[DIAGNOSTIC] Externalizing module:' , {
63+ module : id ,
64+ importer : importer || 'entry' ,
65+ timestamp : new Date ( ) . toISOString ( ) ,
66+ packageName : name ,
67+ } ) ;
68+ }
69+
70+ return result ;
71+ } ,
72+ buildEnd : function ( ) {
73+ console . log ( '[DIAGNOSTIC] Externalization summary:' , {
74+ packageName : name ,
75+ totalExternalized : externalizedModules . size ,
76+ externalizedModules : Array . from ( externalizedModules ) ,
77+ timestamp : new Date ( ) . toISOString ( ) ,
78+ } ) ;
79+ } ,
80+ } ;
81+ } ;
82+
3883/**
3984 *
4085 * @param {'esm' | 'umd' } format
@@ -55,7 +100,7 @@ const createConfigForFormat = (format, overrides) => {
55100 } ,
56101 plugins : [
57102 nodePolyfills ( ) ,
58- nodeExternals ( { deps : true } ) ,
103+ createLoggingExternalsPlugin ( ) ,
59104 nodeResolve ( { extensions } ) ,
60105
61106 babel ( {
@@ -67,7 +112,6 @@ const createConfigForFormat = (format, overrides) => {
67112 } ) ,
68113
69114 svgr ( ) ,
70- // cache buster!
71115 visualizer ( {
72116 open : false ,
73117 filename : `${ moduleFormatToDirectory [ format ] } /bundle-stats.html` ,
0 commit comments