@@ -428,40 +428,50 @@ function verifyWorkerAssets(workersDirectory) {
428428}
429429
430430function verifyCoreExcludesParser ( coreDirectory ) {
431- const moduleIds = JSON . parse (
432- readFileSync ( join ( coreDirectory , "module-ids .json" ) , "utf8 ") ,
431+ const trace = requireModuleTrace (
432+ join ( coreDirectory , "core- module-trace .json" ) ,
433433 ) ;
434- if ( ! Array . isArray ( moduleIds ) ) {
435- throw new Error ( "Core module trace was not an array" ) ;
434+ const chunks = chunkMap ( trace , coreDirectory ) ;
435+ const entries = trace . chunks . filter (
436+ ( chunk ) => chunk . isEntry === true ,
437+ ) ;
438+ if ( entries . length !== 1 ) {
439+ throw new Error ( "Core module trace did not contain exactly one entry" ) ;
436440 }
437- const parserModules = moduleIds . filter (
438- ( moduleId ) =>
439- typeof moduleId === "string" &&
440- moduleId . includes ( "/node-sql-parser/" ) ,
441+ const reachable = reachableChunks (
442+ chunks ,
443+ [ entries [ 0 ] . fileName ] ,
444+ true ,
441445 ) ;
442- if ( parserModules . length > 0 ) {
446+ const javascriptFiles = listFiles ( coreDirectory )
447+ . filter ( ( path ) => extname ( path ) === ".js" )
448+ . map ( ( path ) =>
449+ path . slice ( coreDirectory . length + 1 ) . split ( sep ) . join ( "/" ) ,
450+ ) ;
451+ const orphanJavascript = javascriptFiles . filter (
452+ ( fileName ) => ! reachable . has ( fileName ) ,
453+ ) ;
454+ if ( orphanJavascript . length > 0 ) {
443455 throw new Error (
444- `Core-only build included parser modules : ${ parserModules . join ( ", " ) } ` ,
456+ `Core-only build emitted unreachable JavaScript : ${ orphanJavascript . join ( ", " ) } ` ,
445457 ) ;
446458 }
447- const workerModules = moduleIds . filter (
459+ const moduleIds = trace . chunks . flatMap ( ( chunk ) => chunk . moduleIds ) ;
460+ const parserModules = moduleIds . filter (
448461 ( moduleId ) =>
449462 typeof moduleId === "string" &&
450- / (?: ^ | [ / \\ ] ) [ ^ / \\ ] * w o r k e r [ ^ / \\ ] * \. [ c m ] ? [ j t ] s $ / i . test ( moduleId ) ,
463+ moduleId . includes ( "/node-sql-parser/" ) ,
451464 ) ;
452- if ( workerModules . length > 0 ) {
465+ if ( parserModules . length > 0 ) {
453466 throw new Error (
454- `Core-only build included worker modules: ${ workerModules . join ( ", " ) } ` ,
467+ `Core-only build included parser modules: ${ parserModules . join ( ", " ) } ` ,
455468 ) ;
456469 }
457470 for ( const path of listFiles ( coreDirectory ) ) {
458471 const extension = extname ( path ) ;
459472 if ( extension !== ".js" && extension !== ".json" ) {
460473 continue ;
461474 }
462- if ( / w o r k e r / i. test ( basename ( path ) ) ) {
463- throw new Error ( `Core-only build emitted worker asset ${ basename ( path ) } ` ) ;
464- }
465475 const contents = readFileSync ( path , "utf8" ) ;
466476 const marker = PARSER_MARKERS . find ( ( candidate ) =>
467477 contents . includes ( candidate ) ,
@@ -471,13 +481,8 @@ function verifyCoreExcludesParser(coreDirectory) {
471481 `Core-only output ${ basename ( path ) } contained parser marker ${ marker } ` ,
472482 ) ;
473483 }
474- if ( extension === ".js" && / n e w \s + W o r k e r \s * \( / . test ( contents ) ) {
475- throw new Error (
476- `Core-only output ${ basename ( path ) } contained a worker constructor` ,
477- ) ;
478- }
479484 }
480- return moduleIds . length ;
485+ return new Set ( moduleIds ) . size ;
481486}
482487
483488function verifySsrImport ( fixtureDirectory ) {
@@ -697,7 +702,12 @@ try {
697702 const fixtureDirectory = join ( temporaryDirectory , "fixture" ) ;
698703 cpSync ( fixtureSource , fixtureDirectory , { recursive : true } ) ;
699704 runPackageManager (
700- [ "install" , "--frozen-lockfile" , "--ignore-scripts" ] ,
705+ [
706+ "install" ,
707+ "--frozen-lockfile" ,
708+ "--ignore-scripts" ,
709+ "--offline" ,
710+ ] ,
701711 fixtureDirectory ,
702712 ) ;
703713
0 commit comments