Skip to content

Commit

Permalink
Merge branch 'main' into fix/stylelint-taro-rn
Browse files Browse the repository at this point in the history
  • Loading branch information
tutuxxx authored Jan 13, 2025
2 parents 7bcfd03 + cbcdd87 commit 60a3c92
Show file tree
Hide file tree
Showing 103 changed files with 219 additions and 136 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rustflags = ["-C", "target-feature=+crt-static"]

[alias]
# Alias to build actual SWC plugin binary for the specified target.
build-wasi = "build --target wasm32-wasi"
build-wasi = "build --target wasm32-wasip1"
build-wasm32 = "build --target wasm32-unknown-unknown"
build-swc-plugins = "build-wasi --release -p swc_plugin_compile_mode -p swc_plugin_define_config -p swc_plugin_compile_mode_pre_process"
test-swc-plugins = "test -p swc_plugin_compile_mode -p swc_plugin_define_config -p swc_plugin_compile_mode_pre_process"
4 changes: 2 additions & 2 deletions .github/workflows/build-rust-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: wasm32-wasi
targets: wasm32-wasip1
- name: Cache cargo
uses: actions/cache@v3
with:
Expand All @@ -33,5 +33,5 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: wasm-wasi-swc_plugins
path: target/wasm32-wasi/release/*.wasm
path: target/wasm32-wasip1/release/*.wasm
if-no-files-found: error
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: wasm32-wasi
targets: wasm32-wasip1
- name: Cache cargo
uses: actions/cache@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ $ pnpm --filter @tarojs/binding run test

#### SWC 插件

首先在项目根目录执行 `rustup target add wasm32-wasi` 命令安装 `wasm32-wasi``target`
首先在项目根目录执行 `rustup target add wasm32-wasip1` 命令安装 `wasm32-wasip1``target`

开发过程中可以使用 SWC 测试套件进行单元测试:

Expand All @@ -207,7 +207,7 @@ $ cargo build -p [package-name]

Cargo workspace 会把编译产物输出到根目录的 `target` 文件夹中。进行集成测试时,需要手动把 `.wasm` 产物软链到目标文件夹,而 Github CI 在正式发布时会自动拷贝产物到正确的文件夹中。

如对 `@taorjs/helper` 进行集成测试时,会把 `target/wasm32-wasi/release/swc_plugin_xxx.wasm` 文件的软链到 `packages/taro-helper/swc/swc_plugin_xxx.wasm`
如对 `@taorjs/helper` 进行集成测试时,会把 `target/wasm32-wasip1/release/swc_plugin_xxx.wasm` 文件的软链到 `packages/taro-helper/swc/swc_plugin_xxx.wasm`

####

Expand Down
2 changes: 1 addition & 1 deletion crates/native_binding/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/binding",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "Node binding for taro",
"main": "binding.js",
"typings": "binding.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tarojs/binding-darwin-arm64",
"description": "Native binding for taro",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tarojs/binding-darwin-x64",
"description": "Native binding for taro",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/linux-x64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tarojs/binding-linux-x64-gnu",
"description": "Native binding for taro",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/linux-x64-musl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/binding-linux-x64-musl",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/win32-x64-msvc/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tarojs/binding-win32-x64-msvc",
"description": "Native binding for taro",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"os": [
"win32"
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "taro",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "开放式跨端跨框架开发解决方案",
"homepage": "https://github.com/NervJS/taro#readme",
"author": "O2Team",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-transform-react-jsx-to-rn-stylesheet",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "Transform stylesheet selector to style in JSX Elements.",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-transform-solid-jsx/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "babel-plugin-transform-solid-jsx",
"description": "A JSX to DOM plugin that wraps expressions for fine grained change detection",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"license": "MIT",
"repository": {
"type": "git",
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": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"author": "O2Team",
"license": "MIT",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion 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": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "Taro babel preset",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/create-app",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "create taro app with one command",
"author": "O2Team",
"license": "MIT",
Expand Down
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": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"author": "O2Team",
"license": "MIT",
"main": "dist/index.js",
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": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "Taro specific linting rules for ESLint",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-helper/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jest-taro-helper",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "jest helper for taro",
"private": true,
"author": "O2Team",
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": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "transform html tag name selector",
"author": "O2Team",
"license": "MIT",
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": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "parse constants defined in config",
"author": "O2Team",
"license": "MIT",
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": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "PostCSS plugin px 转小程序 rpx及h5 rem 单位",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-unit-transform/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-taro-unit-transform",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "小程序单位转换",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/rollup-plugin-copy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rollup-plugin-copy",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "rollup-plugin-copy for taro",
"private": true,
"author": "O2Team",
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": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "Taro utils internal use.",
"author": "O2Team",
"license": "MIT",
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": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "Shareable stylelint config for React Native CSS modules",
"author": "O2Team",
"license": "MIT",
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,6 +1,6 @@
{
"name": "stylelint-taro-rn",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "A collection of React Native specific rules for stylelint",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/stylelint-taro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stylelint-taro",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "Taro stylelint 规则集合",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/api",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "Taro common API",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-cli-convertor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/cli-convertor",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "cli tool for taro-convert",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/cli",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "cli tool for taro",
"author": "O2Team",
"license": "MIT",
Expand Down
1 change: 1 addition & 0 deletions packages/taro-cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export default class CLI {
projectName: _[1] || args.name,
description: args.description,
typescript: args.typescript,
buildEs5: args['build-es5'],
framework: args.framework,
compiler: args.compiler,
npm: args.npm,
Expand Down
7 changes: 7 additions & 0 deletions packages/taro-cli/src/presets/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
validateConfig
} from '@tarojs/plugin-doctor'

import { extractCompileEntry } from '../../util/appConfig'
import * as hooks from '../constant'

import type { IPluginContext } from '@tarojs/service'
Expand All @@ -14,6 +15,8 @@ export default (ctx: IPluginContext) => {
'--type [typeName]': 'Build type, weapp/swan/alipay/tt/qq/jd/h5/rn',
'--watch': 'Watch mode',
'--env [env]': 'Value for process.env.NODE_ENV',
'--pages': 'Specify the pages to be compiled, separate multiple by comma',
'--components': 'Specify the components to be compiled, separate multiple by comma',
'--mode [mode]': 'Value of dotenv extname',
'-p, --port [port]': 'Specified port',
'--no-build': 'Do not build project',
Expand All @@ -36,6 +39,7 @@ export default (ctx: IPluginContext) => {
synopsisList: [
'taro build --type weapp',
'taro build --type weapp --watch',
'taro build --type weapp --watch --pages pages/index/index',
'taro build --type weapp --env production',
'taro build --type weapp --blended',
'taro build --type weapp --no-build',
Expand All @@ -50,6 +54,7 @@ export default (ctx: IPluginContext) => {
const { platform, isWatch, blended, newBlended, withoutBuild, noInjectGlobalStyle, noCheck } = options
const { fs, chalk, PROJECT_CONFIG } = ctx.helper
const { outputPath, configPath } = ctx.paths
const { args } = options

if (!configPath || !fs.existsSync(configPath)) {
console.log(chalk.red(`找不到项目配置文件${PROJECT_CONFIG},请确定当前目录是 Taro 项目根目录!`))
Expand Down Expand Up @@ -120,6 +125,8 @@ export default (ctx: IPluginContext) => {
newBlended,
noInjectGlobalStyle,
async modifyAppConfig (appConfig) {
extractCompileEntry(appConfig, args, ctx)

await ctx.applyPlugins({
name: hooks.MODIFY_APP_CONFIG,
opts: {
Expand Down
3 changes: 3 additions & 0 deletions packages/taro-cli/src/presets/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default (ctx: IPluginContext) => {
'--name [name]': '项目名称',
'--description [description]': '项目介绍',
'--typescript': '使用TypeScript',
'--build-es5': '是否需要编译为es5',
'--npm [npm]': '包管理工具',
'--template-source [templateSource]': '项目模板源',
'--clone [clone]': '拉取远程模板时使用git clone',
Expand All @@ -25,6 +26,7 @@ export default (ctx: IPluginContext) => {
template,
description,
typescript,
buildEs5,
css,
npm,
framework,
Expand All @@ -45,6 +47,7 @@ export default (ctx: IPluginContext) => {
template,
description,
typescript,
buildEs5,
framework,
compiler,
hideDefaultTemplate,
Expand Down
29 changes: 29 additions & 0 deletions packages/taro-cli/src/util/appConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { IPluginContext } from '@tarojs/service'
import { isString } from '@tarojs/shared'
import { AppConfig } from '@tarojs/taro'

/**
* 按需编译功能,只编译指定的页面或组件
* @param appConfig
* @param args
*/
export function extractCompileEntry(
appConfig: AppConfig,
args: { _: string[], [key: string]: any },
ctx: IPluginContext
): void {
const { chalk } = ctx.helper

const extractType = isString(args.pages) ? 'pages' : isString(args.components) ? 'components' : ''
if (!extractType) return

const entries = args[extractType].split(',').map(item => item.trim()).filter(Boolean)
if (!entries.length) {
console.log(chalk.yellow(`按需编译开启失败,请指定要编译的${extractType}`))
return
}

appConfig[extractType] = entries
appConfig.subPackages = []
console.log(chalk.green(`已开启按需编译,仅编译以下${extractType}: ${appConfig[extractType]}`))
}
2 changes: 1 addition & 1 deletion packages/taro-components-advanced/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/components-advanced",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components-library-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/components-library-react",
"version": "4.0.9-beta.2",
"version": "4.0.9-beta.8",
"description": "Taro 组件库 React 版本库",
"private": true,
"author": "O2Team",
Expand Down
Loading

0 comments on commit 60a3c92

Please sign in to comment.