@tailwindcss-mangle/core 2.0.4 → 2.0.6
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/index.cjs +11 -4
- package/dist/index.mjs +11 -4
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -7,6 +7,7 @@ const shared = require('@tailwindcss-mangle/shared');
|
|
|
7
7
|
const babel = require('@babel/core');
|
|
8
8
|
const helperPluginUtils = require('@babel/helper-plugin-utils');
|
|
9
9
|
const MagicString = require('magic-string');
|
|
10
|
+
const escape = require('@ast-core/escape');
|
|
10
11
|
|
|
11
12
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
12
13
|
|
|
@@ -341,7 +342,7 @@ createNewSortInstance({
|
|
|
341
342
|
});
|
|
342
343
|
|
|
343
344
|
function handleValue$1(options) {
|
|
344
|
-
const { addToUsedBy, id, magicString, node, raw, replaceMap, offset = 0 } = options;
|
|
345
|
+
const { addToUsedBy, id, magicString, node, raw, replaceMap, offset = 0, escape: escape$1 = false } = options;
|
|
345
346
|
let value = raw;
|
|
346
347
|
const arr = sort(shared.splitCode(value)).desc((x) => x.length);
|
|
347
348
|
for (const str of arr) {
|
|
@@ -354,7 +355,11 @@ function handleValue$1(options) {
|
|
|
354
355
|
}
|
|
355
356
|
}
|
|
356
357
|
if (typeof node.start === "number" && typeof node.end === "number" && value) {
|
|
357
|
-
|
|
358
|
+
const start = node.start + offset;
|
|
359
|
+
const end = node.end - offset;
|
|
360
|
+
if (start < end) {
|
|
361
|
+
magicString.update(start, end, escape$1 ? escape.jsStringEscape(value) : value);
|
|
362
|
+
}
|
|
358
363
|
}
|
|
359
364
|
}
|
|
360
365
|
const plugin = helperPluginUtils.declare((api, options) => {
|
|
@@ -372,7 +377,8 @@ const plugin = helperPluginUtils.declare((api, options) => {
|
|
|
372
377
|
node,
|
|
373
378
|
raw: node.value,
|
|
374
379
|
replaceMap,
|
|
375
|
-
offset: 1
|
|
380
|
+
offset: 1,
|
|
381
|
+
escape: true
|
|
376
382
|
});
|
|
377
383
|
}
|
|
378
384
|
},
|
|
@@ -386,7 +392,8 @@ const plugin = helperPluginUtils.declare((api, options) => {
|
|
|
386
392
|
node,
|
|
387
393
|
raw: node.value.raw,
|
|
388
394
|
replaceMap,
|
|
389
|
-
offset: 0
|
|
395
|
+
offset: 0,
|
|
396
|
+
escape: false
|
|
390
397
|
});
|
|
391
398
|
}
|
|
392
399
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ export { ClassGenerator } from '@tailwindcss-mangle/shared';
|
|
|
6
6
|
import babel, { transformSync } from '@babel/core';
|
|
7
7
|
import { declare } from '@babel/helper-plugin-utils';
|
|
8
8
|
import MagicString from 'magic-string';
|
|
9
|
+
import { jsStringEscape } from '@ast-core/escape';
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
|
|
@@ -342,7 +343,7 @@ createNewSortInstance({
|
|
|
342
343
|
});
|
|
343
344
|
|
|
344
345
|
function handleValue$1(options) {
|
|
345
|
-
const { addToUsedBy, id, magicString, node, raw, replaceMap, offset = 0 } = options;
|
|
346
|
+
const { addToUsedBy, id, magicString, node, raw, replaceMap, offset = 0, escape = false } = options;
|
|
346
347
|
let value = raw;
|
|
347
348
|
const arr = sort(splitCode(value)).desc((x) => x.length);
|
|
348
349
|
for (const str of arr) {
|
|
@@ -355,7 +356,11 @@ function handleValue$1(options) {
|
|
|
355
356
|
}
|
|
356
357
|
}
|
|
357
358
|
if (typeof node.start === "number" && typeof node.end === "number" && value) {
|
|
358
|
-
|
|
359
|
+
const start = node.start + offset;
|
|
360
|
+
const end = node.end - offset;
|
|
361
|
+
if (start < end) {
|
|
362
|
+
magicString.update(start, end, escape ? jsStringEscape(value) : value);
|
|
363
|
+
}
|
|
359
364
|
}
|
|
360
365
|
}
|
|
361
366
|
const plugin = declare((api, options) => {
|
|
@@ -373,7 +378,8 @@ const plugin = declare((api, options) => {
|
|
|
373
378
|
node,
|
|
374
379
|
raw: node.value,
|
|
375
380
|
replaceMap,
|
|
376
|
-
offset: 1
|
|
381
|
+
offset: 1,
|
|
382
|
+
escape: true
|
|
377
383
|
});
|
|
378
384
|
}
|
|
379
385
|
},
|
|
@@ -387,7 +393,8 @@ const plugin = declare((api, options) => {
|
|
|
387
393
|
node,
|
|
388
394
|
raw: node.value.raw,
|
|
389
395
|
replaceMap,
|
|
390
|
-
offset: 0
|
|
396
|
+
offset: 0,
|
|
397
|
+
escape: false
|
|
391
398
|
});
|
|
392
399
|
}
|
|
393
400
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailwindcss-mangle/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "The core of tailwindcss-mangle",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -36,14 +36,15 @@
|
|
|
36
36
|
"registry": "https://registry.npmjs.org/"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
+
"@ast-core/escape": "^1.0.0",
|
|
40
|
+
"@babel/core": "^7.22.10",
|
|
39
41
|
"@babel/helper-plugin-utils": "^7.22.5",
|
|
40
42
|
"@babel/preset-typescript": "^7.22.5",
|
|
41
|
-
"@babel/core": "^7.22.10",
|
|
42
43
|
"@babel/types": "^7.22.10",
|
|
44
|
+
"magic-string": "^0.30.2",
|
|
43
45
|
"parse5": "^7.1.2",
|
|
44
46
|
"postcss": "^8.4.27",
|
|
45
47
|
"postcss-selector-parser": "^6.0.13",
|
|
46
|
-
"magic-string": "^0.30.2",
|
|
47
48
|
"@tailwindcss-mangle/shared": "^2.0.4"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|