()
| 362 | * @returns {Source | null} the default export |
| 363 | */ |
| 364 | const generateJSDefaultExport = () => { |
| 365 | switch (exportType) { |
| 366 | case "text": { |
| 367 | return this._generateCssText(module, generateContext, true); |
| 368 | } |
| 369 | case "css-style-sheet": { |
| 370 | const rt = generateContext.runtimeTemplate; |
| 371 | const fnPrefix = rt.supportsArrowFunction() |
| 372 | ? "() => {\n" |
| 373 | : "function() {\n"; |
| 374 | const constOrVar = rt.renderConst(); |
| 375 | const fallback = |
| 376 | "{ cssText: css, replaceSync: function(value) { this.cssText = value; } }"; |
| 377 | if (rt.compilation.compiler.platform.node === true) { |
| 378 | return new ConcatSource( |
| 379 | `(${fnPrefix}${constOrVar} css = `, |
| 380 | this._generateCssText(module, generateContext, true), |
| 381 | `;\nreturn ${fallback};\n})()` |
| 382 | ); |
| 383 | } |
| 384 | if (rt.isUniversalTarget()) { |
| 385 | return new ConcatSource( |
| 386 | `(${fnPrefix}${constOrVar} css = `, |
| 387 | this._generateCssText(module, generateContext, true), |
| 388 | `;\nif (typeof CSSStyleSheet === 'undefined') return ${fallback};\n${constOrVar} sheet = new CSSStyleSheet();\nsheet.replaceSync(css);\nreturn sheet;\n})()` |
| 389 | ); |
| 390 | } |
| 391 | return new ConcatSource( |
| 392 | `(${fnPrefix}${constOrVar} sheet = new CSSStyleSheet();\nsheet.replaceSync(`, |
| 393 | this._generateCssText(module, generateContext, true), |
| 394 | ");\nreturn sheet;\n})()" |
| 395 | ); |
| 396 | } |
| 397 | default: |
| 398 | return null; |
| 399 | } |
| 400 | }; |
| 401 | |
| 402 | /** @type {Source | null} */ |
| 403 | const defaultExport = generateJSDefaultExport(); |
nothing calls this directly
no test coverage detected