MCPcopy
hub / github.com/webpack/webpack / handleValueAtRule

Method handleValueAtRule

lib/css/CssParser.js:2819–2926  ·  view source on GitHub ↗
(at)

Source from the content-addressed store, hash-verified

2817 * @param {AtRule} at the `@value` at-rule
2818 */
2819 const handleValueAtRule = (at) => {
2820 const start = A.start(at);
2821 const nameEnd = A.nameEnd(at);
2822 const semi = A.end(at);
2823 const atRuleEnd =
2824 source.charCodeAt(semi) === CC_SEMICOLON ? semi + 1 : semi;
2825 const params = input.slice(nameEnd, semi);
2826 const parsed = parseValueAtRuleParams(params);
2827
2828 if (
2829 typeof (/** @type {ValueAtRuleImport} */ (parsed).from) !== "undefined"
2830 ) {
2831 if (/** @type {ValueAtRuleImport} */ (parsed).from.length === 0) {
2832 this._emitWarning(
2833 state,
2834 `Broken '@value' at-rule: ${input.slice(start, atRuleEnd)}'`,
2835 locConverter,
2836 start,
2837 atRuleEnd
2838 );
2839
2840 const dep = new ConstDependency("", [start, atRuleEnd]);
2841 module.addPresentationalDependency(dep);
2842 return;
2843 }
2844
2845 let { from, items } = /** @type {ValueAtRuleImport} */ (parsed);
2846
2847 for (const { importName, localName } of items) {
2848 {
2849 const reexport = icssDefinitions.get(from);
2850
2851 if (reexport && reexport.value) {
2852 from = reexport.value.slice(1, -1);
2853 }
2854
2855 const dep = new CssIcssImportDependency(
2856 from,
2857 [0, 0],
2858 /** @type {"local" | "global"} */
2859 (mode),
2860 importName,
2861 localName
2862 );
2863 setDepLoc(dep, start, nameEnd);
2864 module.addDependency(dep);
2865
2866 icssDefinitions.set(localName, {
2867 importName,
2868 request: from
2869 });
2870 }
2871
2872 {
2873 const { line: sl, column: sc } = locConverter.get(start);
2874 const { line: el, column: ec } = locConverter.get(nameEnd);
2875 addCssExport(
2876 sl,

Callers

nothing calls this directly

Calls 8

_emitWarningMethod · 0.95
parseValueAtRuleParamsFunction · 0.85
sliceMethod · 0.80
addDependencyMethod · 0.65
getMethod · 0.45
setMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected