|
| 1 | +// Jest Snapshot v1, https://goo.gl/fbAQLP |
| 2 | + |
| 3 | +exports[`inspector inspectPostcssPlugin patch snap 1`] = ` |
| 4 | +""use strict"; |
| 5 | +
|
| 6 | +Object.defineProperty(exports, "__esModule", { |
| 7 | + value: true |
| 8 | +}); |
| 9 | +const _setupTrackingContext = /*#__PURE__*/_interopRequireDefault(require("./lib/setupTrackingContext")); |
| 10 | +const _processTailwindFeatures = /*#__PURE__*/_interopRequireDefault(require("./processTailwindFeatures")); |
| 11 | +const _sharedState = require("./lib/sharedState"); |
| 12 | +const _findAtConfigPath = require("./lib/findAtConfigPath"); |
| 13 | +function _interopRequireDefault(obj) { |
| 14 | + return obj && obj.__esModule ? obj : { |
| 15 | + default: obj |
| 16 | + }; |
| 17 | +} |
| 18 | +const contextRef = { |
| 19 | + value: [] |
| 20 | +}; |
| 21 | +module.exports = function tailwindcss(configOrPath) { |
| 22 | + return { |
| 23 | + postcssPlugin: "tailwindcss", |
| 24 | + plugins: [_sharedState.env.DEBUG && function (root) { |
| 25 | + console.log("\\n"); |
| 26 | + console.time("JIT TOTAL"); |
| 27 | + return root; |
| 28 | + }, function (root, result) { |
| 29 | + contextRef.value.length = 0; |
| 30 | + var _findAtConfigPath1; |
| 31 | + // Use the path for the \`@config\` directive if it exists, otherwise use the |
| 32 | + // path for the file being processed |
| 33 | + configOrPath = (_findAtConfigPath1 = (0, _findAtConfigPath.findAtConfigPath)(root, result)) !== null && _findAtConfigPath1 !== void 0 ? _findAtConfigPath1 : configOrPath; |
| 34 | + let context = (0, _setupTrackingContext.default)(configOrPath); |
| 35 | + if (root.type === "document") { |
| 36 | + let roots = root.nodes.filter(node => node.type === "root"); |
| 37 | + for (const root1 of roots) { |
| 38 | + if (root1.type === "root") { |
| 39 | + contextRef.value.push((0, _processTailwindFeatures.default)(context)(root1, result)); |
| 40 | + } |
| 41 | + } |
| 42 | + return; |
| 43 | + } |
| 44 | + contextRef.value.push((0, _processTailwindFeatures.default)(context)(root, result)); |
| 45 | + }, _sharedState.env.OXIDE && function lightningCssPlugin(_root, result) { |
| 46 | + let postcss = require("postcss"); |
| 47 | + let lightningcss = require("lightningcss"); |
| 48 | + let browserslist = require("browserslist"); |
| 49 | + try { |
| 50 | + let transformed = lightningcss.transform({ |
| 51 | + filename: result.opts.from, |
| 52 | + code: Buffer.from(result.root.toString()), |
| 53 | + minify: false, |
| 54 | + sourceMap: !!result.map, |
| 55 | + inputSourceMap: result.map ? result.map.toString() : undefined, |
| 56 | + targets: typeof process !== "undefined" && process.env.JEST_WORKER_ID ? { |
| 57 | + chrome: 106 << 16 |
| 58 | + } : lightningcss.browserslistToTargets(browserslist(require("../package.json").browserslist)), |
| 59 | + drafts: { |
| 60 | + nesting: true, |
| 61 | + customMedia: true |
| 62 | + } |
| 63 | + }); |
| 64 | + var _result_map; |
| 65 | + result.map = Object.assign((_result_map = result.map) !== null && _result_map !== void 0 ? _result_map : {}, { |
| 66 | + toJSON() { |
| 67 | + return transformed.map.toJSON(); |
| 68 | + }, |
| 69 | + toString() { |
| 70 | + return transformed.map.toString(); |
| 71 | + } |
| 72 | + }); |
| 73 | + result.root = postcss.parse(transformed.code.toString("utf8")); |
| 74 | + } catch (err) { |
| 75 | + if (typeof process !== "undefined" && process.env.JEST_WORKER_ID) { |
| 76 | + let lines = err.source.split("\\n"); |
| 77 | + err = new Error(["Error formatting using Lightning CSS:", "", ...["\`\`\`css", ...lines.slice(Math.max(err.loc.line - 3, 0), err.loc.line), " ".repeat(err.loc.column - 1) + "^-- " + err.toString(), ...lines.slice(err.loc.line, err.loc.line + 2), "\`\`\`"]].join("\\n")); |
| 78 | + } |
| 79 | + if (Error.captureStackTrace) { |
| 80 | + Error.captureStackTrace(err, lightningCssPlugin); |
| 81 | + } |
| 82 | + throw err; |
| 83 | + } |
| 84 | + }, _sharedState.env.DEBUG && function (root) { |
| 85 | + console.timeEnd("JIT TOTAL"); |
| 86 | + console.log("\\n"); |
| 87 | + return root; |
| 88 | + }].filter(Boolean) |
| 89 | + }; |
| 90 | +}; |
| 91 | +module.exports.postcss = true; |
| 92 | +module.exports.contextRef = contextRef;" |
| 93 | +`; |
| 94 | + |
| 95 | +exports[`inspector inspectProcessTailwindFeaturesReturnContext patch snap 1`] = ` |
| 96 | +""use strict"; |
| 97 | +
|
| 98 | +Object.defineProperty(exports, "__esModule", { |
| 99 | + value: true |
| 100 | +}); |
| 101 | +Object.defineProperty(exports, "default", { |
| 102 | + enumerable: true, |
| 103 | + get: () => processTailwindFeatures |
| 104 | +}); |
| 105 | +const _normalizeTailwindDirectives = /*#__PURE__*/_interopRequireDefault(require("./lib/normalizeTailwindDirectives")); |
| 106 | +const _expandTailwindAtRules = /*#__PURE__*/_interopRequireDefault(require("./lib/expandTailwindAtRules")); |
| 107 | +const _expandApplyAtRules = /*#__PURE__*/_interopRequireDefault(require("./lib/expandApplyAtRules")); |
| 108 | +const _evaluateTailwindFunctions = /*#__PURE__*/_interopRequireDefault(require("./lib/evaluateTailwindFunctions")); |
| 109 | +const _substituteScreenAtRules = /*#__PURE__*/_interopRequireDefault(require("./lib/substituteScreenAtRules")); |
| 110 | +const _resolveDefaultsAtRules = /*#__PURE__*/_interopRequireDefault(require("./lib/resolveDefaultsAtRules")); |
| 111 | +const _collapseAdjacentRules = /*#__PURE__*/_interopRequireDefault(require("./lib/collapseAdjacentRules")); |
| 112 | +const _collapseDuplicateDeclarations = /*#__PURE__*/_interopRequireDefault(require("./lib/collapseDuplicateDeclarations")); |
| 113 | +const _partitionApplyAtRules = /*#__PURE__*/_interopRequireDefault(require("./lib/partitionApplyAtRules")); |
| 114 | +const _detectNesting = /*#__PURE__*/_interopRequireDefault(require("./lib/detectNesting")); |
| 115 | +const _setupContextUtils = require("./lib/setupContextUtils"); |
| 116 | +const _featureFlags = require("./featureFlags"); |
| 117 | +function _interopRequireDefault(obj) { |
| 118 | + return obj && obj.__esModule ? obj : { |
| 119 | + default: obj |
| 120 | + }; |
| 121 | +} |
| 122 | +function processTailwindFeatures(setupContext) { |
| 123 | + return function (root, result) { |
| 124 | + let { |
| 125 | + tailwindDirectives, |
| 126 | + applyDirectives |
| 127 | + } = (0, _normalizeTailwindDirectives.default)(root); |
| 128 | + (0, _detectNesting.default)()(root, result); |
| 129 | + // Partition apply rules that are found in the css |
| 130 | + // itself. |
| 131 | + (0, _partitionApplyAtRules.default)()(root, result); |
| 132 | + let context = setupContext({ |
| 133 | + tailwindDirectives, |
| 134 | + applyDirectives, |
| 135 | + registerDependency(dependency) { |
| 136 | + result.messages.push({ |
| 137 | + plugin: "tailwindcss", |
| 138 | + parent: result.opts.from, |
| 139 | + ...dependency |
| 140 | + }); |
| 141 | + }, |
| 142 | + createContext(tailwindConfig, changedContent) { |
| 143 | + return (0, _setupContextUtils.createContext)(tailwindConfig, changedContent, root); |
| 144 | + } |
| 145 | + })(root, result); |
| 146 | + if (context.tailwindConfig.separator === "-") { |
| 147 | + throw new Error("The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead."); |
| 148 | + } |
| 149 | + (0, _featureFlags.issueFlagNotices)(context.tailwindConfig); |
| 150 | + (0, _expandTailwindAtRules.default)(context)(root, result); |
| 151 | + // Partition apply rules that are generated by |
| 152 | + // addComponents, addUtilities and so on. |
| 153 | + (0, _partitionApplyAtRules.default)()(root, result); |
| 154 | + (0, _expandApplyAtRules.default)(context)(root, result); |
| 155 | + (0, _evaluateTailwindFunctions.default)(context)(root, result); |
| 156 | + (0, _substituteScreenAtRules.default)(context)(root, result); |
| 157 | + (0, _resolveDefaultsAtRules.default)(context)(root, result); |
| 158 | + (0, _collapseAdjacentRules.default)(context)(root, result); |
| 159 | + (0, _collapseDuplicateDeclarations.default)(context)(root, result); |
| 160 | + return context; |
| 161 | + }; |
| 162 | +}" |
| 163 | +`; |
0 commit comments