Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 从2.x迁移taro-transform-wx模块,升级taroize和taro-transform-wx到babel7 #10

Merged
merged 2 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module.exports = {
'react/prop-types': 0,
'react/no-find-dom-node': 0,
'react/no-unknown-property': 0,
'import/no-named-default': 'off',
quotes: [2, 'single', { avoidEscape: true, allowTemplateLiterals: true }],
semi: [2, 'never'],
'simple-import-sort/imports': [2, {
Expand Down
17 changes: 17 additions & 0 deletions packages/postcss-unit-transform/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint'
],
parserOptions: { },
extends: [
'eslint:recommended',
'standard',
'plugin:@typescript-eslint/recommended',
'prettier'
],
rules: {
'@typescript-eslint/no-unused-vars': 0,
'@typescript-eslint/no-var-requires': 0
}
}
3 changes: 3 additions & 0 deletions packages/postcss-unit-transform/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# postcss-taro-unit-transform

小程序的单位转换
17 changes: 17 additions & 0 deletions packages/postcss-unit-transform/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const postcss = require('postcss')

module.exports = postcss.plugin('postcss-taro-unit-transform', plugin)

function plugin (opts) {
return function (root) {
root.walkDecls(function (decl) {
let value = decl.value
value = value.replace(/([0-9.]+)px/ig, function (match, size) {
return (parseInt(size, 10) * 2) + 'px'
}).replace(/([0-9.]+)rpx/ig, function (match, size) {
return size + 'px'
})
decl.value = value
})
}
}
19 changes: 19 additions & 0 deletions packages/postcss-unit-transform/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "postcss-taro-unit-transform",
"version": "3.6.8",
"description": "小程序单位转换",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "luckyadam",
"license": "MIT",
"dependencies": {
"postcss": "^6.0.21",
"typescript": "^4.7.4"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0"
}
}
53 changes: 53 additions & 0 deletions packages/postcss-unit-transform/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


ansi-styles@^3.2.1:
version "3.2.1"
resolved "https://registry.npm.taobao.org/ansi-styles/download/ansi-styles-3.2.1.tgz?cache=0&sync_timestamp=1589682811931&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fansi-styles%2Fdownload%2Fansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
dependencies:
color-convert "^1.9.0"

chalk@^2.4.1:
version "2.4.2"
resolved "https://registry.npm.taobao.org/chalk/download/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
dependencies:
ansi-styles "^3.2.1"
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"

color-convert@^1.9.0:
version "1.9.3"
resolved "https://registry.npm.taobao.org/color-convert/download/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
dependencies:
color-name "1.1.3"

[email protected]:
version "1.1.3"
resolved "https://registry.npm.taobao.org/color-name/download/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"

escape-string-regexp@^1.0.5:
version "1.0.5"
resolved "https://registry.npm.taobao.org/escape-string-regexp/download/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"

has-flag@^3.0.0:
version "3.0.0"
resolved "https://registry.npm.taobao.org/has-flag/download/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"

postcss@^6.0.21:
version "6.0.23"
resolved "https://registry.npm.taobao.org/postcss/download/postcss-6.0.23.tgz#61c82cc328ac60e677645f979054eb98bc0e3324"
dependencies:
chalk "^2.4.1"
source-map "^0.6.1"
supports-color "^5.4.0"

source-map@^0.6.1:
version "0.6.1"
resolved "https://registry.npm.taobao.org/source-map/download/source-map-0.6.1.tgz?cache=0&sync_timestamp=1589682764497&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsource-map%2Fdownload%2Fsource-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"

supports-color@^5.3.0, supports-color@^5.4.0:
version "5.5.0"
resolved "https://registry.npm.taobao.org/supports-color/download/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
dependencies:
has-flag "^3.0.0"
11 changes: 6 additions & 5 deletions packages/taro-cli-convertor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@
"author": "O2Team",
"license": "MIT",
"dependencies": {
"@babel/generator": "^7.20.0",
"@babel/template": "^7.20.0",
"@babel/traverse": "^7.20.0",
"@babel/types": "^7.20.0",
"@tarojs/cli": "workspace:*",
"@tarojs/helper": "workspace:*",
"@tarojs/taroize": "workspace:*",
"@tarojs/cli": "workspace:*",
"@tarojs/transformer-wx": "^2.2.10",
"postcss-taro-unit-transform": "^2.2.10",
"prettier": "^2.7.1",
"postcss": "^8.4.18"
"@tarojs/transformer-wx": "workspace:*",
"postcss": "^8.4.18",
"postcss-taro-unit-transform": "workspace:*",
"prettier": "^2.7.1"
},
"devDependencies": {
"@babel/parser": "^7.14.5",
Expand Down
14 changes: 9 additions & 5 deletions packages/taro-cli-convertor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export default class Convertor {
template(
`import ${importName} from '${promoteRelativePath(path.relative(outputFilePath, importPath))}'`,
babylonConfig
)()
)() as t.Statement
)
})
}
Expand All @@ -360,7 +360,7 @@ export default class Convertor {
template(
`import ${name} from '${promoteRelativePath(path.relative(sourceFilePath, component))}'`,
babylonConfig
)()
)() as t.Statement
)
})
}
Expand Down Expand Up @@ -896,13 +896,17 @@ ${code}
date,
projectName,
framework: this.framework,
compiler: 'webpack5'
compiler: 'webpack5',
typescript: false
})
creator.template(templateName, path.join('config', 'dev.js'), path.join(configDir, 'dev.js'), {
framework: this.framework
framework: this.framework,
compiler: 'webpack5',
typescript: false
})
creator.template(templateName, path.join('config', 'prod.js'), path.join(configDir, 'prod.js'), {
framework: this.framework
framework: this.framework,
typescript: false
})
creator.template(templateName, 'project.config.json', path.join(this.convertRoot, 'project.config.json'), {
description,
Expand Down
4 changes: 4 additions & 0 deletions packages/taro-transformer-wx/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/lib
/node_modules
t.js
tt.js
44 changes: 44 additions & 0 deletions packages/taro-transformer-wx/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module.exports = {
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint'
],
parserOptions: { },
extends: [
'eslint:recommended',
'standard',
'plugin:@typescript-eslint/recommended',
'prettier'
],
rules: {
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/indent': [2, 2],
'@typescript-eslint/member-delimiter-style': [1, { multiline: { delimiter: 'none' }, singleline: { delimiter: 'comma' } }],
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-namespace': 0,
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/no-this-alias': 0,
'@typescript-eslint/no-unused-vars': 0,
'@typescript-eslint/no-use-before-define': [1, { functions: false, classes: false }],
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/ban-types': 0,
'no-restricted-globals': 'off',
'no-cond-assign': 'off',
'no-inner-declarations': 'off',
'no-unmodified-loop-condition': 'off',
'no-return-assign': 'off',
'no-console': 'off',
'no-self-compare': 'off',
'no-control-regex': 'off',
'no-new-func': 'off',
'no-new': 'off',
'prefer-const': 'off',
'no-empty': 'off',
'no-unsafe-optional-chaining': 'off',
'no-prototype-builtins': 'off',
camelcase: 'off'
}
}
12 changes: 12 additions & 0 deletions packages/taro-transformer-wx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
dist
node_modules
.cache
.DS_Store
lerna-debug.log
yarn-error.log
_book
.idea
lib
t.js
tt.js
test.js
28 changes: 28 additions & 0 deletions packages/taro-transformer-wx/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"name": "t.js",
"request": "launch",
"args": ["--runInBand"],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"program": "${workspaceFolder}/t.js"
},
{
"type": "node",
"name": "vscode-jest-tests",
"request": "launch",
"args": ["--runInBand"],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
}
]
}
43 changes: 43 additions & 0 deletions packages/taro-transformer-wx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="0.0.69-beta.1"></a>
## [0.0.69-beta.1](https://github.com/NervJS/taro/compare/v0.0.69-beta.0...v0.0.69-beta.1) (2018-07-09)


### Features

* **transformer:** 支持 style 传入对象 ([d0be191](https://github.com/NervJS/taro/commit/d0be191))




<a name="0.0.67-beta.3"></a>
## [0.0.67-beta.3](https://github.com/NervJS/taro/compare/v0.0.67-beta.2...v0.0.67-beta.3) (2018-07-04)


### Bug Fixes

* **transformer:** 单独使用的自定义也加入 key ([a231a90](https://github.com/NervJS/taro/commit/a231a90))
* **transformer:** 所有设置 if 条件都加入 block ([a32661e](https://github.com/NervJS/taro/commit/a32661e))




<a name="0.0.67-beta.1"></a>
## [0.0.67-beta.1](https://github.com/NervJS/taro/compare/v0.0.67-beta.0...v0.0.67-beta.1) (2018-07-04)




**Note:** Version bump only for package @tarojs/transformer-wx

<a name="0.0.67-beta.0"></a>
## [0.0.67-beta.0](https://github.com/NervJS/taro/compare/v0.0.66...v0.0.67-beta.0) (2018-07-04)


### Bug Fixes

* **transformer:** 循环自定义组件的 iterator 重命名 ([a9cf461](https://github.com/NervJS/taro/commit/a9cf461))
3 changes: 3 additions & 0 deletions packages/taro-transformer-wx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @tarojs/transformer-wx

把 JSX 语法转换成可以在小程序运行的字符串模板。
4 changes: 4 additions & 0 deletions packages/taro-transformer-wx/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var transform = require('./lib/src').default

module.exports = transform
module.exports.default = transform
Loading