All Projects → SyMind → taro2-to-3

SyMind / taro2-to-3

Licence: MIT license
让 Taro2 项目自动升级到 Taro3 项目⚒️。

Programming Languages

javascript
184084 projects - #8 most used programming language
EJS
674 projects

Projects that are alternatives of or similar to taro2-to-3

ui
We reinvent the UI for taro3+
Stars: ✭ 48 (+54.84%)
Mutual labels:  taro, taro3
taro3-vue3-template
一个基于 Taro3 和 Vue3 框架微信小程序模版。 核心技术采用Taro3、Vue3、TypeScript、NutUi、Vux4/Pinia、VueUse
Stars: ✭ 115 (+270.97%)
Mutual labels:  taro, taro3
awesome-codemods
Awesome list of codemods for various languages, libraries and frameworks
Stars: ✭ 98 (+216.13%)
Mutual labels:  codemod
babel-plugin-hyperscript-to-jsx
This plugin transforms react-hyperscript into JSX. Intended to be used as codemod.
Stars: ✭ 20 (-35.48%)
Mutual labels:  codemod
TaroCreator
微信小程序 小程序模板 小程序可视化设计工具 Taro Taro UI
Stars: ✭ 60 (+93.55%)
Mutual labels:  taro
codemod-v4
codemod cli for antd v4 upgrade
Stars: ✭ 84 (+170.97%)
Mutual labels:  codemod
taro-tax
taro版个税小程序
Stars: ✭ 12 (-61.29%)
Mutual labels:  taro
moment-dayjs-codemod
A Codemod to migrate from moment.js to day.js
Stars: ✭ 20 (-35.48%)
Mutual labels:  codemod
natsuha-weather
Natsuha Weather for WeChat Mini Program.
Stars: ✭ 33 (+6.45%)
Mutual labels:  taro
taro-ts-mobx-boilerplate
Taro 脚手架 Typescript/ Mobx / icon font / Jest
Stars: ✭ 12 (-61.29%)
Mutual labels:  taro
taro-yanxuan
首个 Taro 多端统一实例 - 网易严选(小程序 + H5 + React Native) - By 趣店 FED
Stars: ✭ 2,527 (+8051.61%)
Mutual labels:  taro
ember-data-codemod
A codemod to upgrade to new ember-data packages
Stars: ✭ 13 (-58.06%)
Mutual labels:  codemod
Ts Migrate
A tool to help migrate JavaScript code quickly and conveniently to TypeScript
Stars: ✭ 4,246 (+13596.77%)
Mutual labels:  codemod
tiny-treeshaker
🌳🥤 A tiny codemod for tree shaking (experimental) 🌳🥤
Stars: ✭ 92 (+196.77%)
Mutual labels:  codemod
font-awesome-codemod
⚙️ Font Awesome codemod script
Stars: ✭ 46 (+48.39%)
Mutual labels:  codemod
ember-angle-brackets-codemod
Codemod to convert curly braces syntax to angle brackets syntax
Stars: ✭ 58 (+87.1%)
Mutual labels:  codemod
rn-update-deprecated-modules
Codemod to update import declarations as per react-native > 0.59.x deprecations.
Stars: ✭ 73 (+135.48%)
Mutual labels:  codemod
share
notes or share of vue,react,flutter...
Stars: ✭ 32 (+3.23%)
Mutual labels:  taro
miniapp
使用 Rax 语法(类 React)编写跨多端的小程序应用。
Stars: ✭ 65 (+109.68%)
Mutual labels:  taro
vantui
基于vant-weapp实现的Taro-React版及H5-React版组件库https://antmjs.github.io/vantui/#/home
Stars: ✭ 454 (+1364.52%)
Mutual labels:  taro

taro2-to-3

帮助你将 Taro 2.x 项目升级到 Taro 3.x 项目,基于 jscodeshift 构建。

该工具的处理规则参考 Taro 官方 迁移指南

动机

愿将 Taro 2.x 项目升级到 Taro 3.x 项目的过程变得轻松愉悦。

使用

在运行前,请先提交你的本地代码修改。

# 全局安装
npm i -g taro2-to-3
# or for yarn user
#  yarn global add taro2-to-3
taro2-to-3

已知问题

  1. Taro 内部 __taroRouterChange 事件参数变更,h5 中参数发生变化,小程序中不触发 NervJS/taro#7903
  2. Taro 3.2.x 以上版本中 preloadData api 发生变更 https://github.com/NervJS/taro/commit/d2c4aaf5d9d755bc3ca40f9b449340b360c673d5
  3. 缺失对 this.$scope api 进行转换 NervJS/taro#7795

处理流程

  1. 读取 Taro 项目中的编译配置文件 config/index.js.
    1. 读取其中的配置项 sourceRoot ,获取项目入口文件所在目录。
    2. 更新编译配置文件。
  2. 读取当前项目中的入口文件,如 {sourceRoot}/app.js
    1. 读取其中的配置项 pages ,获取项目中所有的页面路径。
    2. 更新入口文件。
  3. 执行以下脚本。
  4. 读取项目的 package.json 文件,检查并更新依赖。

脚本包括

taro-imports

在 Taro 2.x 中,所有面向应用开发者的 API 都在 @tarojs/taro 包中。

在 Taro 3.x 中,将 React 的 API 从 react 包中引入,其它的 API 仍然从 @tarojs/taro 引入。

- import Taro, { Component } from '@tarojs/taro';
+ import React, { Component } from '@tarojs/taro';
+ import Taro from '@tarojs/taro';

class Wallace extends Component {
    componentDidMount() {
        Taro.request().then(() => {});
    }
    render() {
        return <div />;
    }
}

page-config

在 Taro 2.x 中,页面的配置挂载在类组件的类属性或函数式的属性上,通过 AST 分析取出来,然后生成 JSON 文件。

在 Taro 3.x 中,使用 *.config.js ,该文件和页面文件在同一文件夹。

// foo.jsx
export default class Index extends Component {
-   config = {
-       navigationBarTitleText: '首页'
-   }
    render() {
        return null;
    }
}

+// foo.config.js
+export default config = {
+   navigationBarTitleText: '首页'
+};

router

在 Taro 2.x 中,通过 this.$router 访问当前组件/页面路由的详情。

在 Taro 3.x 等价的 API 是 @tarojs/taro 包中的 getCurrentInstance().router。

class Foo extends Component {
+   $instance = getCurrentInstance();
    componentWillMount() {
-       console.log(this.$router);
+       console.log(this.$instance.router)
    }
}

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].