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

chore: drop @babel/plugin-proposal-class-properties #17385

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public-hoist-pattern[]=@types/*
public-hoist-pattern[]=*eslint*
public-hoist-pattern[]=*jest*
public-hoist-pattern[]=*prettier*
registry="https://registry.yarnpkg.com/"

strict-peer-dependencies=false

{SCOPE}:registry=https://npm.pkg.github.com
2 changes: 1 addition & 1 deletion examples/swiper-effect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
},
"devDependencies": {
"@babel/core": "^7.24.4",
"@babel/plugin-proposal-class-properties": "7.14.5",
"@babel/plugin-transform-class-properties": "7.25.9",
"@babel/preset-react": "^7.24.1",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
"@tarojs/cli": "4.0.7",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@babel/core",
"@babel/helper-plugin-utils",
"@babel/parser",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-class-properties",
"@babel/plugin-proposal-decorators",
"@babel/plugin-proposal-do-expressions",
"@babel/plugin-proposal-object-rest-spread",
Expand Down Expand Up @@ -156,8 +156,8 @@
"stylelint-order": "^6.0.4",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.1",
"typescript": "~5.4.5",
"tslib": "^2.6.2",
"typescript": "~5.4.5",
"vitest": "^1.6.0"
},
"pnpm": {
Expand Down
18 changes: 9 additions & 9 deletions packages/babel-preset-taro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = {

- `@babel/plugin-transform-runtime`
- `@babel/plugin-proposal-decorators`
- `@babel/plugin-proposal-class-properties`
- `@babel/plugin-transform-class-properties`
- `babel-plugin-dynamic-import-node`(小程序环境)

#### 2. React
Expand Down Expand Up @@ -150,7 +150,7 @@ import "core-js/modules/es.string.pad-end";

**默认值**:`false`

同时是 `@babel/preset-env`、`@babel/plugin-proposal-class-properties` 的 `loose` 配置项。
同时是 `@babel/preset-env`、`@babel/plugin-transform-class-properties` 的 `loose` 配置项。

### debug

Expand All @@ -167,23 +167,23 @@ import "core-js/modules/es.string.pad-end";
### spec

`@babel/preset-env` 的 [spec](https://babeljs.io/docs/en/babel-preset-env#spec) 配置项。

### configPath

`@babel/preset-env` 的 [configPath](https://babeljs.io/docs/en/babel-preset-env#configpath) 配置项。

### include

`@babel/preset-env` 的 [include](https://babeljs.io/docs/en/babel-preset-env#include) 配置项。

### exclude

`@babel/preset-env` 的 [exclude](https://babeljs.io/docs/en/babel-preset-env#exclude) 配置项。

### shippedProposals

`@babel/preset-env` 的 [shippedProposals](https://babeljs.io/docs/en/babel-preset-env#shippedproposals) 配置项。

### forceAllTransforms

`@babel/preset-env` 的 [forceAllTransforms](https://babeljs.io/docs/en/babel-preset-env#forcealltransforms) 配置项。
Expand All @@ -203,14 +203,14 @@ import "core-js/modules/es.string.pad-end";

**默认值**:开发者根目录 `node_modules` 中的 `@babel/plugin-transform-runtime` 的路径。

**类型**:`string`
**类型**:`string`

`@babel/plugin-transform-runtime` 的 [absoluteRuntime](https://babeljs.io/docs/en/babel-plugin-transform-runtime#absoluteruntime) 配置项。

### version

**默认值**:开发者根目录 `node_modules` 中的 `@babel/plugin-transform-runtime` 的版本号。

**类型**:`string`
**类型**:`string`

`@babel/plugin-transform-runtime` 的 [version](https://babeljs.io/docs/en/babel-plugin-transform-runtime#version) 配置项。
8 changes: 4 additions & 4 deletions packages/babel-preset-taro/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ module.exports = (_, options = {}) => {
forceAllTransforms,
}

let transformRuntimeCorejs = false
let transformRuntimeCoreJs = false
if (useBuiltIns === 'usage') {
transformRuntimeCorejs = 3
transformRuntimeCoreJs = 3
} else {
envOptions.useBuiltIns = useBuiltIns
if (useBuiltIns === 'entry') {
Expand All @@ -183,14 +183,14 @@ module.exports = (_, options = {}) => {
legacy: decoratorsLegacy !== false,
},
],
[require('@babel/plugin-proposal-class-properties'), { loose }]
[require('@babel/plugin-transform-class-properties'), { loose }]
)

plugins.push([
require('@babel/plugin-transform-runtime'),
{
regenerator: true,
corejs: transformRuntimeCorejs,
corejs: transformRuntimeCoreJs,
helpers: true,
useESModules: process.env.NODE_ENV !== 'test',
absoluteRuntime,
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset-taro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"dependencies": {
"@babel/plugin-proposal-decorators": "^7.24.1",
"@babel/plugin-transform-class-properties": "^7.24.1",
"@babel/plugin-transform-class-properties": "^7.25.9",
"@babel/plugin-transform-runtime": "^7.24.3",
"@babel/preset-env": "^7.24.4",
"@babel/preset-typescript": "^7.24.1",
Expand Down
16 changes: 8 additions & 8 deletions packages/taro-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,27 @@
"@tarojs/plugin-doctor": "^0.0.13",
"@tarojs/service": "workspace:*",
"@tarojs/shared": "workspace:*",
"adm-zip": "^0.5.12",
"axios": "^1.6.8",
"adm-zip": "^0.5.16",
"axios": "^1.8.1",
"cli-highlight": "^2.1.11",
"download-git-repo": "^3.0.2",
"envinfo": "^7.12.0",
"envinfo": "^7.14.0",
"inquirer": "^8.2.6",
"latest-version": "^5.1.0",
"minimist": "^1.2.8",
"ora": "^5.4.1",
"semver": "^7.6.0",
"validate-npm-package-name": "^5.0.0"
"semver": "^7.7.1",
"validate-npm-package-name": "^5.0.1"
},
"devDependencies": {
"@babel/types": "^7.24.0",
"@babel/types": "^7.26.9",
"@tarojs/plugin-platform-h5": "workspace:*",
"@tarojs/plugin-platform-weapp": "workspace:*",
"@tarojs/taro": "workspace:*",
"@tarojs/webpack5-runner": "workspace:*",
"@types/babel__traverse": "^7.20.6",
"babel-preset-taro": "workspace:*",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.4.0"
"eslint-plugin-react": "^7.37.4",
"eslint-plugin-react-hooks": "^4.6.2"
}
}
8 changes: 2 additions & 6 deletions packages/taro-cli/src/create/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default class Page extends Creator {
public conf: IPageConf
private modifyCustomTemplateConfig: TGetCustomTemplate
private afterCreate: TAfterCreate | undefined
private pageEntryPath: string
private pageEntryPath: string = ''

constructor (args: IPageArgs) {
super()
Expand Down Expand Up @@ -214,17 +214,13 @@ export default class Page extends Creator {
plugins: typescript ? ['typescript'] : []
})

const callback = (state: ConfigModificationState) => {
modifyState = state
}

traverse(ast, {
ExportDefaultDeclaration (path) {
modifyPagesOrSubPackages({
path,
fullPagePath: pageString,
subPkgRootPath: subPkg,
callback
callback: (state: ConfigModificationState) => { modifyState = state }
})
},
})
Expand Down
5 changes: 2 additions & 3 deletions packages/taro-cli/templates/default/package.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"devDependencies": {
"@babel/core": "^7.24.4",
"@tarojs/cli": "{{ version }}",
"@babel/plugin-proposal-class-properties": "7.14.5",
"@babel/plugin-transform-class-properties": "7.25.9",
"@types/webpack-env": "^1.13.6",{{#if (includes "React" "Preact" s=framework)}}
"@types/react": "^18.0.0",{{/if}}{{#if (eq compiler "Webpack5") }}
"webpack": "5.91.0",
Expand Down Expand Up @@ -111,7 +111,7 @@
}{{/if}}{{#if (eq compiler "Vite") }}
"devDependencies": {
"@babel/core": "^7.24.4",
"@babel/plugin-proposal-class-properties": "7.14.5",
"@babel/plugin-transform-class-properties": "7.25.9",
"@tarojs/cli": "{{ version }}",
"@tarojs/vite-runner": "{{ version }}",
"babel-preset-taro": "{{ version }}",
Expand Down Expand Up @@ -140,4 +140,3 @@
"postcss": "^8.4.38"
}{{/if}}
}

2 changes: 1 addition & 1 deletion packages/taro-components/babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"power-assert"
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-class-properties",
"@babel/plugin-proposal-object-rest-spread"
],
"babelrcRoots": ["./h5/*"]
Expand Down
4 changes: 2 additions & 2 deletions packages/taro-framework-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ function VitePresetPlugin (framework: Frameworks): PluginOption {
babel: {
plugins: [
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
['@babel/plugin-transform-class-properties', { loose: true }],
],
},
})
: require('@vitejs/plugin-react').default({
babel: {
plugins: [
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
['@babel/plugin-transform-class-properties', { loose: true }],
],
},
})
Expand Down
32 changes: 16 additions & 16 deletions packages/taro-helper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,32 @@
},
"homepage": "https://github.com/NervJS/taro#readme",
"dependencies": {
"@babel/core": "^7.24.4",
"@babel/generator": "^7.24.4",
"@babel/parser": "^7.24.4",
"@babel/traverse": "^7.24.1",
"@babel/types": "^7.24.0",
"@swc/core": "1.3.96",
"@swc/register": "0.1.10",
"@babel/core": "^7.26.9",
"@babel/generator": "^7.26.9",
"@babel/parser": "^7.26.9",
"@babel/traverse": "^7.26.9",
"@babel/types": "^7.26.9",
"@swc/core": "1.11.7",
"@swc/register": "^0.1.10",
"ansi-escapes": "^4.3.2",
"chalk": "^4.1.2",
"chokidar": "^3.6.0",
"cross-spawn": "^7.0.3",
"debug": "^4.3.4",
"dotenv": "^16.4.5",
"dotenv-expand": "^11.0.6",
"esbuild": "~0.21.0",
"cross-spawn": "^7.0.6",
"debug": "^4.4.0",
"dotenv": "^16.4.7",
"dotenv-expand": "^11.0.7",
"esbuild": "~0.21.5",
"find-yarn-workspace-root": "^2.0.0",
"fs-extra": "^11.2.0",
"fs-extra": "^11.3.0",
"lodash": "^4.17.21",
"require-from-string": "^2.0.2",
"resolve": "^1.22.8",
"supports-hyperlinks": "^3.0.0"
"resolve": "^1.22.10",
"supports-hyperlinks": "^3.2.0"
},
"devDependencies": {
"@tarojs/taro": "workspace:*",
"@types/babel__core": "^7.20.5",
"@types/babel__generator": "^7.6.8",
"@types/babel__traverse": "^7.20.5"
"@types/babel__traverse": "^7.20.6"
}
}
4 changes: 2 additions & 2 deletions packages/taro-helper/src/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function resolveNpmSync(pluginName: string, root?: string): string {
return res
}
return npmCached[pluginName]
} catch (err) {
} catch (err: any) {
if (err.code === 'MODULE_NOT_FOUND') {
console.log(chalk.cyan(`缺少npm包${pluginName},开始安装...`))
const installOptions: IInstallOptions = {
Expand Down Expand Up @@ -168,7 +168,7 @@ export async function getNpmPkg(npmName: string, root: string) {
let npmPath
try {
npmPath = resolveNpmSync(npmName, root)
} catch (err) {
} catch (err: any) {
if (err.code === 'MODULE_NOT_FOUND') {
console.log(chalk.cyan(`缺少npm包${npmName},开始安装...`))
const installOptions: IInstallOptions = {
Expand Down
7 changes: 4 additions & 3 deletions packages/taro-helper/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,9 +603,10 @@ function readSFCPageConfig(configPath: string) {
p.stop()
}
const configSource = matches[0]
const ast = babel.parse(configSource, { filename: '' }) as babel.ParseResult

babel.traverse(ast.program, { CallExpression: callExprHandler })
const ast = babel.parseSync(configSource, { filename: '' })
if (ast) {
babel.traverse(ast.program, { CallExpression: callExprHandler })
}
}

return result
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-rn/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// 由 getLibList.js 脚本生成, 不要进行手动修改, 请不要手动修改
export * from './ENV_TYPE'
export * from './arrayBufferToBase64'
export * from './authorize'
export * from './base64ToArrayBuffer'
Expand All @@ -16,6 +15,7 @@ export * from './createInnerAudioContext'
export * from './createSelectorQuery'
export * from './createVideoContext'
export * from './downloadFile'
export * from './ENV_TYPE'
export * from './getAppBaseInfo'
export * from './getClipboardData'
export * from './getEnv'
Expand Down
Loading