Skip to content

Commit 62d9359

Browse files
committed
fix: 从2.x迁移taro-transform-wx模块,升级taroize和taro-transform-wx到babel7
1 parent 2561c80 commit 62d9359

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+12951
-95
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ module.exports = {
4848
'react/prop-types': 0,
4949
'react/no-find-dom-node': 0,
5050
'react/no-unknown-property': 0,
51+
'import/no-named-default': 'off',
5152
quotes: [2, 'single', { avoidEscape: true, allowTemplateLiterals: true }],
5253
semi: [2, 'never'],
5354
'simple-import-sort/imports': [2, {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
plugins: [
4+
'@typescript-eslint'
5+
],
6+
parserOptions: { },
7+
extends: [
8+
'eslint:recommended',
9+
'standard',
10+
'plugin:@typescript-eslint/recommended',
11+
'prettier'
12+
],
13+
rules: {
14+
'@typescript-eslint/no-unused-vars': 0,
15+
'@typescript-eslint/no-var-requires': 0
16+
}
17+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# postcss-taro-unit-transform
2+
3+
小程序的单位转换
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const postcss = require('postcss')
2+
3+
module.exports = postcss.plugin('postcss-taro-unit-transform', plugin)
4+
5+
function plugin (opts) {
6+
return function (root) {
7+
root.walkDecls(function (decl) {
8+
let value = decl.value
9+
value = value.replace(/([0-9.]+)px/ig, function (match, size) {
10+
return (parseInt(size, 10) * 2) + 'px'
11+
}).replace(/([0-9.]+)rpx/ig, function (match, size) {
12+
return size + 'px'
13+
})
14+
decl.value = value
15+
})
16+
}
17+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "postcss-taro-unit-transform",
3+
"version": "3.6.8",
4+
"description": "小程序单位转换",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "luckyadam",
10+
"license": "MIT",
11+
"dependencies": {
12+
"postcss": "^6.0.21",
13+
"typescript": "^4.7.4"
14+
},
15+
"devDependencies": {
16+
"@typescript-eslint/eslint-plugin": "^5.17.0",
17+
"@typescript-eslint/parser": "^5.17.0"
18+
}
19+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
ansi-styles@^3.2.1:
6+
version "3.2.1"
7+
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"
8+
dependencies:
9+
color-convert "^1.9.0"
10+
11+
chalk@^2.4.1:
12+
version "2.4.2"
13+
resolved "https://registry.npm.taobao.org/chalk/download/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
14+
dependencies:
15+
ansi-styles "^3.2.1"
16+
escape-string-regexp "^1.0.5"
17+
supports-color "^5.3.0"
18+
19+
color-convert@^1.9.0:
20+
version "1.9.3"
21+
resolved "https://registry.npm.taobao.org/color-convert/download/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
22+
dependencies:
23+
color-name "1.1.3"
24+
25+
26+
version "1.1.3"
27+
resolved "https://registry.npm.taobao.org/color-name/download/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
28+
29+
escape-string-regexp@^1.0.5:
30+
version "1.0.5"
31+
resolved "https://registry.npm.taobao.org/escape-string-regexp/download/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
32+
33+
has-flag@^3.0.0:
34+
version "3.0.0"
35+
resolved "https://registry.npm.taobao.org/has-flag/download/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
36+
37+
postcss@^6.0.21:
38+
version "6.0.23"
39+
resolved "https://registry.npm.taobao.org/postcss/download/postcss-6.0.23.tgz#61c82cc328ac60e677645f979054eb98bc0e3324"
40+
dependencies:
41+
chalk "^2.4.1"
42+
source-map "^0.6.1"
43+
supports-color "^5.4.0"
44+
45+
source-map@^0.6.1:
46+
version "0.6.1"
47+
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"
48+
49+
supports-color@^5.3.0, supports-color@^5.4.0:
50+
version "5.5.0"
51+
resolved "https://registry.npm.taobao.org/supports-color/download/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
52+
dependencies:
53+
has-flag "^3.0.0"

packages/taro-cli-convertor/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@
3030
"author": "O2Team",
3131
"license": "MIT",
3232
"dependencies": {
33+
"@babel/generator": "^7.20.0",
3334
"@babel/template": "^7.20.0",
3435
"@babel/traverse": "^7.20.0",
3536
"@babel/types": "^7.20.0",
37+
"@tarojs/cli": "workspace:*",
3638
"@tarojs/helper": "workspace:*",
3739
"@tarojs/taroize": "workspace:*",
38-
"@tarojs/cli": "workspace:*",
39-
"@tarojs/transformer-wx": "^2.2.10",
40-
"postcss-taro-unit-transform": "^2.2.10",
41-
"prettier": "^2.7.1",
42-
"postcss": "^8.4.18"
40+
"@tarojs/transformer-wx": "workspace:*",
41+
"postcss": "^8.4.18",
42+
"postcss-taro-unit-transform": "workspace:*",
43+
"prettier": "^2.7.1"
4344
},
4445
"devDependencies": {
4546
"@babel/parser": "^7.14.5",

packages/taro-cli-convertor/src/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ export default class Convertor {
348348
template(
349349
`import ${importName} from '${promoteRelativePath(path.relative(outputFilePath, importPath))}'`,
350350
babylonConfig
351-
)()
351+
)() as t.Statement
352352
)
353353
})
354354
}
@@ -360,7 +360,7 @@ export default class Convertor {
360360
template(
361361
`import ${name} from '${promoteRelativePath(path.relative(sourceFilePath, component))}'`,
362362
babylonConfig
363-
)()
363+
)() as t.Statement
364364
)
365365
})
366366
}
@@ -896,13 +896,17 @@ ${code}
896896
date,
897897
projectName,
898898
framework: this.framework,
899-
compiler: 'webpack5'
899+
compiler: 'webpack5',
900+
typescript: false
900901
})
901902
creator.template(templateName, path.join('config', 'dev.js'), path.join(configDir, 'dev.js'), {
902-
framework: this.framework
903+
framework: this.framework,
904+
compiler: 'webpack5',
905+
typescript: false
903906
})
904907
creator.template(templateName, path.join('config', 'prod.js'), path.join(configDir, 'prod.js'), {
905-
framework: this.framework
908+
framework: this.framework,
909+
typescript: false
906910
})
907911
creator.template(templateName, 'project.config.json', path.join(this.convertRoot, 'project.config.json'), {
908912
description,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/lib
2+
/node_modules
3+
t.js
4+
tt.js
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
plugins: [
4+
'@typescript-eslint'
5+
],
6+
parserOptions: { },
7+
extends: [
8+
'eslint:recommended',
9+
'standard',
10+
'plugin:@typescript-eslint/recommended',
11+
'prettier'
12+
],
13+
rules: {
14+
'@typescript-eslint/ban-ts-comment': 0,
15+
'@typescript-eslint/explicit-function-return-type': 0,
16+
'@typescript-eslint/explicit-module-boundary-types': 0,
17+
'@typescript-eslint/indent': [2, 2],
18+
'@typescript-eslint/member-delimiter-style': [1, { multiline: { delimiter: 'none' }, singleline: { delimiter: 'comma' } }],
19+
'@typescript-eslint/no-empty-function': 0,
20+
'@typescript-eslint/no-explicit-any': 0,
21+
'@typescript-eslint/no-namespace': 0,
22+
'@typescript-eslint/no-non-null-assertion': 0,
23+
'@typescript-eslint/no-this-alias': 0,
24+
'@typescript-eslint/no-unused-vars': 0,
25+
'@typescript-eslint/no-use-before-define': [1, { functions: false, classes: false }],
26+
'@typescript-eslint/no-var-requires': 0,
27+
'@typescript-eslint/ban-types': 0,
28+
'no-restricted-globals': 'off',
29+
'no-cond-assign': 'off',
30+
'no-inner-declarations': 'off',
31+
'no-unmodified-loop-condition': 'off',
32+
'no-return-assign': 'off',
33+
'no-console': 'off',
34+
'no-self-compare': 'off',
35+
'no-control-regex': 'off',
36+
'no-new-func': 'off',
37+
'no-new': 'off',
38+
'prefer-const': 'off',
39+
'no-empty': 'off',
40+
'no-unsafe-optional-chaining': 'off',
41+
'no-prototype-builtins': 'off',
42+
camelcase: 'off'
43+
}
44+
}

0 commit comments

Comments
 (0)