Skip to content

Commit

Permalink
Merge pull request #2 from NervJS/next
Browse files Browse the repository at this point in the history
合并上游分支代码
  • Loading branch information
bigmeow authored Sep 9, 2021
2 parents 6e359ae + aefff41 commit 35a764a
Show file tree
Hide file tree
Showing 59 changed files with 253 additions and 188 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.3.6",
"version": "3.3.7",
"npmClient": "yarn",
"command": {
"create": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { transform } from '@babel/core'
import syntaxJSX from 'babel-plugin-syntax-jsx'
import jSXStylePlugin from '../dist/index'
import jSXStylePlugin from '../src/index'

const mergeStylesFunctionTemplate = `function _mergeStyles() {
var newTarget = {};
Expand Down Expand Up @@ -555,6 +555,30 @@ class App extends Component {
}`)
})

it('Processing module style conditional expression When css module enable', () => {
expect(getTransfromCode(`
import { createElement, Component } from 'rax';
import './app.scss';
import styleSheet from './app.module.scss';
class App extends Component {
render() {
const a = 1 ? styleSheet.red : styleSheet.blue;
return <div className={a} />;
}
}`, false, { enableCSSModule: true })).toBe(`import { createElement, Component } from 'rax';
import appScssStyleSheet from "./app.scss";
import styleSheet from './app.module.scss';
var _styleSheet = appScssStyleSheet;
class App extends Component {
render() {
const a = 1 ? styleSheet.red : styleSheet.blue;
return <div style={a} />;
}\n
}`)
})

it('merge stylesheet when css module disable', () => {
expect(getTransfromCode(`
import { createElement, Component } from 'rax';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
verbose: true,
transform: {
'^.+\\.js$': 'babel-jest'
'^.+\\.js$': 'babel-jest',
'^.+\\.tsx?$': 'ts-jest'
},
testPathIgnorePatterns: ['/node_modules/', '/__tests__/mocks/']
testPathIgnorePatterns: ['/node_modules/']
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-transform-react-jsx-to-rn-stylesheet",
"version": "3.3.6",
"version": "3.3.7",
"description": "Transform stylesheet selector to style in JSX Elements.",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -24,7 +24,7 @@
},
"dependencies": {
"camelize": "^1.0.0",
"taro-css-to-react-native": "3.3.6"
"taro-css-to-react-native": "3.3.7"
},
"devDependencies": {
"@types/babel__core": "^7.1.14"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export default function (babel: {
}
}

// assign 属性引用
if (t.isMemberExpression(expression) && t.isIdentifier(expression.object)) {
if (cssModuleStylesheets.includes(expression.object.name)) {
return true
Expand All @@ -164,7 +165,18 @@ export default function (babel: {
}
}

// 解构
// Conditional_Operator 条件(三元)运算符
if (t.isConditionalExpression(expression)) {
const { consequent, alternate } = expression
if (
isCSSMemberOrBindings(consequent, cssModuleStylesheets, astPath) ||
isCSSMemberOrBindings(alternate, cssModuleStylesheets, astPath)
) {
return true
}
}

// spread 解构
if (t.isObjectExpression(expression)) {
for (const prop of expression.properties) {
if (t.isSpreadElement(prop)) {
Expand All @@ -179,8 +191,8 @@ export default function (babel: {
function isJSXCSSModuleExpression (value, cssModuleStylesheets, astPath) {
if (t.isJSXExpressionContainer(value)) {
// 1. memberExpression a. 导入. b. 赋值. like `className="{style.red}"` or `const a = style; className="{a.red}"`
// 2. 解构 like `className="{{ ...style.red }}"`
// 3. memberExpression 和 解构. like `const a = { ...style }; className="{a.red}"
// 2. spread like `className="{{ ...style.red }}"`
// 3. memberExpression and spread. like `const a = { ...style }; className="{a.red}"

if (isCSSMemberOrBindings(value.expression, cssModuleStylesheets, astPath)) {
return true
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-transform-taroapi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-transform-taroapi",
"version": "3.3.6",
"version": "3.3.7",
"main": "dist/index.js",
"scripts": {
"build": "tsc"
Expand Down
12 changes: 6 additions & 6 deletions packages/babel-preset-taro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-preset-taro",
"version": "3.3.6",
"version": "3.3.7",
"description": "> TODO: description",
"author": "yuche <i@yuche.me>",
"homepage": "https://github.com/nervjs/taro/tree/master/packages/babel-preset-taro#readme",
Expand Down Expand Up @@ -34,21 +34,21 @@
"@babel/preset-typescript": "7.12.17",
"@babel/runtime": "^7.11.2",
"@babel/runtime-corejs3": "^7.14.8",
"@tarojs/helper": "3.3.6",
"@tarojs/taro-h5": "3.3.6",
"@tarojs/helper": "3.3.7",
"@tarojs/taro-h5": "3.3.7",
"@vue/babel-plugin-jsx": "^1.0.6",
"@vue/babel-preset-jsx": "^1.2.4",
"babel-plugin-dynamic-import-node": "^2.3.3",
"babel-plugin-global-define": "^1.0.3",
"babel-plugin-jsx-attributes-array-to-object": "^0.3.0",
"babel-plugin-transform-imports-api": "^1.0.0",
"babel-plugin-transform-react-jsx-to-rn-stylesheet": "3.3.6",
"babel-plugin-transform-taroapi": "3.3.6",
"babel-plugin-transform-react-jsx-to-rn-stylesheet": "3.3.7",
"babel-plugin-transform-taroapi": "3.3.7",
"core-js": "^3.6.5",
"metro-react-native-babel-preset": "^0.64.0",
"react-refresh": "0.9.0"
},
"devDependencies": {
"@tarojs/taro-rn": "3.3.6"
"@tarojs/taro-rn": "3.3.7"
}
}
2 changes: 1 addition & 1 deletion packages/css-to-react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "taro-css-to-react-native",
"description": "Convert CSS text to a React Native stylesheet object",
"version": "3.3.6",
"version": "3.3.7",
"main": "dist/index.js",
"license": "MIT",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-taro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-taro",
"version": "3.3.6",
"version": "3.3.7",
"description": "Taro specific linting rules for ESLint",
"main": "index.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-taro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-taro",
"version": "3.3.6",
"version": "3.3.7",
"description": "Taro specific linting plugin for ESLint",
"main": "index.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-html-transform/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-html-transform",
"version": "3.3.6",
"version": "3.3.7",
"description": "transform html tag name selector",
"main": "index.js",
"author": "drchan",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-plugin-constparse/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-plugin-constparse",
"version": "3.3.6",
"version": "3.3.7",
"description": "parse constants defined in config",
"main": "index.js",
"author": "Simba",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-pxtransform/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-pxtransform",
"version": "3.3.6",
"version": "3.3.7",
"description": "PostCSS plugin px 转小程序 rpx及h5 rem 单位",
"keywords": [
"postcss",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/shared",
"version": "3.3.6",
"version": "3.3.7",
"description": "> TODO: description",
"author": "yuche <i@yuche.me>",
"homepage": "https://github.com/nervjs/taro/tree/master/packages/shared#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/stylelint-config-taro-rn/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stylelint-config-taro-rn",
"version": "3.3.6",
"version": "3.3.7",
"description": "Shareable stylelint config for React Native CSS modules",
"main": "index.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/stylelint-taro-rn/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stylelint-taro-rn",
"description": "A collection of React Native specific rules for stylelint",
"version": "3.3.6",
"version": "3.3.7",
"main": "dist/index.js",
"files": [
"dist",
Expand Down
8 changes: 4 additions & 4 deletions packages/taro-alipay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/plugin-platform-alipay",
"version": "3.3.6",
"version": "3.3.7",
"description": "支付宝小程序平台插件",
"author": "Chen-jj",
"homepage": "https://github.com/nervjs/taro/tree/master/packages/taro-alipay#readme",
Expand All @@ -27,8 +27,8 @@
"url": "https://github.com/NervJS/taro/issues"
},
"dependencies": {
"@tarojs/components": "3.3.6",
"@tarojs/service": "3.3.6",
"@tarojs/shared": "3.3.6"
"@tarojs/components": "3.3.7",
"@tarojs/service": "3.3.7",
"@tarojs/shared": "3.3.7"
}
}
4 changes: 3 additions & 1 deletion packages/taro-alipay/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ export const components = {
'default-source': ''
},
Canvas: {
type: '',
width: singleQuote('300px'),
height: singleQuote('225px')
height: singleQuote('225px'),
bindReady: ''
},
Video: {
'poster-size': singleQuote('contain'),
Expand Down
4 changes: 2 additions & 2 deletions packages/taro-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/api",
"version": "3.3.6",
"version": "3.3.7",
"description": "Taro common API",
"author": "yuche <i@yuche.me>",
"homepage": "https://github.com/nervjs/taro/tree/master/packages/api#readme",
Expand Down Expand Up @@ -30,6 +30,6 @@
},
"dependencies": {
"@babel/runtime": "^7.11.2",
"@tarojs/runtime": "3.3.6"
"@tarojs/runtime": "3.3.7"
}
}
34 changes: 17 additions & 17 deletions packages/taro-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/cli",
"version": "3.3.6",
"version": "3.3.7",
"description": "cli tool for taro",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -44,17 +44,17 @@
"license": "MIT",
"dependencies": {
"@hapi/joi": "17.1.1",
"@tarojs/helper": "3.3.6",
"@tarojs/plugin-platform-alipay": "3.3.6",
"@tarojs/plugin-platform-jd": "3.3.6",
"@tarojs/plugin-platform-qq": "3.3.6",
"@tarojs/plugin-platform-swan": "3.3.6",
"@tarojs/plugin-platform-tt": "3.3.6",
"@tarojs/plugin-platform-weapp": "3.3.6",
"@tarojs/service": "3.3.6",
"@tarojs/shared": "3.3.6",
"@tarojs/taro": "3.3.6",
"@tarojs/taroize": "3.3.6",
"@tarojs/helper": "3.3.7",
"@tarojs/plugin-platform-alipay": "3.3.7",
"@tarojs/plugin-platform-jd": "3.3.7",
"@tarojs/plugin-platform-qq": "3.3.7",
"@tarojs/plugin-platform-swan": "3.3.7",
"@tarojs/plugin-platform-tt": "3.3.7",
"@tarojs/plugin-platform-weapp": "3.3.7",
"@tarojs/service": "3.3.7",
"@tarojs/shared": "3.3.7",
"@tarojs/taro": "3.3.7",
"@tarojs/taroize": "3.3.7",
"@tarojs/transformer-wx": "^2.0.4",
"@types/request": "^2.48.1",
"@typescript-eslint/parser": "^4.15.1",
Expand All @@ -79,11 +79,11 @@
"ejs": "^2.6.1",
"envinfo": "^6.0.1",
"eslint": "^6.1.0",
"eslint-config-taro": "3.3.6",
"eslint-config-taro": "3.3.7",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-react": "^7.4.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-taro": "3.3.6",
"eslint-plugin-taro": "3.3.7",
"eslint-plugin-vue": "^6.2.2",
"fbjs": "^1.0.0",
"fs-extra": "^5.0.0",
Expand All @@ -105,7 +105,7 @@
"postcss-modules-resolve-imports": "^1.3.0",
"postcss-modules-scope": "^1.1.0",
"postcss-modules-values": "^1.3.0",
"postcss-pxtransform": "3.3.6",
"postcss-pxtransform": "3.3.7",
"postcss-reporter": "^6.0.1",
"postcss-taro-unit-transform": "1.2.15",
"postcss-url": "^7.3.2",
Expand All @@ -126,7 +126,7 @@
"xxhashjs": "^0.2.2"
},
"devDependencies": {
"@tarojs/mini-runner": "3.3.6",
"@tarojs/webpack-runner": "3.3.6"
"@tarojs/mini-runner": "3.3.7",
"@tarojs/webpack-runner": "3.3.7"
}
}
6 changes: 3 additions & 3 deletions packages/taro-components-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/components-react",
"version": "3.3.6",
"version": "3.3.7",
"description": "",
"main:h5": "src/index.js",
"main": "dist/index.js",
Expand All @@ -24,8 +24,8 @@
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.13.10",
"@tarojs/taro": "3.3.6",
"@tarojs/taro-h5": "3.3.6",
"@tarojs/taro": "3.3.7",
"@tarojs/taro-h5": "3.3.7",
"better-scroll": "^1.14.1",
"classnames": "^2.2.5",
"intersection-observer": "^0.7.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/taro-components-rn/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/components-rn",
"version": "3.3.6",
"version": "3.3.7",
"description": "多端解决方案基础组件(RN)",
"main": "./dist/index.js",
"scripts": {
Expand Down Expand Up @@ -42,7 +42,7 @@
"unimodules-permissions-interface": "~5.3.0"
},
"devDependencies": {
"@tarojs/components": "3.3.6",
"@tarojs/components": "3.3.7",
"@types/react-native": "0.64.10",
"@types/sinon": "^9.0.8",
"cpy-cli": "^3.1.1",
Expand Down
Loading

0 comments on commit 35a764a

Please sign in to comment.