@@ -19,6 +19,7 @@ const {
1919const RuntimeGlobals = require ( "../RuntimeGlobals" ) ;
2020const Template = require ( "../Template" ) ;
2121const CssImportDependency = require ( "../dependencies/CssImportDependency" ) ;
22+ const EntryDependency = require ( "../dependencies/EntryDependency" ) ;
2223const { getUndoPath } = require ( "../util/identifier" ) ;
2324const memoize = require ( "../util/memoize" ) ;
2425
@@ -467,22 +468,45 @@ class CssGenerator extends Generator {
467468 * @returns {SourceTypes } available types (do not mutate)
468469 */
469470 getTypes ( module ) {
470- if ( this . _generatesJsOnly ( module ) ) {
471- return JAVASCRIPT_TYPES ;
472- }
473- /** @type {Set<string> } */
471+ const exportType = /** @type {BuildMeta } */ ( module . buildMeta ) . exportType ;
474472 const sourceTypes = new Set ( ) ;
475473 const connections = this . _moduleGraph . getIncomingConnections ( module ) ;
474+
475+ let isEntryModule = false ;
476476 for ( const connection of connections ) {
477- if ( connection . dependency instanceof CssImportDependency ) {
477+ if ( connection . dependency instanceof EntryDependency ) {
478+ isEntryModule = true ;
479+ }
480+ if (
481+ exportType === "link" &&
482+ connection . dependency instanceof CssImportDependency
483+ ) {
478484 continue ;
479485 }
480486 if ( ! connection . originModule ) {
481487 continue ;
482488 }
483489 if ( connection . originModule . type . split ( "/" ) [ 0 ] !== CSS_TYPE ) {
484490 sourceTypes . add ( JAVASCRIPT_TYPE ) ;
491+ } else {
492+ const originModule = /** @type {CssModule } */ connection . originModule ;
493+ const originExportType = /** @type {BuildMeta } */ (
494+ originModule . buildMeta
495+ ) . exportType ;
496+ if (
497+ /** @type {boolean } */ (
498+ originExportType && originExportType !== "link"
499+ )
500+ ) {
501+ sourceTypes . add ( JAVASCRIPT_TYPE ) ;
502+ }
503+ }
504+ }
505+ if ( this . _generatesJsOnly ( module ) ) {
506+ if ( sourceTypes . has ( JAVASCRIPT_TYPE ) || isEntryModule ) {
507+ return JAVASCRIPT_TYPES ;
485508 }
509+ return new Set ( ) ;
486510 }
487511 if ( sourceTypes . has ( JAVASCRIPT_TYPE ) ) {
488512 return JAVASCRIPT_AND_CSS_TYPES ;
0 commit comments