Skip to content

Conversation

@xiaoxiaojx
Copy link
Member

Summary
feat(css): added css-style-sheet to exportType for CSSStyleSheet return

What kind of change does this PR introduce?
feature

Did you add tests for your changes?
Yes

Does this PR introduce a breaking change?
No

If relevant, what needs to be documented once your changes are merged or what have you already documented?
Need to add docs for CSS exportType

.another {
font-size: 16px;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add url and @import here to ensure we handle them

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's improve a test case and we can merge

@xiaoxiaojx xiaoxiaojx force-pushed the feat/css-style-sheet branch from 39ce594 to fe75ab7 Compare November 7, 2025 12:53
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 7, 2025

CodSpeed Performance Report

Merging #20104 will not alter performance

Comparing xiaoxiaojx:feat/css-style-sheet (6b091d2) with main (1328dcb)

Summary

✅ 69 untouched

@xiaoxiaojx xiaoxiaojx force-pushed the feat/css-style-sheet branch 3 times, most recently from 56339ad to 909fe48 Compare November 11, 2025 13:07
)};`
]);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a HMR test case, also there is import("./style.css", { with: { type: "css" } }), so make sense to have the only one runtime, just adding different code when export type is different

"var rules = s.cssRules;",
"for (var j = 0; j < rules.length; j++) {",
Template.indent("cssTexts.push(rules[j].cssText);"),
"}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just caught this - do we handle CSS nesting here?

return generateContext.runtimeTemplate.concatenation(
...importCode,
moduleCode
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we still can use concatenation for text to avoid extra work in runtime? i.e. concatenation for text and runtime logic for css-style-sheet?

// Child modules imported via @import should inherit this exportType
// instead of using the default "link", ensuring that the entire
// import chain uses the same export format.
const parent = state.compilation.moduleGraph.getIssuer(module);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about to use parent module, because issuer not always can be (although the parent too, but it seems to me more intuitive than taking the issuer)

@xiaoxiaojx xiaoxiaojx force-pushed the feat/css-style-sheet branch 2 times, most recently from 9688f85 to 2d15632 Compare November 12, 2025 04:33
@alexander-akait
Copy link
Member

@xiaoxiaojx Let's make a rebase and we can merge

@alexander-akait alexander-akait merged commit 102e1a4 into webpack:main Nov 12, 2025
47 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants