weapp-tailwindcss 5.0.0-next.1 → 5.0.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/bundlers/shared/generator-css.d.ts +3 -1
  2. package/dist/bundlers/vite/css-finalizer.d.ts +3 -0
  3. package/dist/bundlers/vite/generate-bundle.d.ts +14 -1
  4. package/dist/bundlers/vite/source-candidates.d.ts +15 -0
  5. package/dist/cli.js +1 -1
  6. package/dist/cli.mjs +1 -1
  7. package/dist/core.js +1 -1
  8. package/dist/core.mjs +1 -1
  9. package/dist/generator/options.d.ts +2 -0
  10. package/dist/generator/types.d.ts +1 -0
  11. package/dist/generator-Y-Ikv4Fu.mjs +1177 -0
  12. package/dist/{generator-css-DhPFjSzK.mjs → generator-css-Bwy_Uz89.mjs} +72 -32
  13. package/dist/{generator-css-CnYjiMrD.js → generator-css-CRLrHW4F.js} +72 -32
  14. package/dist/{generator-CZ-JXw6T.js → generator-mmhXzZnv.js} +797 -13
  15. package/dist/generator.js +1 -1
  16. package/dist/generator.mjs +1 -1
  17. package/dist/gulp.js +4 -5
  18. package/dist/gulp.mjs +4 -5
  19. package/dist/index.js +3 -3
  20. package/dist/index.mjs +3 -3
  21. package/dist/{loader-anchors-DvwgIYdA.mjs → loader-anchors-1MumTAtA.mjs} +2 -2
  22. package/dist/{loader-anchors-cprm4Klq.js → loader-anchors-TrFvT6g1.js} +1 -1
  23. package/dist/postcss.js +3 -1
  24. package/dist/postcss.mjs +3 -1
  25. package/dist/{recorder-rn_2v_nd.js → recorder-GdTJ3QqX.js} +1 -1
  26. package/dist/{recorder-B_XyZ576.mjs → recorder-XdFvVASS.mjs} +1 -1
  27. package/dist/tailwindcss/v4-engine/candidates.d.ts +2 -0
  28. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +1 -0
  29. package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +1 -0
  30. package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +1 -0
  31. package/dist/tailwindcss/v4-engine/tailwind-v4-default-colors.d.ts +1 -0
  32. package/dist/tailwindcss/v4-engine/types.d.ts +2 -0
  33. package/dist/{vite-C8JlHiyR.mjs → vite-BDywuCjn.mjs} +409 -163
  34. package/dist/{vite-BHpAqldo.js → vite-DgRh_GXn.js} +405 -158
  35. package/dist/vite.js +1 -1
  36. package/dist/vite.mjs +1 -1
  37. package/dist/{webpack-DNIJ0ysE.js → webpack-CAJR4hhP.js} +3 -3
  38. package/dist/{webpack-CABjKGGQ.mjs → webpack-CiHqVZTg.mjs} +3 -3
  39. package/dist/webpack.js +1 -1
  40. package/dist/webpack.mjs +1 -1
  41. package/dist/webpack4.js +3 -3
  42. package/dist/webpack4.mjs +3 -3
  43. package/package.json +5 -8
  44. package/dist/generator-Dwxgra97.mjs +0 -399
@@ -1,5 +1,5 @@
1
- import { _ as removeUnsupportedCascadeLayers, a as resolveTailwindV4Source, c as resolveTailwindV4SourceOptionsFromPatcher, f as resolveTailwindV3Source, i as normalizeWeappTailwindcssGeneratorOptions, m as resolveTailwindV3SourceOptionsFromPatcher, p as resolveTailwindV3SourceFromPatcher, s as resolveTailwindV4SourceFromPatcher, t as createWeappTailwindcssGenerator } from "./generator-Dwxgra97.mjs";
2
- import { l as replaceWxml } from "./recorder-B_XyZ576.mjs";
1
+ import { a as resolveTailwindV4Source, c as resolveTailwindV4SourceOptionsFromPatcher, h as resolveTailwindV3SourceOptionsFromPatcher, i as normalizeWeappTailwindcssGeneratorOptions, m as resolveTailwindV3SourceFromPatcher, p as resolveTailwindV3Source, s as resolveTailwindV4SourceFromPatcher, t as createWeappTailwindcssGenerator, v as removeUnsupportedCascadeLayers } from "./generator-Y-Ikv4Fu.mjs";
2
+ import { l as replaceWxml } from "./recorder-XdFvVASS.mjs";
3
3
  import postcss from "postcss";
4
4
  import path from "node:path";
5
5
  import process from "node:process";
@@ -643,13 +643,14 @@ function hasTailwindSourceDirectives(rawSource) {
643
643
  return false;
644
644
  }
645
645
  }
646
- function resolveCssEntrySource(rawSource, base) {
646
+ function resolveCssEntrySource(rawSource, base, options = {}) {
647
647
  try {
648
648
  const root = postcss.parse(rawSource);
649
649
  let found = false;
650
650
  let config;
651
651
  let configRequest;
652
652
  let removedConfig = false;
653
+ const removeConfig = options.removeConfig ?? true;
653
654
  root.walk((node) => {
654
655
  if (isTailwindGenerationDirective(node)) found = true;
655
656
  if (node.type === "atrule" && node.name === "config") {
@@ -658,8 +659,10 @@ function resolveCssEntrySource(rawSource, base) {
658
659
  configRequest = configPath;
659
660
  config = path.isAbsolute(configPath) ? configPath : path.resolve(base, configPath);
660
661
  }
661
- node.remove();
662
- removedConfig = true;
662
+ if (removeConfig) {
663
+ node.remove();
664
+ removedConfig = true;
665
+ }
663
666
  }
664
667
  });
665
668
  if (!found) return;
@@ -697,17 +700,40 @@ function stripStyleExtension(file) {
697
700
  return file.replace(/[?#].*$/, "").replace(/\.(?:wx|ac|jx|tt|q|c|ty)?ss$/i, "");
698
701
  }
699
702
  function createSourceStylePathCandidates(file, sourceOptions) {
700
- const relativeFile = stripStyleExtension(file);
701
- if (path.isAbsolute(relativeFile)) return [];
702
703
  const bases = [
703
704
  sourceOptions.projectRoot,
704
705
  sourceOptions.cwd,
705
706
  process.cwd()
706
707
  ].filter((item) => typeof item === "string" && item.length > 0);
708
+ const strippedFile = stripStyleExtension(file);
709
+ const relativeFiles = /* @__PURE__ */ new Set();
710
+ if (path.isAbsolute(strippedFile)) for (const base of bases) {
711
+ const relative = path.relative(base, strippedFile);
712
+ if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) continue;
713
+ relativeFiles.add(relative);
714
+ const parts = relative.split(path.sep).filter(Boolean);
715
+ if (parts.length > 1) {
716
+ relativeFiles.add(parts.slice(1).join(path.sep));
717
+ const distIndex = parts.lastIndexOf("dist");
718
+ if (distIndex >= 0 && distIndex < parts.length - 1) relativeFiles.add([...parts.slice(0, distIndex), ...parts.slice(distIndex + 1)].join(path.sep));
719
+ }
720
+ }
721
+ else {
722
+ relativeFiles.add(strippedFile);
723
+ const parts = strippedFile.split(/[\\/]/).filter(Boolean);
724
+ if (parts.length > 1) {
725
+ relativeFiles.add(parts.slice(1).join(path.sep));
726
+ const distIndex = parts.lastIndexOf("dist");
727
+ if (distIndex >= 0 && distIndex < parts.length - 1) relativeFiles.add([...parts.slice(0, distIndex), ...parts.slice(distIndex + 1)].join(path.sep));
728
+ }
729
+ }
707
730
  const candidates = /* @__PURE__ */ new Set();
708
- for (const base of bases) for (const sourceRoot of ["", "src"]) {
709
- const prefix = sourceRoot ? path.resolve(base, sourceRoot, relativeFile) : path.resolve(base, relativeFile);
710
- for (const extension of SOURCE_STYLE_EXTENSIONS) candidates.add(`${prefix}${extension}`);
731
+ for (const relativeFile of relativeFiles) {
732
+ if (!relativeFile || path.isAbsolute(relativeFile)) continue;
733
+ for (const base of bases) for (const sourceRoot of ["", "src"]) {
734
+ const prefix = sourceRoot ? path.resolve(base, sourceRoot, relativeFile) : path.resolve(base, relativeFile);
735
+ for (const extension of SOURCE_STYLE_EXTENSIONS) candidates.add(`${prefix}${extension}`);
736
+ }
711
737
  }
712
738
  return [...candidates];
713
739
  }
@@ -723,13 +749,16 @@ function extractStyleDirectiveSources(source) {
723
749
  if (styleSources.length > 0) return styleSources;
724
750
  return hasTailwindSourceDirectives(source) ? [source] : [];
725
751
  }
726
- function resolveSourceSideCssEntrySource(file, sourceOptions) {
752
+ function shouldResolveSourceSideCssEntry(rawSource) {
753
+ return rawSource.includes("@apply");
754
+ }
755
+ function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {}) {
727
756
  for (const sourceFile of createSourceStylePathCandidates(file, sourceOptions)) {
728
757
  if (!existsSync(sourceFile)) continue;
729
758
  try {
730
759
  const source = readFileSync(sourceFile, "utf8");
731
760
  for (const styleSource of extractStyleDirectiveSources(source)) {
732
- const cssEntrySource = resolveCssEntrySource(styleSource, path.dirname(sourceFile));
761
+ const cssEntrySource = resolveCssEntrySource(styleSource, path.dirname(sourceFile), resolveOptions);
733
762
  if (cssEntrySource) return cssEntrySource;
734
763
  }
735
764
  } catch {
@@ -737,11 +766,18 @@ function resolveSourceSideCssEntrySource(file, sourceOptions) {
737
766
  }
738
767
  }
739
768
  }
769
+ function tryResolveTailwindV4SourceOptions(runtimeState) {
770
+ try {
771
+ return resolveTailwindV4SourceOptionsFromPatcher(runtimeState.twPatcher);
772
+ } catch {
773
+ return;
774
+ }
775
+ }
740
776
  async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions) {
741
- const cssEntrySource = resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions));
777
+ const cssEntrySource = resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions), { removeConfig: majorVersion === 3 });
742
778
  if (majorVersion === 3) {
743
779
  const sourceOptions = resolveTailwindV3SourceOptionsFromPatcher(runtimeState.twPatcher);
744
- const sourceSideEntrySource = resolveSourceSideCssEntrySource(file, sourceOptions);
780
+ const sourceSideEntrySource = resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: true });
745
781
  const resolvedEntrySource = cssEntrySource ?? sourceSideEntrySource;
746
782
  if (!resolvedEntrySource) return resolveTailwindV3SourceFromPatcher(runtimeState.twPatcher);
747
783
  const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, sourceOptions);
@@ -752,15 +788,18 @@ async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, fil
752
788
  ...config ? { config } : {}
753
789
  });
754
790
  }
755
- if (!cssEntrySource) return resolveTailwindV4SourceFromPatcher(runtimeState.twPatcher);
791
+ const sourceOptions = tryResolveTailwindV4SourceOptions(runtimeState);
792
+ const shouldPreferSourceSideEntry = shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder"));
793
+ const resolvedEntrySource = (sourceOptions && shouldPreferSourceSideEntry ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0) ?? cssEntrySource;
794
+ if (!resolvedEntrySource) return resolveTailwindV4SourceFromPatcher(runtimeState.twPatcher);
756
795
  return resolveTailwindV4Source({
757
- ...resolveTailwindV4SourceOptionsFromPatcher(runtimeState.twPatcher),
758
- base: cssEntrySource.base,
759
- css: cssEntrySource.css
796
+ ...sourceOptions ?? {},
797
+ base: resolvedEntrySource.base,
798
+ css: resolvedEntrySource.css
760
799
  });
761
800
  }
762
801
  async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions) {
763
- const cssEntrySource = resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions));
802
+ const cssEntrySource = resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions), { removeConfig: majorVersion === 3 });
764
803
  if (majorVersion !== 4 || cssEntrySource && !cssHandlerOptions.isMainChunk) return [await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions)];
765
804
  let sourceOptions;
766
805
  try {
@@ -980,7 +1019,8 @@ async function generateCssByGenerator(options) {
980
1019
  const hasSourceDirectives = hasTailwindSourceDirectives(rawSource);
981
1020
  const hasGeneratedMarkers = hasTailwindGeneratedCssMarkers(rawSource);
982
1021
  const shouldForceGenerateCurrentCss = hasGeneratedCss || hasGeneratedMarkers || hasSourceDirectives || cssHandlerOptions.isMainChunk;
983
- if (generatorOptions.mode === "off" || !SUPPORTED_GENERATOR_MAJOR_VERSIONS.has(majorVersion ?? 0) || generatorOptions.mode === "force" && (!shouldForceGenerateCurrentCss || majorVersion === 3 && !hasSourceDirectives && !hasGeneratedCss && !hasGeneratedMarkers) || generatorOptions.mode !== "force" && majorVersion !== 3 && !hasGeneratedCss || !cssHandlerOptions.isMainChunk && majorVersion !== 3 && generatorOptions.mode !== "force" && !hasGeneratedCss) return;
1022
+ const shouldAutoGenerateCurrentCss = hasGeneratedCss || hasGeneratedMarkers || hasSourceDirectives;
1023
+ if (generatorOptions.mode === "off" || !SUPPORTED_GENERATOR_MAJOR_VERSIONS.has(majorVersion ?? 0) || (generatorOptions.mode === "force" ? !shouldForceGenerateCurrentCss : !shouldAutoGenerateCurrentCss) || generatorOptions.mode === "force" && majorVersion === 3 && !hasSourceDirectives && !hasGeneratedCss && !hasGeneratedMarkers || generatorOptions.mode !== "force" && majorVersion === 3) return;
984
1024
  try {
985
1025
  await runtimeState.patchPromise;
986
1026
  const sources = await resolveGeneratorSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions);
@@ -989,7 +1029,9 @@ async function generateCssByGenerator(options) {
989
1029
  const generatedResults = await Promise.all(sources.map(async (source) => {
990
1030
  return createWeappTailwindcssGenerator(source).generate({
991
1031
  candidates: runtime,
1032
+ scanSources: false,
992
1033
  styleOptions: generatorStyleOptions,
1034
+ tailwindcssV3Compatibility: generatorOptions.tailwindcssV3Compatibility,
993
1035
  target: generatorOptions.target
994
1036
  });
995
1037
  }));
@@ -1036,18 +1078,16 @@ async function generateCssByGenerator(options) {
1036
1078
  source: "generator"
1037
1079
  };
1038
1080
  }
1039
- if (generatorOptions.mode === "force") {
1040
- debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
1041
- let css = stripTailwindBanner(generated.css);
1042
- if (generated.target === "weapp") css = inheritLegacyUnitConvertedDeclarations(css, rawSource);
1043
- css = await appendLegacyCompatCss(css, rawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
1044
- css = await appendLegacyContainerCompatCss(css, rawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
1045
- return {
1046
- css: finalizeMiniProgramGeneratorCss(css, generated.target),
1047
- target: generated.target,
1048
- source: "generator-forced"
1049
- };
1050
- }
1081
+ debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
1082
+ let css = stripTailwindBanner(generated.css);
1083
+ if (generated.target === "weapp") css = inheritLegacyUnitConvertedDeclarations(css, rawSource);
1084
+ css = await appendLegacyCompatCss(css, rawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
1085
+ css = await appendLegacyContainerCompatCss(css, rawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
1086
+ return {
1087
+ css: finalizeMiniProgramGeneratorCss(css, generated.target),
1088
+ target: generated.target,
1089
+ source: generatorOptions.mode === "force" ? "generator-forced" : "generator"
1090
+ };
1051
1091
  } catch (error) {
1052
1092
  if (generatorOptions.mode === "force") throw error;
1053
1093
  debug("tailwind direct css generation failed, fallback to styleHandler: %s %O", file, error);
@@ -1,6 +1,6 @@
1
1
  const require_chunk = require("./chunk-8l464Juk.js");
2
- const require_generator = require("./generator-CZ-JXw6T.js");
3
- const require_recorder = require("./recorder-rn_2v_nd.js");
2
+ const require_generator = require("./generator-mmhXzZnv.js");
3
+ const require_recorder = require("./recorder-GdTJ3QqX.js");
4
4
  let postcss = require("postcss");
5
5
  postcss = require_chunk.__toESM(postcss);
6
6
  let node_path = require("node:path");
@@ -647,13 +647,14 @@ function hasTailwindSourceDirectives(rawSource) {
647
647
  return false;
648
648
  }
649
649
  }
650
- function resolveCssEntrySource(rawSource, base) {
650
+ function resolveCssEntrySource(rawSource, base, options = {}) {
651
651
  try {
652
652
  const root = postcss.default.parse(rawSource);
653
653
  let found = false;
654
654
  let config;
655
655
  let configRequest;
656
656
  let removedConfig = false;
657
+ const removeConfig = options.removeConfig ?? true;
657
658
  root.walk((node) => {
658
659
  if (isTailwindGenerationDirective(node)) found = true;
659
660
  if (node.type === "atrule" && node.name === "config") {
@@ -662,8 +663,10 @@ function resolveCssEntrySource(rawSource, base) {
662
663
  configRequest = configPath;
663
664
  config = node_path.default.isAbsolute(configPath) ? configPath : node_path.default.resolve(base, configPath);
664
665
  }
665
- node.remove();
666
- removedConfig = true;
666
+ if (removeConfig) {
667
+ node.remove();
668
+ removedConfig = true;
669
+ }
667
670
  }
668
671
  });
669
672
  if (!found) return;
@@ -701,17 +704,40 @@ function stripStyleExtension(file) {
701
704
  return file.replace(/[?#].*$/, "").replace(/\.(?:wx|ac|jx|tt|q|c|ty)?ss$/i, "");
702
705
  }
703
706
  function createSourceStylePathCandidates(file, sourceOptions) {
704
- const relativeFile = stripStyleExtension(file);
705
- if (node_path.default.isAbsolute(relativeFile)) return [];
706
707
  const bases = [
707
708
  sourceOptions.projectRoot,
708
709
  sourceOptions.cwd,
709
710
  node_process.default.cwd()
710
711
  ].filter((item) => typeof item === "string" && item.length > 0);
712
+ const strippedFile = stripStyleExtension(file);
713
+ const relativeFiles = /* @__PURE__ */ new Set();
714
+ if (node_path.default.isAbsolute(strippedFile)) for (const base of bases) {
715
+ const relative = node_path.default.relative(base, strippedFile);
716
+ if (!relative || relative.startsWith("..") || node_path.default.isAbsolute(relative)) continue;
717
+ relativeFiles.add(relative);
718
+ const parts = relative.split(node_path.default.sep).filter(Boolean);
719
+ if (parts.length > 1) {
720
+ relativeFiles.add(parts.slice(1).join(node_path.default.sep));
721
+ const distIndex = parts.lastIndexOf("dist");
722
+ if (distIndex >= 0 && distIndex < parts.length - 1) relativeFiles.add([...parts.slice(0, distIndex), ...parts.slice(distIndex + 1)].join(node_path.default.sep));
723
+ }
724
+ }
725
+ else {
726
+ relativeFiles.add(strippedFile);
727
+ const parts = strippedFile.split(/[\\/]/).filter(Boolean);
728
+ if (parts.length > 1) {
729
+ relativeFiles.add(parts.slice(1).join(node_path.default.sep));
730
+ const distIndex = parts.lastIndexOf("dist");
731
+ if (distIndex >= 0 && distIndex < parts.length - 1) relativeFiles.add([...parts.slice(0, distIndex), ...parts.slice(distIndex + 1)].join(node_path.default.sep));
732
+ }
733
+ }
711
734
  const candidates = /* @__PURE__ */ new Set();
712
- for (const base of bases) for (const sourceRoot of ["", "src"]) {
713
- const prefix = sourceRoot ? node_path.default.resolve(base, sourceRoot, relativeFile) : node_path.default.resolve(base, relativeFile);
714
- for (const extension of SOURCE_STYLE_EXTENSIONS) candidates.add(`${prefix}${extension}`);
735
+ for (const relativeFile of relativeFiles) {
736
+ if (!relativeFile || node_path.default.isAbsolute(relativeFile)) continue;
737
+ for (const base of bases) for (const sourceRoot of ["", "src"]) {
738
+ const prefix = sourceRoot ? node_path.default.resolve(base, sourceRoot, relativeFile) : node_path.default.resolve(base, relativeFile);
739
+ for (const extension of SOURCE_STYLE_EXTENSIONS) candidates.add(`${prefix}${extension}`);
740
+ }
715
741
  }
716
742
  return [...candidates];
717
743
  }
@@ -727,13 +753,16 @@ function extractStyleDirectiveSources(source) {
727
753
  if (styleSources.length > 0) return styleSources;
728
754
  return hasTailwindSourceDirectives(source) ? [source] : [];
729
755
  }
730
- function resolveSourceSideCssEntrySource(file, sourceOptions) {
756
+ function shouldResolveSourceSideCssEntry(rawSource) {
757
+ return rawSource.includes("@apply");
758
+ }
759
+ function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {}) {
731
760
  for (const sourceFile of createSourceStylePathCandidates(file, sourceOptions)) {
732
761
  if (!(0, node_fs.existsSync)(sourceFile)) continue;
733
762
  try {
734
763
  const source = (0, node_fs.readFileSync)(sourceFile, "utf8");
735
764
  for (const styleSource of extractStyleDirectiveSources(source)) {
736
- const cssEntrySource = resolveCssEntrySource(styleSource, node_path.default.dirname(sourceFile));
765
+ const cssEntrySource = resolveCssEntrySource(styleSource, node_path.default.dirname(sourceFile), resolveOptions);
737
766
  if (cssEntrySource) return cssEntrySource;
738
767
  }
739
768
  } catch {
@@ -741,11 +770,18 @@ function resolveSourceSideCssEntrySource(file, sourceOptions) {
741
770
  }
742
771
  }
743
772
  }
773
+ function tryResolveTailwindV4SourceOptions(runtimeState) {
774
+ try {
775
+ return require_generator.resolveTailwindV4SourceOptionsFromPatcher(runtimeState.twPatcher);
776
+ } catch {
777
+ return;
778
+ }
779
+ }
744
780
  async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions) {
745
- const cssEntrySource = resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions));
781
+ const cssEntrySource = resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions), { removeConfig: majorVersion === 3 });
746
782
  if (majorVersion === 3) {
747
783
  const sourceOptions = require_generator.resolveTailwindV3SourceOptionsFromPatcher(runtimeState.twPatcher);
748
- const sourceSideEntrySource = resolveSourceSideCssEntrySource(file, sourceOptions);
784
+ const sourceSideEntrySource = resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: true });
749
785
  const resolvedEntrySource = cssEntrySource ?? sourceSideEntrySource;
750
786
  if (!resolvedEntrySource) return require_generator.resolveTailwindV3SourceFromPatcher(runtimeState.twPatcher);
751
787
  const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, sourceOptions);
@@ -756,15 +792,18 @@ async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, fil
756
792
  ...config ? { config } : {}
757
793
  });
758
794
  }
759
- if (!cssEntrySource) return require_generator.resolveTailwindV4SourceFromPatcher(runtimeState.twPatcher);
795
+ const sourceOptions = tryResolveTailwindV4SourceOptions(runtimeState);
796
+ const shouldPreferSourceSideEntry = shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder"));
797
+ const resolvedEntrySource = (sourceOptions && shouldPreferSourceSideEntry ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0) ?? cssEntrySource;
798
+ if (!resolvedEntrySource) return require_generator.resolveTailwindV4SourceFromPatcher(runtimeState.twPatcher);
760
799
  return require_generator.resolveTailwindV4Source({
761
- ...require_generator.resolveTailwindV4SourceOptionsFromPatcher(runtimeState.twPatcher),
762
- base: cssEntrySource.base,
763
- css: cssEntrySource.css
800
+ ...sourceOptions ?? {},
801
+ base: resolvedEntrySource.base,
802
+ css: resolvedEntrySource.css
764
803
  });
765
804
  }
766
805
  async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions) {
767
- const cssEntrySource = resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions));
806
+ const cssEntrySource = resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions), { removeConfig: majorVersion === 3 });
768
807
  if (majorVersion !== 4 || cssEntrySource && !cssHandlerOptions.isMainChunk) return [await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions)];
769
808
  let sourceOptions;
770
809
  try {
@@ -984,7 +1023,8 @@ async function generateCssByGenerator(options) {
984
1023
  const hasSourceDirectives = hasTailwindSourceDirectives(rawSource);
985
1024
  const hasGeneratedMarkers = hasTailwindGeneratedCssMarkers(rawSource);
986
1025
  const shouldForceGenerateCurrentCss = hasGeneratedCss || hasGeneratedMarkers || hasSourceDirectives || cssHandlerOptions.isMainChunk;
987
- if (generatorOptions.mode === "off" || !SUPPORTED_GENERATOR_MAJOR_VERSIONS.has(majorVersion ?? 0) || generatorOptions.mode === "force" && (!shouldForceGenerateCurrentCss || majorVersion === 3 && !hasSourceDirectives && !hasGeneratedCss && !hasGeneratedMarkers) || generatorOptions.mode !== "force" && majorVersion !== 3 && !hasGeneratedCss || !cssHandlerOptions.isMainChunk && majorVersion !== 3 && generatorOptions.mode !== "force" && !hasGeneratedCss) return;
1026
+ const shouldAutoGenerateCurrentCss = hasGeneratedCss || hasGeneratedMarkers || hasSourceDirectives;
1027
+ if (generatorOptions.mode === "off" || !SUPPORTED_GENERATOR_MAJOR_VERSIONS.has(majorVersion ?? 0) || (generatorOptions.mode === "force" ? !shouldForceGenerateCurrentCss : !shouldAutoGenerateCurrentCss) || generatorOptions.mode === "force" && majorVersion === 3 && !hasSourceDirectives && !hasGeneratedCss && !hasGeneratedMarkers || generatorOptions.mode !== "force" && majorVersion === 3) return;
988
1028
  try {
989
1029
  await runtimeState.patchPromise;
990
1030
  const sources = await resolveGeneratorSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions);
@@ -993,7 +1033,9 @@ async function generateCssByGenerator(options) {
993
1033
  const generatedResults = await Promise.all(sources.map(async (source) => {
994
1034
  return require_generator.createWeappTailwindcssGenerator(source).generate({
995
1035
  candidates: runtime,
1036
+ scanSources: false,
996
1037
  styleOptions: generatorStyleOptions,
1038
+ tailwindcssV3Compatibility: generatorOptions.tailwindcssV3Compatibility,
997
1039
  target: generatorOptions.target
998
1040
  });
999
1041
  }));
@@ -1040,18 +1082,16 @@ async function generateCssByGenerator(options) {
1040
1082
  source: "generator"
1041
1083
  };
1042
1084
  }
1043
- if (generatorOptions.mode === "force") {
1044
- debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
1045
- let css = stripTailwindBanner(generated.css);
1046
- if (generated.target === "weapp") css = inheritLegacyUnitConvertedDeclarations(css, rawSource);
1047
- css = await appendLegacyCompatCss(css, rawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
1048
- css = await appendLegacyContainerCompatCss(css, rawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
1049
- return {
1050
- css: finalizeMiniProgramGeneratorCss(css, generated.target),
1051
- target: generated.target,
1052
- source: "generator-forced"
1053
- };
1054
- }
1085
+ debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
1086
+ let css = stripTailwindBanner(generated.css);
1087
+ if (generated.target === "weapp") css = inheritLegacyUnitConvertedDeclarations(css, rawSource);
1088
+ css = await appendLegacyCompatCss(css, rawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
1089
+ css = await appendLegacyContainerCompatCss(css, rawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
1090
+ return {
1091
+ css: finalizeMiniProgramGeneratorCss(css, generated.target),
1092
+ target: generated.target,
1093
+ source: generatorOptions.mode === "force" ? "generator-forced" : "generator"
1094
+ };
1055
1095
  } catch (error) {
1056
1096
  if (generatorOptions.mode === "force") throw error;
1057
1097
  debug("tailwind direct css generation failed, fallback to styleHandler: %s %O", file, error);