weapp-tailwindcss 2.9.2 → 2.10.0

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 (42) hide show
  1. package/README.md +13 -9
  2. package/dist/cache/index.d.ts +5 -2
  3. package/dist/cli.js +5 -4
  4. package/dist/cli.mjs +5 -4
  5. package/dist/constants--OCCPvZ8.mjs +36 -0
  6. package/dist/constants-9jsALkux.js +42 -0
  7. package/dist/css-macro/constants.d.ts +14 -0
  8. package/dist/css-macro/index.d.ts +15 -0
  9. package/dist/css-macro/index.js +36 -0
  10. package/dist/css-macro/index.mjs +30 -0
  11. package/dist/css-macro/postcss.d.ts +5 -0
  12. package/dist/css-macro/postcss.js +35 -0
  13. package/dist/css-macro/postcss.mjs +33 -0
  14. package/dist/defaults.js +1 -1
  15. package/dist/defaults.mjs +1 -1
  16. package/dist/defu-R3SAEzGq.mjs +43 -0
  17. package/dist/defu-d2wgbAKv.js +45 -0
  18. package/dist/gulp.js +19 -14
  19. package/dist/gulp.mjs +19 -14
  20. package/dist/index.js +8 -7
  21. package/dist/index.mjs +8 -7
  22. package/dist/{options-e1a9fdd3.mjs → options-1ejnE5kK.mjs} +53 -56
  23. package/dist/{options-9dd8de2e.js → options-jeQuZCU1.js} +57 -59
  24. package/dist/postcss/index.d.ts +2 -2
  25. package/dist/{postcss-8d7f67b4.js → postcss-03jfy6ZA.js} +1 -1
  26. package/dist/{postcss-55ed4d42.mjs → postcss-GEOOjC-4.mjs} +1 -1
  27. package/dist/postcss.js +2 -2
  28. package/dist/postcss.mjs +2 -2
  29. package/dist/replace.js +1 -1
  30. package/dist/replace.mjs +1 -1
  31. package/dist/types.d.ts +2 -1
  32. package/dist/vite.js +115 -110
  33. package/dist/vite.mjs +115 -110
  34. package/dist/webpack.js +20 -17
  35. package/dist/webpack.mjs +20 -17
  36. package/package.json +51 -37
  37. /package/dist/{defaults-b7341550.js → defaults-0O-zKoXE.js} +0 -0
  38. /package/dist/{defaults-d2c66d23.mjs → defaults-dz6xGhOP.mjs} +0 -0
  39. /package/dist/{index-84c7aa87.mjs → index-06BoOZig.mjs} +0 -0
  40. /package/dist/{index-aede98ce.js → index-z25r_Htj.js} +0 -0
  41. /package/dist/{shared-283aac78.mjs → shared-S0v7ZvWs.mjs} +0 -0
  42. /package/dist/{shared-8b9be5f0.js → shared-nXoJWFdz.js} +0 -0
package/dist/vite.js CHANGED
@@ -2,20 +2,21 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var options = require('./options-9dd8de2e.js');
6
- var postcss = require('./postcss-8d7f67b4.js');
7
- var defaults = require('./defaults-b7341550.js');
8
- var index = require('./index-aede98ce.js');
5
+ var options = require('./options-jeQuZCU1.js');
6
+ var postcss = require('./postcss-03jfy6ZA.js');
7
+ var defaults = require('./defaults-0O-zKoXE.js');
8
+ var index = require('./index-z25r_Htj.js');
9
9
  require('micromatch');
10
10
  require('magic-string');
11
11
  require('./replace.js');
12
12
  require('@weapp-core/escape');
13
13
  require('@ast-core/escape');
14
- require('./shared-8b9be5f0.js');
14
+ require('./shared-nXoJWFdz.js');
15
15
  require('@weapp-core/regex');
16
16
  require('@babel/generator');
17
17
  require('@babel/parser');
18
18
  require('@babel/traverse');
19
+ require('./defu-d2wgbAKv.js');
19
20
  require('@babel/types');
20
21
  require('htmlparser2');
21
22
  require('postcss');
@@ -36,7 +37,7 @@ function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
36
37
  options$1.customReplaceDictionary = 'simple';
37
38
  }
38
39
  const opts = options.getOptions(options$1);
39
- const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache } = opts;
40
+ const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache, tailwindcssBasedir } = opts;
40
41
  if (disabled) {
41
42
  return;
42
43
  }
@@ -47,115 +48,119 @@ function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
47
48
  name: postcss.vitePluginName,
48
49
  enforce: 'post',
49
50
  generateBundle(opt, bundle) {
50
- debug('start');
51
- onStart();
52
- const entries = Object.entries(bundle);
53
- const groupedEntries = defaults.getGroupedEntries(entries, opts);
54
- const runtimeSet = twPatcher.getClassSet();
55
- setMangleRuntimeSet(runtimeSet);
56
- debug('get runtimeSet, class count: %d', runtimeSet.size);
57
- if (Array.isArray(groupedEntries.html)) {
58
- let noCachedCount = 0;
59
- for (let i = 0; i < groupedEntries.html.length; i++) {
60
- const [file, originalSource] = groupedEntries.html[i];
61
- const oldVal = originalSource.source.toString();
62
- const hash = cache.computeHash(oldVal);
63
- cache.calcHashValueChanged(file, hash);
64
- cache.process(file, () => {
65
- const source = cache.get(file);
66
- if (source) {
67
- originalSource.source = source;
68
- debug('html cache hit: %s', file);
69
- }
70
- else {
71
- return false;
72
- }
73
- }, () => {
74
- originalSource.source = templateHandler(oldVal, {
75
- runtimeSet
51
+ return options.__awaiter(this, void 0, void 0, function* () {
52
+ debug('start');
53
+ onStart();
54
+ const entries = Object.entries(bundle);
55
+ const groupedEntries = defaults.getGroupedEntries(entries, opts);
56
+ const runtimeSet = twPatcher.getClassSet({
57
+ basedir: tailwindcssBasedir
58
+ });
59
+ setMangleRuntimeSet(runtimeSet);
60
+ debug('get runtimeSet, class count: %d', runtimeSet.size);
61
+ if (Array.isArray(groupedEntries.html)) {
62
+ let noCachedCount = 0;
63
+ for (let i = 0; i < groupedEntries.html.length; i++) {
64
+ const [file, originalSource] = groupedEntries.html[i];
65
+ const oldVal = originalSource.source.toString();
66
+ const hash = cache.computeHash(oldVal);
67
+ cache.calcHashValueChanged(file, hash);
68
+ yield cache.process(file, () => {
69
+ const source = cache.get(file);
70
+ if (source) {
71
+ originalSource.source = source;
72
+ debug('html cache hit: %s', file);
73
+ }
74
+ else {
75
+ return false;
76
+ }
77
+ }, () => {
78
+ originalSource.source = templateHandler(oldVal, {
79
+ runtimeSet
80
+ });
81
+ onUpdate(file, oldVal, originalSource.source);
82
+ debug('html handle: %s', file);
83
+ noCachedCount++;
84
+ return {
85
+ key: file,
86
+ source: originalSource.source
87
+ };
76
88
  });
77
- onUpdate(file, oldVal, originalSource.source);
78
- debug('html handle: %s', file);
79
- noCachedCount++;
80
- return {
81
- key: file,
82
- source: originalSource.source
83
- };
84
- });
89
+ }
90
+ debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
85
91
  }
86
- debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
87
- }
88
- if (Array.isArray(groupedEntries.js)) {
89
- let noCachedCount = 0;
90
- for (let i = 0; i < groupedEntries.js.length; i++) {
91
- const [file, originalSource] = groupedEntries.js[i];
92
- const rawSource = originalSource.code;
93
- const hash = cache.computeHash(rawSource);
94
- cache.calcHashValueChanged(file, hash);
95
- cache.process(file, () => {
96
- const source = cache.get(file);
97
- if (source) {
98
- originalSource.code = source;
99
- debug('js cache hit: %s', file);
100
- }
101
- else {
102
- return false;
103
- }
104
- }, () => {
105
- const mapFilename = file + '.map';
106
- const hasMap = Boolean(bundle[mapFilename]);
107
- const { code, map } = jsHandler(rawSource, runtimeSet, {
108
- generateMap: hasMap
92
+ if (Array.isArray(groupedEntries.js)) {
93
+ let noCachedCount = 0;
94
+ for (let i = 0; i < groupedEntries.js.length; i++) {
95
+ const [file, originalSource] = groupedEntries.js[i];
96
+ const rawSource = originalSource.code;
97
+ const hash = cache.computeHash(rawSource);
98
+ cache.calcHashValueChanged(file, hash);
99
+ yield cache.process(file, () => {
100
+ const source = cache.get(file);
101
+ if (source) {
102
+ originalSource.code = source;
103
+ debug('js cache hit: %s', file);
104
+ }
105
+ else {
106
+ return false;
107
+ }
108
+ }, () => {
109
+ const mapFilename = file + '.map';
110
+ const hasMap = Boolean(bundle[mapFilename]);
111
+ const { code, map } = jsHandler(rawSource, runtimeSet, {
112
+ generateMap: hasMap
113
+ });
114
+ originalSource.code = code;
115
+ onUpdate(file, rawSource, code);
116
+ debug('js handle: %s', file);
117
+ noCachedCount++;
118
+ if (hasMap && map) {
119
+ bundle[mapFilename].source = map.toString();
120
+ }
121
+ return {
122
+ key: file,
123
+ source: code
124
+ };
109
125
  });
110
- originalSource.code = code;
111
- onUpdate(file, rawSource, code);
112
- debug('js handle: %s', file);
113
- noCachedCount++;
114
- if (hasMap && map) {
115
- bundle[mapFilename].source = map.toString();
116
- }
117
- return {
118
- key: file,
119
- source: code
120
- };
121
- });
126
+ }
127
+ debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
122
128
  }
123
- debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
124
- }
125
- if (Array.isArray(groupedEntries.css)) {
126
- let noCachedCount = 0;
127
- for (let i = 0; i < groupedEntries.css.length; i++) {
128
- const [file, originalSource] = groupedEntries.css[i];
129
- const rawSource = originalSource.source.toString();
130
- const hash = cache.computeHash(rawSource);
131
- cache.calcHashValueChanged(file, hash);
132
- cache.process(file, () => {
133
- const source = cache.get(file);
134
- if (source) {
135
- originalSource.source = source;
136
- debug('css cache hit: %s', file);
137
- }
138
- else {
139
- return false;
140
- }
141
- }, () => {
142
- const css = styleHandler(rawSource, {
143
- isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType)
144
- });
145
- originalSource.source = css;
146
- onUpdate(file, rawSource, css);
147
- debug('css handle: %s', file);
148
- noCachedCount++;
149
- return {
150
- key: file,
151
- source: css
152
- };
153
- });
129
+ if (Array.isArray(groupedEntries.css)) {
130
+ let noCachedCount = 0;
131
+ for (let i = 0; i < groupedEntries.css.length; i++) {
132
+ const [file, originalSource] = groupedEntries.css[i];
133
+ const rawSource = originalSource.source.toString();
134
+ const hash = cache.computeHash(rawSource);
135
+ cache.calcHashValueChanged(file, hash);
136
+ yield cache.process(file, () => {
137
+ const source = cache.get(file);
138
+ if (source) {
139
+ originalSource.source = source;
140
+ debug('css cache hit: %s', file);
141
+ }
142
+ else {
143
+ return false;
144
+ }
145
+ }, () => options.__awaiter(this, void 0, void 0, function* () {
146
+ const css = yield styleHandler(rawSource, {
147
+ isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType)
148
+ });
149
+ originalSource.source = css;
150
+ onUpdate(file, rawSource, css);
151
+ debug('css handle: %s', file);
152
+ noCachedCount++;
153
+ return {
154
+ key: file,
155
+ source: css
156
+ };
157
+ }));
158
+ }
159
+ debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
154
160
  }
155
- debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
156
- }
157
- onEnd();
158
- debug('end');
161
+ onEnd();
162
+ debug('end');
163
+ });
159
164
  }
160
165
  };
161
166
  }
package/dist/vite.mjs CHANGED
@@ -1,17 +1,18 @@
1
- import { g as getOptions, a as createTailwindcssPatcher } from './options-e1a9fdd3.mjs';
2
- import { v as vitePluginName } from './postcss-55ed4d42.mjs';
3
- import { g as getGroupedEntries } from './defaults-d2c66d23.mjs';
4
- import { c as createDebug } from './index-84c7aa87.mjs';
1
+ import { g as getOptions, a as createTailwindcssPatcher, _ as __awaiter } from './options-1ejnE5kK.mjs';
2
+ import { v as vitePluginName } from './postcss-GEOOjC-4.mjs';
3
+ import { g as getGroupedEntries } from './defaults-dz6xGhOP.mjs';
4
+ import { c as createDebug } from './index-06BoOZig.mjs';
5
5
  import 'micromatch';
6
6
  import 'magic-string';
7
7
  import './replace.mjs';
8
8
  import '@weapp-core/escape';
9
9
  import '@ast-core/escape';
10
- import './shared-283aac78.mjs';
10
+ import './shared-S0v7ZvWs.mjs';
11
11
  import '@weapp-core/regex';
12
12
  import '@babel/generator';
13
13
  import '@babel/parser';
14
14
  import '@babel/traverse';
15
+ import './defu-R3SAEzGq.mjs';
15
16
  import '@babel/types';
16
17
  import 'htmlparser2';
17
18
  import 'postcss';
@@ -32,7 +33,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
32
33
  options.customReplaceDictionary = 'simple';
33
34
  }
34
35
  const opts = getOptions(options);
35
- const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache } = opts;
36
+ const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache, tailwindcssBasedir } = opts;
36
37
  if (disabled) {
37
38
  return;
38
39
  }
@@ -43,115 +44,119 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
43
44
  name: vitePluginName,
44
45
  enforce: 'post',
45
46
  generateBundle(opt, bundle) {
46
- debug('start');
47
- onStart();
48
- const entries = Object.entries(bundle);
49
- const groupedEntries = getGroupedEntries(entries, opts);
50
- const runtimeSet = twPatcher.getClassSet();
51
- setMangleRuntimeSet(runtimeSet);
52
- debug('get runtimeSet, class count: %d', runtimeSet.size);
53
- if (Array.isArray(groupedEntries.html)) {
54
- let noCachedCount = 0;
55
- for (let i = 0; i < groupedEntries.html.length; i++) {
56
- const [file, originalSource] = groupedEntries.html[i];
57
- const oldVal = originalSource.source.toString();
58
- const hash = cache.computeHash(oldVal);
59
- cache.calcHashValueChanged(file, hash);
60
- cache.process(file, () => {
61
- const source = cache.get(file);
62
- if (source) {
63
- originalSource.source = source;
64
- debug('html cache hit: %s', file);
65
- }
66
- else {
67
- return false;
68
- }
69
- }, () => {
70
- originalSource.source = templateHandler(oldVal, {
71
- runtimeSet
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ debug('start');
49
+ onStart();
50
+ const entries = Object.entries(bundle);
51
+ const groupedEntries = getGroupedEntries(entries, opts);
52
+ const runtimeSet = twPatcher.getClassSet({
53
+ basedir: tailwindcssBasedir
54
+ });
55
+ setMangleRuntimeSet(runtimeSet);
56
+ debug('get runtimeSet, class count: %d', runtimeSet.size);
57
+ if (Array.isArray(groupedEntries.html)) {
58
+ let noCachedCount = 0;
59
+ for (let i = 0; i < groupedEntries.html.length; i++) {
60
+ const [file, originalSource] = groupedEntries.html[i];
61
+ const oldVal = originalSource.source.toString();
62
+ const hash = cache.computeHash(oldVal);
63
+ cache.calcHashValueChanged(file, hash);
64
+ yield cache.process(file, () => {
65
+ const source = cache.get(file);
66
+ if (source) {
67
+ originalSource.source = source;
68
+ debug('html cache hit: %s', file);
69
+ }
70
+ else {
71
+ return false;
72
+ }
73
+ }, () => {
74
+ originalSource.source = templateHandler(oldVal, {
75
+ runtimeSet
76
+ });
77
+ onUpdate(file, oldVal, originalSource.source);
78
+ debug('html handle: %s', file);
79
+ noCachedCount++;
80
+ return {
81
+ key: file,
82
+ source: originalSource.source
83
+ };
72
84
  });
73
- onUpdate(file, oldVal, originalSource.source);
74
- debug('html handle: %s', file);
75
- noCachedCount++;
76
- return {
77
- key: file,
78
- source: originalSource.source
79
- };
80
- });
85
+ }
86
+ debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
81
87
  }
82
- debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
83
- }
84
- if (Array.isArray(groupedEntries.js)) {
85
- let noCachedCount = 0;
86
- for (let i = 0; i < groupedEntries.js.length; i++) {
87
- const [file, originalSource] = groupedEntries.js[i];
88
- const rawSource = originalSource.code;
89
- const hash = cache.computeHash(rawSource);
90
- cache.calcHashValueChanged(file, hash);
91
- cache.process(file, () => {
92
- const source = cache.get(file);
93
- if (source) {
94
- originalSource.code = source;
95
- debug('js cache hit: %s', file);
96
- }
97
- else {
98
- return false;
99
- }
100
- }, () => {
101
- const mapFilename = file + '.map';
102
- const hasMap = Boolean(bundle[mapFilename]);
103
- const { code, map } = jsHandler(rawSource, runtimeSet, {
104
- generateMap: hasMap
88
+ if (Array.isArray(groupedEntries.js)) {
89
+ let noCachedCount = 0;
90
+ for (let i = 0; i < groupedEntries.js.length; i++) {
91
+ const [file, originalSource] = groupedEntries.js[i];
92
+ const rawSource = originalSource.code;
93
+ const hash = cache.computeHash(rawSource);
94
+ cache.calcHashValueChanged(file, hash);
95
+ yield cache.process(file, () => {
96
+ const source = cache.get(file);
97
+ if (source) {
98
+ originalSource.code = source;
99
+ debug('js cache hit: %s', file);
100
+ }
101
+ else {
102
+ return false;
103
+ }
104
+ }, () => {
105
+ const mapFilename = file + '.map';
106
+ const hasMap = Boolean(bundle[mapFilename]);
107
+ const { code, map } = jsHandler(rawSource, runtimeSet, {
108
+ generateMap: hasMap
109
+ });
110
+ originalSource.code = code;
111
+ onUpdate(file, rawSource, code);
112
+ debug('js handle: %s', file);
113
+ noCachedCount++;
114
+ if (hasMap && map) {
115
+ bundle[mapFilename].source = map.toString();
116
+ }
117
+ return {
118
+ key: file,
119
+ source: code
120
+ };
105
121
  });
106
- originalSource.code = code;
107
- onUpdate(file, rawSource, code);
108
- debug('js handle: %s', file);
109
- noCachedCount++;
110
- if (hasMap && map) {
111
- bundle[mapFilename].source = map.toString();
112
- }
113
- return {
114
- key: file,
115
- source: code
116
- };
117
- });
122
+ }
123
+ debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
118
124
  }
119
- debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
120
- }
121
- if (Array.isArray(groupedEntries.css)) {
122
- let noCachedCount = 0;
123
- for (let i = 0; i < groupedEntries.css.length; i++) {
124
- const [file, originalSource] = groupedEntries.css[i];
125
- const rawSource = originalSource.source.toString();
126
- const hash = cache.computeHash(rawSource);
127
- cache.calcHashValueChanged(file, hash);
128
- cache.process(file, () => {
129
- const source = cache.get(file);
130
- if (source) {
131
- originalSource.source = source;
132
- debug('css cache hit: %s', file);
133
- }
134
- else {
135
- return false;
136
- }
137
- }, () => {
138
- const css = styleHandler(rawSource, {
139
- isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType)
140
- });
141
- originalSource.source = css;
142
- onUpdate(file, rawSource, css);
143
- debug('css handle: %s', file);
144
- noCachedCount++;
145
- return {
146
- key: file,
147
- source: css
148
- };
149
- });
125
+ if (Array.isArray(groupedEntries.css)) {
126
+ let noCachedCount = 0;
127
+ for (let i = 0; i < groupedEntries.css.length; i++) {
128
+ const [file, originalSource] = groupedEntries.css[i];
129
+ const rawSource = originalSource.source.toString();
130
+ const hash = cache.computeHash(rawSource);
131
+ cache.calcHashValueChanged(file, hash);
132
+ yield cache.process(file, () => {
133
+ const source = cache.get(file);
134
+ if (source) {
135
+ originalSource.source = source;
136
+ debug('css cache hit: %s', file);
137
+ }
138
+ else {
139
+ return false;
140
+ }
141
+ }, () => __awaiter(this, void 0, void 0, function* () {
142
+ const css = yield styleHandler(rawSource, {
143
+ isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType)
144
+ });
145
+ originalSource.source = css;
146
+ onUpdate(file, rawSource, css);
147
+ debug('css handle: %s', file);
148
+ noCachedCount++;
149
+ return {
150
+ key: file,
151
+ source: css
152
+ };
153
+ }));
154
+ }
155
+ debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
150
156
  }
151
- debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
152
- }
153
- onEnd();
154
- debug('end');
157
+ onEnd();
158
+ debug('end');
159
+ });
155
160
  }
156
161
  };
157
162
  }