Gathering detailed insights and metrics for react-native-typed-stylus-transformer
Gathering detailed insights and metrics for react-native-typed-stylus-transformer
Gathering detailed insights and metrics for react-native-typed-stylus-transformer
Gathering detailed insights and metrics for react-native-typed-stylus-transformer
Stylus transformer with Typescript support for React Native
npm install react-native-typed-stylus-transformer
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
18 Commits
2 Watchers
11 Branches
1 Contributors
Updated on May 27, 2025
Latest Version
0.11.0
Package Id
react-native-typed-stylus-transformer@0.11.0
Unpacked Size
10.74 kB
Size
3.75 kB
File Count
4
NPM Version
6.4.1
Node Version
8.15.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Load Stylus files to react native style objects.
This transformer also generates .d.ts
Typescript typings for the Stylus files. Notice that platform specific extensions are not supported in the Typescript typings.
This transformer can be used together with React Native CSS modules.
Minimum React Native version for this transformer is 0.52. If you are using an older version, please update to a newer React Native version before trying to use this transformer.
1yarn add --dev react-native-typed-stylus-transformer stylus
Add this to metro.config.js
in your project's root (create the file if it does not exist already):
1const { getDefaultConfig } = require("metro-config"); 2 3module.exports = (async () => { 4 const { 5 resolver: { sourceExts } 6 } = await getDefaultConfig(); 7 return { 8 transformer: { 9 babelTransformerPath: require.resolve( 10 "react-native-typed-stylus-transformer" 11 ) 12 }, 13 resolver: { 14 sourceExts: [...sourceExts, "styl"] 15 } 16 }; 17})();
If you are using Expo, you also need to add this to app.json
:
1{ 2 "expo": { 3 "packagerOpts": { 4 "config": "metro.config.js" 5 } 6 } 7}
If you are using React Native without Expo, add this to rn-cli.config.js
in your project's root (create the file if you don't have one already):
1module.exports = { 2 getTransformModulePath() { 3 return require.resolve("react-native-typed-stylus-transformer"); 4 }, 5 getSourceExts() { 6 return ["js", "jsx", "styl"]; 7 } 8};
If you are using Expo, instead of adding the rn-cli.config.js
file, you need to add this to app.json
:
1{ 2 "expo": { 3 "packagerOpts": { 4 "sourceExts": ["js", "jsx", "styl"], 5 "transformer": "node_modules/react-native-typed-stylus-transformer/index.js" 6 } 7 } 8}
Your App.styl
file might look like this:
1.myClass { 2 color: blue; 3} 4.myOtherClass { 5 color: red; 6}
When you import your stylesheet:
1import styles from "./App.styl";
Your imported styles will look like this:
1var styles = { 2 myClass: { 3 color: "blue" 4 }, 5 myOtherClass: { 6 color: "red" 7 } 8};
The generated App.styl.d.ts
file looks like this:
1export const myClass: string; 2export const myOtherClass: string;
You can then use that style object with an element:
1<MyElement style={styles.myClass} />
You need version 0.11.0 or newer
1:root { 2 --text-color: blue; 3} 4 5.blue { 6 color: var(--text-color); 7}
CSS variables are not supported by default, but you can add support for them by using PostCSS and postcss-css-variables plugin.
Start by installing dependencies:
1yarn add postcss postcss-css-variables react-native-postcss-transformer --dev
Add postcss-css-variables
to your PostCSS configuration with one of the supported config formats, e.g. package.json
, .postcssrc
, postcss.config.js
, etc.
After that create a transformer.js
file and do the following:
1// For React Native version 0.59 or later 2var upstreamTransformer = require("metro-react-native-babel-transformer"); 3 4// For React Native version 0.56-0.58 5// var upstreamTransformer = require("metro/src/reactNativeTransformer"); 6 7// For React Native version 0.52-0.55 8// var upstreamTransformer = require("metro/src/transformer"); 9 10// For React Native version 0.47-0.51 11// var upstreamTransformer = require("metro-bundler/src/transformer"); 12 13// For React Native version 0.46 14// var upstreamTransformer = require("metro-bundler/build/transformer"); 15 16var stylusTransformer = require("react-native-typed-stylus-transformer"); 17var postCSSTransformer = require("react-native-postcss-transformer"); 18 19module.exports.transform = function({ src, filename, options }) { 20 if (filename.endsWith(".styl")) { 21 return stylusTransformer 22 .renderToCSS({ src, filename, options }) 23 .then(css => 24 postCSSTransformer.transform({ src: css, filename, options }) 25 ); 26 } else { 27 return upstreamTransformer.transform({ src, filename, options }); 28 } 29};
After that in metro.config.js
point the babelTransformerPath
to that file:
1const { getDefaultConfig } = require("metro-config"); 2 3module.exports = (async () => { 4 const { 5 resolver: { sourceExts } 6 } = await getDefaultConfig(); 7 return { 8 transformer: { 9 babelTransformerPath: require.resolve("./transformer.js") 10 }, 11 resolver: { 12 sourceExts: [...sourceExts, "styl"] 13 } 14 }; 15})();
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/14 approved changesets -- score normalized to 0
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
46 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More