@cssxjs/bundler 0.2.2 → 0.2.4
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/CHANGELOG.md +12 -0
- package/lib/stylusToCssLoader.js +4 -0
- package/package.json +5 -5
- package/patches/patchStylusAddUnit.js +43 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# v0.2.3 (Wed Nov 05 2025)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- fix: update stylus, add a runtime patch to support the 'u' unit which equals to 8px. ([@cray0000](https://github.com/cray0000))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Pavel Zhukov ([@cray0000](https://github.com/cray0000))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
1
13
|
# v0.2.2 (Tue Nov 04 2025)
|
|
2
14
|
|
|
3
15
|
#### 🐛 Bug Fix
|
package/lib/stylusToCssLoader.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
const { existsSync } = require('fs')
|
|
3
3
|
const { join } = require('path')
|
|
4
4
|
const stylus = require('stylus')
|
|
5
|
+
const patchStylusAddUnit = require('../patches/patchStylusAddUnit')
|
|
6
|
+
|
|
7
|
+
// apply patches
|
|
8
|
+
patchStylusAddUnit()
|
|
5
9
|
|
|
6
10
|
const PROJECT_STYLES_PATH = join(process.cwd(), 'styles/index.styl')
|
|
7
11
|
let UI_STYLES_PATH
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cssxjs/bundler",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Compile CSSX styles in React Native and Web bundlers",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./metro-config": "./metro-config.js",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@babel/core": "^7.0.0",
|
|
25
|
-
"@cssxjs/babel-plugin-rn-stylename-inline": "^0.2.
|
|
25
|
+
"@cssxjs/babel-plugin-rn-stylename-inline": "^0.2.4",
|
|
26
26
|
"@startupjs/css-to-react-native-transform": "^2.1.0-1",
|
|
27
|
-
"babel-preset-cssxjs": "^0.2.
|
|
28
|
-
"stylus": "0.
|
|
27
|
+
"babel-preset-cssxjs": "^0.2.4",
|
|
28
|
+
"stylus": "0.64.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "22ebaf580b16f07e1f2695c2c21196dd15735f11"
|
|
31
31
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// add a new custom unit 'u' which is equal to 8px
|
|
2
|
+
const units = require('stylus/lib/units.js')
|
|
3
|
+
const Unit = require('stylus/lib/nodes/unit.js')
|
|
4
|
+
let patched = false
|
|
5
|
+
|
|
6
|
+
module.exports = function patchStylusAddUnit () {
|
|
7
|
+
if (patched) return
|
|
8
|
+
patched = true
|
|
9
|
+
|
|
10
|
+
// add the unit itself
|
|
11
|
+
if (!units.includes('u')) units.push('u')
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* a monkey patch to convert the 'type' to be dynamic setter/getter
|
|
15
|
+
* with the real value stored in a private symbol. This simulates having 'u' unit converted to 'px' * 8 on assignment.
|
|
16
|
+
*
|
|
17
|
+
* Original constructor is the following:
|
|
18
|
+
*
|
|
19
|
+
* constructor(val, type) {
|
|
20
|
+
* super();
|
|
21
|
+
* this.val = val;
|
|
22
|
+
* this.type = type;
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* this.val and this.type are never reassigned.
|
|
26
|
+
* This make it possible to hack the this.type assignment specifically by auto-multiplying the this.val by 8
|
|
27
|
+
* during the attempt to assign the 'u' to this.type
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
const TYPE = Symbol('unit.type')
|
|
31
|
+
Object.defineProperty(Unit.prototype, 'type', {
|
|
32
|
+
configurable: true,
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get () { return this[TYPE] },
|
|
35
|
+
set (t) {
|
|
36
|
+
if (t === 'u') {
|
|
37
|
+
t = 'px'
|
|
38
|
+
if (typeof this.val === 'number') this.val = this.val * 8
|
|
39
|
+
}
|
|
40
|
+
this[TYPE] = t
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
}
|