unplugin-tailwindcss-mangle 2.1.0 → 2.2.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.
package/dist/esbuild.cjs CHANGED
@@ -1,18 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:fs');
5
4
  require('node:path');
6
- require('@tailwindcss-mangle/shared');
7
- require('@tailwindcss-mangle/config');
8
- require('fast-sort');
9
- require('modern-ahocorasick');
10
5
  require('node:fs/promises');
11
- require('micromatch');
12
6
  require('unplugin');
13
7
  require('@tailwindcss-mangle/core');
14
8
  require('magic-string');
15
- require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
9
+ require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
10
+ require('@tailwindcss-mangle/shared');
16
11
 
17
12
  const esbuild = index.esbuild;
18
13
 
@@ -0,0 +1,6 @@
1
+ import * as esbuild from 'esbuild';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
+
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => esbuild.Plugin;
5
+
6
+ export { _default as default };
@@ -0,0 +1,6 @@
1
+ import * as esbuild from 'esbuild';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
+
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => esbuild.Plugin;
5
+
6
+ export { _default as default };
package/dist/esbuild.mjs CHANGED
@@ -1,16 +1,11 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:fs';
3
2
  import 'node:path';
4
- import '@tailwindcss-mangle/shared';
5
- import '@tailwindcss-mangle/config';
6
- import 'fast-sort';
7
- import 'modern-ahocorasick';
8
3
  import 'node:fs/promises';
9
- import 'micromatch';
10
4
  import 'unplugin';
11
5
  import '@tailwindcss-mangle/core';
12
6
  import 'magic-string';
13
- import './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
7
+ import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
8
+ import '@tailwindcss-mangle/shared';
14
9
 
15
10
  const esbuild = unplugin.esbuild;
16
11
 
package/dist/index.cjs CHANGED
@@ -1,164 +1,27 @@
1
1
  'use strict';
2
2
 
3
3
  const path = require('node:path');
4
- const fs$1 = require('node:fs/promises');
4
+ const fs = require('node:fs/promises');
5
5
  const unplugin$1 = require('unplugin');
6
6
  const core = require('@tailwindcss-mangle/core');
7
7
  const MagicString = require('magic-string');
8
- const fs = require('node:fs');
9
- const shared = require('@tailwindcss-mangle/shared');
10
- const config = require('@tailwindcss-mangle/config');
11
- const fastSort = require('fast-sort');
12
- const AhoCorasick = require('modern-ahocorasick');
13
- const utils = require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
14
- require('micromatch');
8
+ const utils = require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
9
+ require('@tailwindcss-mangle/shared');
15
10
 
16
11
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
17
12
 
18
- const fs__default$1 = /*#__PURE__*/_interopDefaultCompat(fs$1);
19
- const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
20
13
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
21
- const AhoCorasick__default = /*#__PURE__*/_interopDefaultCompat(AhoCorasick);
22
-
23
- function isObject(value) {
24
- return value !== null && typeof value === "object";
25
- }
26
- function _defu(baseObject, defaults, namespace = ".", merger) {
27
- if (!isObject(defaults)) {
28
- return _defu(baseObject, {}, namespace, merger);
29
- }
30
- const object = Object.assign({}, defaults);
31
- for (const key in baseObject) {
32
- if (key === "__proto__" || key === "constructor") {
33
- continue;
34
- }
35
- const value = baseObject[key];
36
- if (value === null || value === void 0) {
37
- continue;
38
- }
39
- if (merger && merger(object, key, value, namespace)) {
40
- continue;
41
- }
42
- if (Array.isArray(value) && Array.isArray(object[key])) {
43
- object[key] = [...value, ...object[key]];
44
- } else if (isObject(value) && isObject(object[key])) {
45
- object[key] = _defu(
46
- value,
47
- object[key],
48
- (namespace ? `${namespace}.` : "") + key.toString(),
49
- merger
50
- );
51
- } else {
52
- object[key] = value;
53
- }
54
- }
55
- return object;
56
- }
57
- function createDefu(merger) {
58
- return (...arguments_) => (
59
- // eslint-disable-next-line unicorn/no-array-reduce
60
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
61
- );
62
- }
63
- const defu = createDefu();
64
-
65
- class Context {
66
- constructor(opts = {}) {
67
- this.options = opts;
68
- this.classSet = /* @__PURE__ */ new Set();
69
- this.replaceMap = /* @__PURE__ */ new Map();
70
- this.includeMatcher = utils.createGlobMatcher(this.options.include, true);
71
- this.excludeMatcher = utils.createGlobMatcher(this.options.exclude, false);
72
- this.classGenerator = new shared.ClassGenerator(this.options.classGenerator);
73
- this.useAC = false;
74
- }
75
- mergeOptions(opts) {
76
- this.options = defu(this.options, opts);
77
- this.includeMatcher = utils.createGlobMatcher(this.options.include, true);
78
- this.excludeMatcher = utils.createGlobMatcher(this.options.exclude, false);
79
- this.classGenerator = new shared.ClassGenerator(this.options.classGenerator);
80
- }
81
- isInclude(file) {
82
- return this.includeMatcher(file) && !this.excludeMatcher(file);
83
- }
84
- currentMangleClassFilter(className) {
85
- return (this.options.mangleClassFilter ?? shared.defaultMangleClassFilter)(className);
86
- }
87
- getClassSet() {
88
- return this.classSet;
89
- }
90
- getReplaceMap() {
91
- return this.replaceMap;
92
- }
93
- addToUsedBy(key, file) {
94
- const hit = this.classGenerator.newClassMap[key];
95
- if (hit) {
96
- hit.usedBy.add(file);
97
- }
98
- }
99
- search(str) {
100
- const arr = this.ahoCorasick?.search(str) ?? [];
101
- const map = /* @__PURE__ */ new Map();
102
- for (const [end, classNames] of arr) {
103
- for (const className of classNames) {
104
- if (map.has(className)) {
105
- const v = map.get(className);
106
- if (v) {
107
- v.push([end - className.length + 1, end + 1]);
108
- }
109
- } else {
110
- map.set(className, [[end - className.length + 1, end + 1]]);
111
- }
112
- }
113
- }
114
- return {
115
- map,
116
- arr: fastSort.sort([...map.entries()]).desc((x) => x[0].length)
117
- };
118
- }
119
- async initConfig(cwd) {
120
- const { config: config$1, cwd: configCwd } = await config.getConfig(cwd);
121
- const mangleConfig = config$1?.mangle;
122
- this.mergeOptions(mangleConfig);
123
- let jsonPath = this.options.classListPath ?? path.resolve(process.cwd(), config$1?.patch?.output?.filename);
124
- if (!path.isAbsolute(jsonPath)) {
125
- jsonPath = path.resolve(configCwd ?? process.cwd(), jsonPath);
126
- }
127
- if (jsonPath && fs__default.existsSync(jsonPath)) {
128
- const rawClassList = fs__default.readFileSync(jsonPath, "utf8");
129
- const list = JSON.parse(rawClassList);
130
- const classList = fastSort.sort(list).desc((c) => c.length);
131
- for (const className of classList) {
132
- if (this.currentMangleClassFilter(className)) {
133
- this.classSet.add(className);
134
- }
135
- }
136
- }
137
- const keywords = [];
138
- for (const cls of this.classSet) {
139
- this.classGenerator.generateClassName(cls);
140
- keywords.push(cls);
141
- }
142
- this.ahoCorasick = new AhoCorasick__default(keywords);
143
- for (const x of Object.entries(this.classGenerator.newClassMap)) {
144
- this.replaceMap.set(x[0], x[1].name);
145
- }
146
- return config$1;
147
- }
148
- }
14
+ const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
149
15
 
150
16
  const unplugin = unplugin$1.createUnplugin((options) => {
151
- const ctx = new Context(options);
152
- if (ctx.options.disabled) {
153
- return {
154
- name: utils.pluginName
155
- };
156
- }
17
+ const ctx = new core.Context();
157
18
  return {
158
19
  name: utils.pluginName,
159
20
  enforce: "pre",
160
21
  async buildStart() {
161
- await ctx.initConfig();
22
+ await ctx.initConfig({
23
+ mangleOptions: options
24
+ });
162
25
  },
163
26
  transformInclude(id) {
164
27
  return ctx.isInclude(id);
@@ -166,41 +29,17 @@ const unplugin = unplugin$1.createUnplugin((options) => {
166
29
  transform(code, id) {
167
30
  const s = new MagicString__default(code);
168
31
  const replaceMap = ctx.getReplaceMap();
169
- if (/\.[jt]sx?$/.test(id)) {
170
- return core.preProcessJs({
171
- code: s,
172
- replaceMap,
173
- addToUsedBy: ctx.addToUsedBy.bind(ctx),
174
- id
175
- });
176
- } else if (ctx.useAC) {
177
- const { arr } = ctx.search(code);
178
- const markArr = [];
179
- for (const [cls, ranges] of arr) {
180
- for (const [start, end] of ranges) {
181
- const value = replaceMap.get(cls);
182
- if (value) {
183
- let flag = true;
184
- for (const [ps, pe] of markArr) {
185
- if (start > ps && start < pe || end < pe && end > start) {
186
- flag = false;
187
- break;
188
- }
189
- }
190
- if (flag) {
191
- markArr.push([start, end]);
192
- s.update(start, end, value);
193
- }
194
- }
195
- }
196
- }
197
- return s.toString();
198
- } else {
199
- for (const [key, value] of replaceMap) {
200
- code = code.replaceAll(key, value);
201
- }
202
- return code;
203
- }
32
+ return /\.[jt]sx?$/.test(id) ? core.preProcessJs({
33
+ code: s,
34
+ replaceMap,
35
+ ctx,
36
+ id
37
+ }) : core.preProcessRawCode({
38
+ code,
39
+ ctx,
40
+ replaceMap,
41
+ id
42
+ });
204
43
  },
205
44
  vite: {
206
45
  generateBundle: {
@@ -213,7 +52,7 @@ const unplugin = unplugin$1.createUnplugin((options) => {
213
52
  const { css } = await core.cssHandler(cssSource.source.toString(), {
214
53
  file,
215
54
  replaceMap,
216
- classGenerator: ctx.classGenerator
55
+ ctx
217
56
  });
218
57
  cssSource.source = css;
219
58
  }
@@ -238,7 +77,7 @@ const unplugin = unplugin$1.createUnplugin((options) => {
238
77
  const [file, chunk] = groupedEntries.js[i];
239
78
  const code = core.jsHandler(chunk.source().toString(), {
240
79
  replaceMap,
241
- classGenerator: ctx.classGenerator
80
+ ctx
242
81
  }).code;
243
82
  if (code) {
244
83
  const source = new ConcatSource(code);
@@ -252,7 +91,7 @@ const unplugin = unplugin$1.createUnplugin((options) => {
252
91
  const { css } = await core.cssHandler(cssSource.source().toString(), {
253
92
  replaceMap,
254
93
  file,
255
- classGenerator: ctx.classGenerator
94
+ ctx
256
95
  });
257
96
  const source = new ConcatSource(css);
258
97
  compilation.updateAsset(file, source);
@@ -262,7 +101,7 @@ const unplugin = unplugin$1.createUnplugin((options) => {
262
101
  for (let i = 0; i < groupedEntries.html.length; i++) {
263
102
  const [file, asset] = groupedEntries.html[i];
264
103
  const html = core.htmlHandler(asset.source().toString(), {
265
- classGenerator: ctx.classGenerator,
104
+ ctx,
266
105
  replaceMap
267
106
  });
268
107
  const source = new ConcatSource(html);
@@ -290,7 +129,7 @@ const unplugin = unplugin$1.createUnplugin((options) => {
290
129
  null,
291
130
  opts.loose ? 2 : 0
292
131
  );
293
- await fs__default$1.writeFile(opts.filename, output, "utf8");
132
+ await fs__default.writeFile(opts.filename, output, "utf8");
294
133
  console.log(`\u2728 ${opts.filename} generated!`);
295
134
  }
296
135
  }
@@ -0,0 +1,6 @@
1
+ import * as _unplugin from 'unplugin';
2
+ import { MangleUserConfig } from '@tailwindcss-mangle/config';
3
+
4
+ declare const unplugin: _unplugin.UnpluginInstance<MangleUserConfig, boolean>;
5
+
6
+ export { unplugin as default };
@@ -0,0 +1,6 @@
1
+ import * as _unplugin from 'unplugin';
2
+ import { MangleUserConfig } from '@tailwindcss-mangle/config';
3
+
4
+ declare const unplugin: _unplugin.UnpluginInstance<MangleUserConfig, boolean>;
5
+
6
+ export { unplugin as default };
package/dist/index.mjs CHANGED
@@ -1,155 +1,20 @@
1
- import { resolve, isAbsolute, dirname } from 'node:path';
2
- import fs$1 from 'node:fs/promises';
1
+ import { dirname } from 'node:path';
2
+ import fs from 'node:fs/promises';
3
3
  import { createUnplugin } from 'unplugin';
4
- import { preProcessJs, cssHandler, jsHandler, htmlHandler } from '@tailwindcss-mangle/core';
4
+ import { Context, preProcessJs, preProcessRawCode, cssHandler, jsHandler, htmlHandler } from '@tailwindcss-mangle/core';
5
5
  import MagicString from 'magic-string';
6
- import fs from 'node:fs';
7
- import { ClassGenerator, defaultMangleClassFilter } from '@tailwindcss-mangle/shared';
8
- import { getConfig } from '@tailwindcss-mangle/config';
9
- import { sort } from 'fast-sort';
10
- import AhoCorasick from 'modern-ahocorasick';
11
- import { c as createGlobMatcher, p as pluginName, g as getGroupedEntries, e as ensureDir } from './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
12
- import 'micromatch';
13
-
14
- function isObject(value) {
15
- return value !== null && typeof value === "object";
16
- }
17
- function _defu(baseObject, defaults, namespace = ".", merger) {
18
- if (!isObject(defaults)) {
19
- return _defu(baseObject, {}, namespace, merger);
20
- }
21
- const object = Object.assign({}, defaults);
22
- for (const key in baseObject) {
23
- if (key === "__proto__" || key === "constructor") {
24
- continue;
25
- }
26
- const value = baseObject[key];
27
- if (value === null || value === void 0) {
28
- continue;
29
- }
30
- if (merger && merger(object, key, value, namespace)) {
31
- continue;
32
- }
33
- if (Array.isArray(value) && Array.isArray(object[key])) {
34
- object[key] = [...value, ...object[key]];
35
- } else if (isObject(value) && isObject(object[key])) {
36
- object[key] = _defu(
37
- value,
38
- object[key],
39
- (namespace ? `${namespace}.` : "") + key.toString(),
40
- merger
41
- );
42
- } else {
43
- object[key] = value;
44
- }
45
- }
46
- return object;
47
- }
48
- function createDefu(merger) {
49
- return (...arguments_) => (
50
- // eslint-disable-next-line unicorn/no-array-reduce
51
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
52
- );
53
- }
54
- const defu = createDefu();
55
-
56
- class Context {
57
- constructor(opts = {}) {
58
- this.options = opts;
59
- this.classSet = /* @__PURE__ */ new Set();
60
- this.replaceMap = /* @__PURE__ */ new Map();
61
- this.includeMatcher = createGlobMatcher(this.options.include, true);
62
- this.excludeMatcher = createGlobMatcher(this.options.exclude, false);
63
- this.classGenerator = new ClassGenerator(this.options.classGenerator);
64
- this.useAC = false;
65
- }
66
- mergeOptions(opts) {
67
- this.options = defu(this.options, opts);
68
- this.includeMatcher = createGlobMatcher(this.options.include, true);
69
- this.excludeMatcher = createGlobMatcher(this.options.exclude, false);
70
- this.classGenerator = new ClassGenerator(this.options.classGenerator);
71
- }
72
- isInclude(file) {
73
- return this.includeMatcher(file) && !this.excludeMatcher(file);
74
- }
75
- currentMangleClassFilter(className) {
76
- return (this.options.mangleClassFilter ?? defaultMangleClassFilter)(className);
77
- }
78
- getClassSet() {
79
- return this.classSet;
80
- }
81
- getReplaceMap() {
82
- return this.replaceMap;
83
- }
84
- addToUsedBy(key, file) {
85
- const hit = this.classGenerator.newClassMap[key];
86
- if (hit) {
87
- hit.usedBy.add(file);
88
- }
89
- }
90
- search(str) {
91
- const arr = this.ahoCorasick?.search(str) ?? [];
92
- const map = /* @__PURE__ */ new Map();
93
- for (const [end, classNames] of arr) {
94
- for (const className of classNames) {
95
- if (map.has(className)) {
96
- const v = map.get(className);
97
- if (v) {
98
- v.push([end - className.length + 1, end + 1]);
99
- }
100
- } else {
101
- map.set(className, [[end - className.length + 1, end + 1]]);
102
- }
103
- }
104
- }
105
- return {
106
- map,
107
- arr: sort([...map.entries()]).desc((x) => x[0].length)
108
- };
109
- }
110
- async initConfig(cwd) {
111
- const { config, cwd: configCwd } = await getConfig(cwd);
112
- const mangleConfig = config?.mangle;
113
- this.mergeOptions(mangleConfig);
114
- let jsonPath = this.options.classListPath ?? resolve(process.cwd(), config?.patch?.output?.filename);
115
- if (!isAbsolute(jsonPath)) {
116
- jsonPath = resolve(configCwd ?? process.cwd(), jsonPath);
117
- }
118
- if (jsonPath && fs.existsSync(jsonPath)) {
119
- const rawClassList = fs.readFileSync(jsonPath, "utf8");
120
- const list = JSON.parse(rawClassList);
121
- const classList = sort(list).desc((c) => c.length);
122
- for (const className of classList) {
123
- if (this.currentMangleClassFilter(className)) {
124
- this.classSet.add(className);
125
- }
126
- }
127
- }
128
- const keywords = [];
129
- for (const cls of this.classSet) {
130
- this.classGenerator.generateClassName(cls);
131
- keywords.push(cls);
132
- }
133
- this.ahoCorasick = new AhoCorasick(keywords);
134
- for (const x of Object.entries(this.classGenerator.newClassMap)) {
135
- this.replaceMap.set(x[0], x[1].name);
136
- }
137
- return config;
138
- }
139
- }
6
+ import { p as pluginName, g as getGroupedEntries, e as ensureDir } from './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
7
+ import '@tailwindcss-mangle/shared';
140
8
 
141
9
  const unplugin = createUnplugin((options) => {
142
- const ctx = new Context(options);
143
- if (ctx.options.disabled) {
144
- return {
145
- name: pluginName
146
- };
147
- }
10
+ const ctx = new Context();
148
11
  return {
149
12
  name: pluginName,
150
13
  enforce: "pre",
151
14
  async buildStart() {
152
- await ctx.initConfig();
15
+ await ctx.initConfig({
16
+ mangleOptions: options
17
+ });
153
18
  },
154
19
  transformInclude(id) {
155
20
  return ctx.isInclude(id);
@@ -157,41 +22,17 @@ const unplugin = createUnplugin((options) => {
157
22
  transform(code, id) {
158
23
  const s = new MagicString(code);
159
24
  const replaceMap = ctx.getReplaceMap();
160
- if (/\.[jt]sx?$/.test(id)) {
161
- return preProcessJs({
162
- code: s,
163
- replaceMap,
164
- addToUsedBy: ctx.addToUsedBy.bind(ctx),
165
- id
166
- });
167
- } else if (ctx.useAC) {
168
- const { arr } = ctx.search(code);
169
- const markArr = [];
170
- for (const [cls, ranges] of arr) {
171
- for (const [start, end] of ranges) {
172
- const value = replaceMap.get(cls);
173
- if (value) {
174
- let flag = true;
175
- for (const [ps, pe] of markArr) {
176
- if (start > ps && start < pe || end < pe && end > start) {
177
- flag = false;
178
- break;
179
- }
180
- }
181
- if (flag) {
182
- markArr.push([start, end]);
183
- s.update(start, end, value);
184
- }
185
- }
186
- }
187
- }
188
- return s.toString();
189
- } else {
190
- for (const [key, value] of replaceMap) {
191
- code = code.replaceAll(key, value);
192
- }
193
- return code;
194
- }
25
+ return /\.[jt]sx?$/.test(id) ? preProcessJs({
26
+ code: s,
27
+ replaceMap,
28
+ ctx,
29
+ id
30
+ }) : preProcessRawCode({
31
+ code,
32
+ ctx,
33
+ replaceMap,
34
+ id
35
+ });
195
36
  },
196
37
  vite: {
197
38
  generateBundle: {
@@ -204,7 +45,7 @@ const unplugin = createUnplugin((options) => {
204
45
  const { css } = await cssHandler(cssSource.source.toString(), {
205
46
  file,
206
47
  replaceMap,
207
- classGenerator: ctx.classGenerator
48
+ ctx
208
49
  });
209
50
  cssSource.source = css;
210
51
  }
@@ -229,7 +70,7 @@ const unplugin = createUnplugin((options) => {
229
70
  const [file, chunk] = groupedEntries.js[i];
230
71
  const code = jsHandler(chunk.source().toString(), {
231
72
  replaceMap,
232
- classGenerator: ctx.classGenerator
73
+ ctx
233
74
  }).code;
234
75
  if (code) {
235
76
  const source = new ConcatSource(code);
@@ -243,7 +84,7 @@ const unplugin = createUnplugin((options) => {
243
84
  const { css } = await cssHandler(cssSource.source().toString(), {
244
85
  replaceMap,
245
86
  file,
246
- classGenerator: ctx.classGenerator
87
+ ctx
247
88
  });
248
89
  const source = new ConcatSource(css);
249
90
  compilation.updateAsset(file, source);
@@ -253,7 +94,7 @@ const unplugin = createUnplugin((options) => {
253
94
  for (let i = 0; i < groupedEntries.html.length; i++) {
254
95
  const [file, asset] = groupedEntries.html[i];
255
96
  const html = htmlHandler(asset.source().toString(), {
256
- classGenerator: ctx.classGenerator,
97
+ ctx,
257
98
  replaceMap
258
99
  });
259
100
  const source = new ConcatSource(html);
@@ -281,7 +122,7 @@ const unplugin = createUnplugin((options) => {
281
122
  null,
282
123
  opts.loose ? 2 : 0
283
124
  );
284
- await fs$1.writeFile(opts.filename, output, "utf8");
125
+ await fs.writeFile(opts.filename, output, "utf8");
285
126
  console.log(`\u2728 ${opts.filename} generated!`);
286
127
  }
287
128
  }
package/dist/nuxt.cjs CHANGED
@@ -1,18 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:fs');
5
4
  require('node:path');
6
- require('@tailwindcss-mangle/shared');
7
- require('@tailwindcss-mangle/config');
8
- require('fast-sort');
9
- require('modern-ahocorasick');
10
5
  require('node:fs/promises');
11
- require('micromatch');
12
6
  require('unplugin');
13
7
  require('@tailwindcss-mangle/core');
14
8
  require('magic-string');
15
- require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
9
+ require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
10
+ require('@tailwindcss-mangle/shared');
16
11
 
17
12
  function nuxt(options = {}, nuxt) {
18
13
  nuxt.hook("webpack:config", (config) => {
@@ -0,0 +1,5 @@
1
+ import { MangleUserConfig } from '@tailwindcss-mangle/config';
2
+
3
+ declare function export_default(options: MangleUserConfig | undefined, nuxt: any): void;
4
+
5
+ export { export_default as default };
@@ -0,0 +1,5 @@
1
+ import { MangleUserConfig } from '@tailwindcss-mangle/config';
2
+
3
+ declare function export_default(options: MangleUserConfig | undefined, nuxt: any): void;
4
+
5
+ export { export_default as default };
package/dist/nuxt.mjs CHANGED
@@ -1,16 +1,11 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:fs';
3
2
  import 'node:path';
4
- import '@tailwindcss-mangle/shared';
5
- import '@tailwindcss-mangle/config';
6
- import 'fast-sort';
7
- import 'modern-ahocorasick';
8
3
  import 'node:fs/promises';
9
- import 'micromatch';
10
4
  import 'unplugin';
11
5
  import '@tailwindcss-mangle/core';
12
6
  import 'magic-string';
13
- import './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
7
+ import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
8
+ import '@tailwindcss-mangle/shared';
14
9
 
15
10
  function nuxt(options = {}, nuxt) {
16
11
  nuxt.hook("webpack:config", (config) => {
package/dist/rollup.cjs CHANGED
@@ -1,18 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:fs');
5
4
  require('node:path');
6
- require('@tailwindcss-mangle/shared');
7
- require('@tailwindcss-mangle/config');
8
- require('fast-sort');
9
- require('modern-ahocorasick');
10
5
  require('node:fs/promises');
11
- require('micromatch');
12
6
  require('unplugin');
13
7
  require('@tailwindcss-mangle/core');
14
8
  require('magic-string');
15
- require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
9
+ require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
10
+ require('@tailwindcss-mangle/shared');
16
11
 
17
12
  const rollup = index.rollup;
18
13
 
@@ -0,0 +1,6 @@
1
+ import * as rollup from 'rollup';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
+
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => rollup.Plugin<any> | rollup.Plugin<any>[];
5
+
6
+ export { _default as default };
@@ -0,0 +1,6 @@
1
+ import * as rollup from 'rollup';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
+
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => rollup.Plugin<any> | rollup.Plugin<any>[];
5
+
6
+ export { _default as default };
package/dist/rollup.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as rollup from 'rollup';
2
2
  import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
3
 
4
- declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => rollup.Plugin | rollup.Plugin[];
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => rollup.Plugin<any> | rollup.Plugin<any>[];
5
5
 
6
6
  export { _default as default };
package/dist/rollup.mjs CHANGED
@@ -1,16 +1,11 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:fs';
3
2
  import 'node:path';
4
- import '@tailwindcss-mangle/shared';
5
- import '@tailwindcss-mangle/config';
6
- import 'fast-sort';
7
- import 'modern-ahocorasick';
8
3
  import 'node:fs/promises';
9
- import 'micromatch';
10
4
  import 'unplugin';
11
5
  import '@tailwindcss-mangle/core';
12
6
  import 'magic-string';
13
- import './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
7
+ import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
8
+ import '@tailwindcss-mangle/shared';
14
9
 
15
10
  const rollup = unplugin.rollup;
16
11
 
@@ -2,18 +2,21 @@
2
2
 
3
3
  const fs = require('node:fs/promises');
4
4
  const path = require('node:path');
5
- const micromatch = require('micromatch');
6
5
  const shared = require('@tailwindcss-mangle/shared');
7
6
 
8
7
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
9
8
 
10
9
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
11
10
  const path__default = /*#__PURE__*/_interopDefaultCompat(path);
12
- const micromatch__default = /*#__PURE__*/_interopDefaultCompat(micromatch);
13
11
 
14
12
  const pluginName = "unplugin-tailwindcss-mangle";
15
13
 
16
- const { isMatch } = micromatch__default;
14
+ function escapeStringRegexp(str) {
15
+ if (typeof str !== "string") {
16
+ throw new TypeError("Expected a string");
17
+ }
18
+ return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
19
+ }
17
20
  function getGroupedEntries(entries, options = {
18
21
  cssMatcher(file) {
19
22
  return /\.css$/.test(file);
@@ -51,16 +54,6 @@ function getGroupedEntries(entries, options = {
51
54
  }
52
55
  return groupedEntries;
53
56
  }
54
- function createGlobMatcher(pattern, fallbackValue = false) {
55
- if (pattern === void 0) {
56
- return function() {
57
- return fallbackValue;
58
- };
59
- }
60
- return function(file) {
61
- return isMatch(file, pattern);
62
- };
63
- }
64
57
  function getCacheDir(basedir = process.cwd()) {
65
58
  return path__default.resolve(basedir, "node_modules/.cache", pluginName);
66
59
  }
@@ -74,8 +67,8 @@ async function ensureDir(p) {
74
67
  }
75
68
  }
76
69
 
77
- exports.createGlobMatcher = createGlobMatcher;
78
70
  exports.ensureDir = ensureDir;
71
+ exports.escapeStringRegexp = escapeStringRegexp;
79
72
  exports.getCacheDir = getCacheDir;
80
73
  exports.getGroupedEntries = getGroupedEntries;
81
74
  exports.pluginName = pluginName;
@@ -1,11 +1,15 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
- import micromatch from 'micromatch';
4
3
  import { groupBy } from '@tailwindcss-mangle/shared';
5
4
 
6
5
  const pluginName = "unplugin-tailwindcss-mangle";
7
6
 
8
- const { isMatch } = micromatch;
7
+ function escapeStringRegexp(str) {
8
+ if (typeof str !== "string") {
9
+ throw new TypeError("Expected a string");
10
+ }
11
+ return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
12
+ }
9
13
  function getGroupedEntries(entries, options = {
10
14
  cssMatcher(file) {
11
15
  return /\.css$/.test(file);
@@ -43,16 +47,6 @@ function getGroupedEntries(entries, options = {
43
47
  }
44
48
  return groupedEntries;
45
49
  }
46
- function createGlobMatcher(pattern, fallbackValue = false) {
47
- if (pattern === void 0) {
48
- return function() {
49
- return fallbackValue;
50
- };
51
- }
52
- return function(file) {
53
- return isMatch(file, pattern);
54
- };
55
- }
56
50
  function getCacheDir(basedir = process.cwd()) {
57
51
  return path.resolve(basedir, "node_modules/.cache", pluginName);
58
52
  }
@@ -66,4 +60,4 @@ async function ensureDir(p) {
66
60
  }
67
61
  }
68
62
 
69
- export { getCacheDir as a, createGlobMatcher as c, ensureDir as e, getGroupedEntries as g, pluginName as p };
63
+ export { escapeStringRegexp as a, getCacheDir as b, ensureDir as e, getGroupedEntries as g, pluginName as p };
package/dist/utils.cjs CHANGED
@@ -2,16 +2,15 @@
2
2
 
3
3
  require('node:fs/promises');
4
4
  require('node:path');
5
- require('micromatch');
6
5
  const shared = require('@tailwindcss-mangle/shared');
7
- const utils = require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
6
+ const utils = require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
8
7
 
9
8
 
10
9
 
11
10
  exports.defaultMangleClassFilter = shared.defaultMangleClassFilter;
12
11
  exports.isMap = shared.isMap;
13
12
  exports.isRegexp = shared.isRegexp;
14
- exports.createGlobMatcher = utils.createGlobMatcher;
15
13
  exports.ensureDir = utils.ensureDir;
14
+ exports.escapeStringRegexp = utils.escapeStringRegexp;
16
15
  exports.getCacheDir = utils.getCacheDir;
17
16
  exports.getGroupedEntries = utils.getGroupedEntries;
@@ -0,0 +1,12 @@
1
+ export { defaultMangleClassFilter, isMap, isRegexp } from '@tailwindcss-mangle/shared';
2
+
3
+ declare function escapeStringRegexp(str: string): string;
4
+ declare function getGroupedEntries<T>(entries: [string, T][], options?: {
5
+ cssMatcher(file: string): boolean;
6
+ htmlMatcher(file: string): boolean;
7
+ jsMatcher(file: string): boolean;
8
+ }): Record<"css" | "html" | "js" | "other", [string, T][]>;
9
+ declare function getCacheDir(basedir?: string): string;
10
+ declare function ensureDir(p: string): Promise<void>;
11
+
12
+ export { ensureDir, escapeStringRegexp, getCacheDir, getGroupedEntries };
@@ -0,0 +1,12 @@
1
+ export { defaultMangleClassFilter, isMap, isRegexp } from '@tailwindcss-mangle/shared';
2
+
3
+ declare function escapeStringRegexp(str: string): string;
4
+ declare function getGroupedEntries<T>(entries: [string, T][], options?: {
5
+ cssMatcher(file: string): boolean;
6
+ htmlMatcher(file: string): boolean;
7
+ jsMatcher(file: string): boolean;
8
+ }): Record<"css" | "html" | "js" | "other", [string, T][]>;
9
+ declare function getCacheDir(basedir?: string): string;
10
+ declare function ensureDir(p: string): Promise<void>;
11
+
12
+ export { ensureDir, escapeStringRegexp, getCacheDir, getGroupedEntries };
package/dist/utils.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export { defaultMangleClassFilter, isMap, isRegexp } from '@tailwindcss-mangle/shared';
2
2
 
3
+ declare function escapeStringRegexp(str: string): string;
3
4
  declare function getGroupedEntries<T>(entries: [string, T][], options?: {
4
5
  cssMatcher(file: string): boolean;
5
6
  htmlMatcher(file: string): boolean;
6
7
  jsMatcher(file: string): boolean;
7
8
  }): Record<"css" | "html" | "js" | "other", [string, T][]>;
8
- declare function createGlobMatcher(pattern: string | string[] | undefined, fallbackValue?: boolean): (file: string) => boolean;
9
9
  declare function getCacheDir(basedir?: string): string;
10
10
  declare function ensureDir(p: string): Promise<void>;
11
11
 
12
- export { createGlobMatcher, ensureDir, getCacheDir, getGroupedEntries };
12
+ export { ensureDir, escapeStringRegexp, getCacheDir, getGroupedEntries };
package/dist/utils.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import 'node:fs/promises';
2
2
  import 'node:path';
3
- import 'micromatch';
4
3
  export { defaultMangleClassFilter, isMap, isRegexp } from '@tailwindcss-mangle/shared';
5
- export { c as createGlobMatcher, e as ensureDir, a as getCacheDir, g as getGroupedEntries } from './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
4
+ export { e as ensureDir, a as escapeStringRegexp, b as getCacheDir, g as getGroupedEntries } from './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
package/dist/vite.cjs CHANGED
@@ -1,18 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:fs');
5
4
  require('node:path');
6
- require('@tailwindcss-mangle/shared');
7
- require('@tailwindcss-mangle/config');
8
- require('fast-sort');
9
- require('modern-ahocorasick');
10
5
  require('node:fs/promises');
11
- require('micromatch');
12
6
  require('unplugin');
13
7
  require('@tailwindcss-mangle/core');
14
8
  require('magic-string');
15
- require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
9
+ require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
10
+ require('@tailwindcss-mangle/shared');
16
11
 
17
12
  const vite = index.vite;
18
13
 
@@ -0,0 +1,6 @@
1
+ import * as vite from 'vite';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
+
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => vite.Plugin | vite.Plugin[];
5
+
6
+ export { _default as default };
@@ -0,0 +1,6 @@
1
+ import * as vite from 'vite';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
+
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => vite.Plugin | vite.Plugin[];
5
+
6
+ export { _default as default };
package/dist/vite.mjs CHANGED
@@ -1,16 +1,11 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:fs';
3
2
  import 'node:path';
4
- import '@tailwindcss-mangle/shared';
5
- import '@tailwindcss-mangle/config';
6
- import 'fast-sort';
7
- import 'modern-ahocorasick';
8
3
  import 'node:fs/promises';
9
- import 'micromatch';
10
4
  import 'unplugin';
11
5
  import '@tailwindcss-mangle/core';
12
6
  import 'magic-string';
13
- import './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
7
+ import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
8
+ import '@tailwindcss-mangle/shared';
14
9
 
15
10
  const vite = unplugin.vite;
16
11
 
package/dist/webpack.cjs CHANGED
@@ -1,18 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:fs');
5
4
  require('node:path');
6
- require('@tailwindcss-mangle/shared');
7
- require('@tailwindcss-mangle/config');
8
- require('fast-sort');
9
- require('modern-ahocorasick');
10
5
  require('node:fs/promises');
11
- require('micromatch');
12
6
  require('unplugin');
13
7
  require('@tailwindcss-mangle/core');
14
8
  require('magic-string');
15
- require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
9
+ require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
10
+ require('@tailwindcss-mangle/shared');
16
11
 
17
12
  const webpack = index.webpack;
18
13
 
@@ -0,0 +1,6 @@
1
+ import * as webpack from 'webpack';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
+
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => webpack.WebpackPluginInstance;
5
+
6
+ export { _default as default };
@@ -0,0 +1,6 @@
1
+ import * as webpack from 'webpack';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
+
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => webpack.WebpackPluginInstance;
5
+
6
+ export { _default as default };
package/dist/webpack.mjs CHANGED
@@ -1,16 +1,11 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:fs';
3
2
  import 'node:path';
4
- import '@tailwindcss-mangle/shared';
5
- import '@tailwindcss-mangle/config';
6
- import 'fast-sort';
7
- import 'modern-ahocorasick';
8
3
  import 'node:fs/promises';
9
- import 'micromatch';
10
4
  import 'unplugin';
11
5
  import '@tailwindcss-mangle/core';
12
6
  import 'magic-string';
13
- import './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
7
+ import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
8
+ import '@tailwindcss-mangle/shared';
14
9
 
15
10
  const webpack = unplugin.webpack;
16
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-tailwindcss-mangle",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "mangle tailwindcss utilities class plugin. support vite and webpack!",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -65,14 +65,11 @@
65
65
  "author": "SonOfMagic <qq1324318532@gmail.com>",
66
66
  "license": "MIT",
67
67
  "dependencies": {
68
- "fast-sort": "^3.4.0",
69
- "magic-string": "^0.30.2",
70
- "micromatch": "^4.0.5",
71
- "modern-ahocorasick": "^1.0.0",
68
+ "magic-string": "^0.30.3",
72
69
  "unplugin": "^1.4.0",
73
- "@tailwindcss-mangle/config": "^2.1.0",
74
- "@tailwindcss-mangle/core": "^2.1.0",
75
- "@tailwindcss-mangle/shared": "^2.1.0"
70
+ "@tailwindcss-mangle/config": "^2.2.0",
71
+ "@tailwindcss-mangle/core": "^2.2.0",
72
+ "@tailwindcss-mangle/shared": "^2.2.0"
76
73
  },
77
74
  "publishConfig": {
78
75
  "access": "public",
@@ -80,18 +77,18 @@
80
77
  },
81
78
  "devDependencies": {
82
79
  "@types/babel__helper-plugin-utils": "^7.10.0",
83
- "@types/micromatch": "^4.0.2",
80
+ "astro": "^2.10.12",
84
81
  "css-loader": "^6.8.1",
85
82
  "html-webpack-plugin": "^5.5.3",
86
83
  "mini-css-extract-plugin": "^2.7.6",
87
84
  "normalize-newline": "^4.1.0",
88
- "postcss": "^8.4.27",
85
+ "postcss": "^8.4.29",
89
86
  "postcss-loader": "^7.3.3",
90
87
  "tailwindcss": "^3.3.3",
91
88
  "vite": "^4.4.9",
92
89
  "webpack": "^5.88.2",
93
90
  "webpack-build-utils": "^0.0.4",
94
- "tailwindcss-patch": "^2.1.0"
91
+ "tailwindcss-patch": "^2.2.0"
95
92
  },
96
93
  "homepage": "https://github.com/sonofmagic/tailwindcss-mangle",
97
94
  "repository": {
@@ -99,6 +96,7 @@
99
96
  "url": "git+https://github.com/sonofmagic/tailwindcss-mangle.git"
100
97
  },
101
98
  "scripts": {
99
+ "dev": "unbuild --sourcemap",
102
100
  "build": "unbuild",
103
101
  "test": "vitest run --coverage.enabled",
104
102
  "test:dev": "vitest"