babel-preset-cssxjs 0.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/CHANGELOG.md +11 -0
- package/README.md +22 -0
- package/index.js +60 -0
- package/package.json +24 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# v0.2.0 (Tue Nov 04 2025)
|
|
2
|
+
|
|
3
|
+
#### 🚀 Enhancement
|
|
4
|
+
|
|
5
|
+
- feat: refactor all babel plugins to perform early transformation of all code in Program.enter block ([@cray0000](https://github.com/cray0000))
|
|
6
|
+
- feat(runtime): implement support for both React Native and pure Web ([@cray0000](https://github.com/cray0000))
|
|
7
|
+
- feat: make it work for pure web through a babel plugin [#2](https://github.com/startupjs/cssx/pull/2) ([@cray0000](https://github.com/cray0000))
|
|
8
|
+
|
|
9
|
+
#### Authors: 1
|
|
10
|
+
|
|
11
|
+
- Pavel Zhukov ([@cray0000](https://github.com/cray0000))
|
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# babel-preset-startupjs
|
|
2
|
+
> Babel preset for compiling StartupJS app on server, web, native
|
|
3
|
+
|
|
4
|
+
## Usage in StartupJS projects
|
|
5
|
+
|
|
6
|
+
StartupJS projects include this configuration by default. **You don't need to install it separately in StartupJS projects.**
|
|
7
|
+
|
|
8
|
+
## Usage outside of StartupJS
|
|
9
|
+
|
|
10
|
+
If you want to use this preset in a custom project, just plug it in `.babelrc`:
|
|
11
|
+
|
|
12
|
+
```json
|
|
13
|
+
{
|
|
14
|
+
presets: ['startupjs']
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## License
|
|
19
|
+
|
|
20
|
+
MIT
|
|
21
|
+
|
|
22
|
+
(c) Decision Mapper - http://decisionmapper.com
|
package/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
module.exports = (api, { platform } = {}) => {
|
|
2
|
+
return {
|
|
3
|
+
overrides: [{
|
|
4
|
+
test: isJsxSource,
|
|
5
|
+
plugins: [
|
|
6
|
+
// support JSX syntax
|
|
7
|
+
require('@babel/plugin-syntax-jsx')
|
|
8
|
+
]
|
|
9
|
+
}, {
|
|
10
|
+
test: isTypeScriptSource,
|
|
11
|
+
plugins: [
|
|
12
|
+
// support TypeScript syntax
|
|
13
|
+
require('@babel/plugin-syntax-typescript')
|
|
14
|
+
]
|
|
15
|
+
}, {
|
|
16
|
+
test: isTsxSource,
|
|
17
|
+
plugins: [
|
|
18
|
+
// support TypeScript + JSX syntax
|
|
19
|
+
[require('@babel/plugin-syntax-typescript'), {
|
|
20
|
+
isTSX: true
|
|
21
|
+
}]
|
|
22
|
+
]
|
|
23
|
+
}, {
|
|
24
|
+
plugins: [
|
|
25
|
+
// transform pug to jsx. This generates a bunch of new AST nodes
|
|
26
|
+
// (it's important to do this first before any dead code elimination runs)
|
|
27
|
+
[require('@cssxjs/babel-plugin-react-pug'), {
|
|
28
|
+
classAttribute: 'styleName'
|
|
29
|
+
}],
|
|
30
|
+
// inline CSS modules (styl`` in the same JSX file -- similar to how it is in Vue.js)
|
|
31
|
+
[require('@cssxjs/babel-plugin-rn-stylename-inline'), {
|
|
32
|
+
platform
|
|
33
|
+
}],
|
|
34
|
+
// CSS modules (separate .styl/.css file)
|
|
35
|
+
[require('@cssxjs/babel-plugin-rn-stylename-to-style'), {
|
|
36
|
+
extensions: ['styl', 'css'],
|
|
37
|
+
useImport: true
|
|
38
|
+
}]
|
|
39
|
+
].filter(Boolean)
|
|
40
|
+
}]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// all files which are not .ts or .tsx are considered to be pure JS with JSX support
|
|
45
|
+
function isJsxSource (fileName) {
|
|
46
|
+
if (!fileName) return false
|
|
47
|
+
return !isTypeScriptSource(fileName) && !isTsxSource(fileName)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function isTypeScriptSource (fileName) {
|
|
51
|
+
if (!fileName) return false
|
|
52
|
+
return fileName.endsWith('.ts')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// NOTE: .tsx is the default when fileName is not provided.
|
|
56
|
+
// This is because we want to support the most overarching syntax by default.
|
|
57
|
+
function isTsxSource (fileName) {
|
|
58
|
+
if (!fileName) return true
|
|
59
|
+
return fileName.endsWith('.tsx')
|
|
60
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "babel-preset-cssxjs",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Babel preset for compiling CSSX",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./index.js"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "echo 'No tests yet' && exit 0"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@babel/plugin-syntax-jsx": "^7.0.0",
|
|
18
|
+
"@babel/plugin-syntax-typescript": "^7.23.3",
|
|
19
|
+
"@cssxjs/babel-plugin-react-pug": "^0.2.0",
|
|
20
|
+
"@cssxjs/babel-plugin-rn-stylename-inline": "^0.2.0",
|
|
21
|
+
"@cssxjs/babel-plugin-rn-stylename-to-style": "^0.2.0"
|
|
22
|
+
},
|
|
23
|
+
"gitHead": "a80a44b4d14c116871ca03997ce772b6beabf5d8"
|
|
24
|
+
}
|