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: [4.x]修复小程序端solid的响应式丢失问题 #15512

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
8305025
fix(solid): 删除h函数
phy-lei Apr 12, 2024
8cb9ce1
feat: add babel-plugin-transform-solid-jsx-ad-taro-components
phy-lei Apr 14, 2024
bee5785
feat: 完成babel的solid插件,在小程序端准确编译taroComponent
phy-lei Apr 14, 2024
0122b5b
chore(babel-solid): 入口文件修改为适配babel的入口
phy-lei Apr 14, 2024
7e409bf
feat(babel-solid): 解耦getTagName
phy-lei Apr 14, 2024
de4b178
fix(solid-babel): 修复solid中对于@tarojs/components的无引用import,收集不到小程序组件bug
phy-lei Apr 15, 2024
54c32be
feat(babel-solid): 修改项目的readme及license
phy-lei Apr 15, 2024
176d4ef
feat(babel-solid): 插件添加h5判断,h5不进行组件转换
phy-lei Apr 15, 2024
e628bff
chore: 修改打包文件路径
phy-lei Apr 15, 2024
5e36a0f
feat(babel-solid): 添加测试用例
phy-lei Apr 15, 2024
c1f6264
chore: eslint ignore babel solid
phy-lei Apr 15, 2024
32fc777
chore: 同步收集小程序组件到其他runner中
phy-lei Apr 15, 2024
da197bf
chore
phy-lei Apr 15, 2024
d3260c8
Merge branch '4.x' of https://github.com/NervJS/taro into fix/solid-r…
phy-lei Apr 15, 2024
2b7c69d
feat: add stencil-solid-output-target
phy-lei Apr 13, 2024
39543bd
chore
phy-lei Apr 16, 2024
13c8f94
feat: 自定义solid-stencil-output
phy-lei Apr 16, 2024
499cd10
feat: 初步完成stencil的solid打包
phy-lei Apr 16, 2024
56fdb46
fix(h5-solid): 顺利编译taro的component,但响应式丢失
phy-lei Apr 16, 2024
04d6142
chore: 调整stencil-solid的createComponent
phy-lei Apr 17, 2024
da112af
fix(h5-solid): 修复web-component的solid连接器编译错乱
phy-lei Apr 18, 2024
946a1de
fix(h5-solid): 完善stencil-solid的连接器,解决props响应式丢失
phy-lei Apr 18, 2024
cc132ba
feat: 优化solid-createComponent代码
phy-lei Apr 19, 2024
9504f30
Merge branch '4.x' of https://github.com/NervJS/taro into fix/solid-r…
phy-lei Apr 19, 2024
5f11ae0
Merge branch 'fix/solid-reactive' of github.com:phy-lei/taro into fix…
phy-lei Apr 19, 2024
55014aa
chore
phy-lei Apr 19, 2024
8b2645d
fix: 修复classList失效的bug
phy-lei Apr 19, 2024
4e19050
feat: 响应式props及element event不通过props绑定,会造成el多余props显示,采用setAttribute及…
phy-lei Apr 19, 2024
354a9f2
chore
phy-lei Apr 19, 2024
c76aa9f
chore: stencil的component同步solid对dom的api调用
phy-lei Apr 24, 2024
3f135a8
chore: 修改babel-solid文件命名
phy-lei May 3, 2024
e840c0e
chore: 修改babel-solid相关的工程化配置
phy-lei May 3, 2024
c04ef10
chore: 类型命名修改
phy-lei May 3, 2024
18f324c
chore: eslintignore采用根目录的
phy-lei May 3, 2024
baba7e9
Merge branches 'fix/solid-reactive-h5' and 'fix/solid-reactive' of gi…
phy-lei May 3, 2024
b7cc39e
Merge branch '4.x' of https://github.com/NervJS/taro into fix/solid-r…
phy-lei May 3, 2024
3b1ae39
Merge branch 'fix/solid-reactive' of github.com:phy-lei/taro into fix…
phy-lei May 3, 2024
1066762
Merge branch '4.x' of https://github.com/NervJS/taro into fix/solid-r…
phy-lei May 6, 2024
25e68e7
chore: sort packages
phy-lei May 6, 2024
a8432b9
fix: babel-solid的ignore加入,修复eslint暴露的问题
phy-lei May 6, 2024
3b690de
chore
phy-lei May 6, 2024
893bd6e
Merge branch 'fix/solid-reactive' of github.com:phy-lei/taro into fix…
phy-lei May 6, 2024
453727a
chore: solid-components打包对于solid-js及tarojs的包使用外部依赖
phy-lei May 13, 2024
2101c55
chore: 格式化
phy-lei May 13, 2024
455fbb7
Merge branch '4.x' into fix/solid-reactive-h5
Jun 3, 2024
5f50ced
refactor: 依赖治理
Jun 3, 2024
33b539c
refactor: babel-plugin-transform-solid-jsx 测试命令
Jun 3, 2024
34d580c
fix: 解决合并造成的问题
Jun 3, 2024
f63e1ce
Merge branch '4.x' into fix/solid-reactive
Jun 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ packages/taro-plugin-vue-devtools/src/backend

packages/taro-helper/swc
crates

packages/babel-plugin-transform-solid-jsx-ad-taro-components/test
phy-lei marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ artifacts
*.node

# harmony-hybrid extend-h5-apis file
packages/taro-platform-harmony-hybrid/src/api/apis/extend-h5-apis.ts
packages/taro-platform-harmony-hybrid/src/api/apis/extend-h5-apis.ts
phy-lei marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,10 @@ Apache-2.0 (intersection-observer):
The following files embed [intersection-observer](https://github.com/GoogleChromeLabs/intersection-observer) Apache-2.0:
`/packages/taro-api/src/polyfill/intersection-observer.ts`
See `/LICENSE.txt` for details of the license.

==================

MIT (babel-plugin-jsx-dom-expressions):
The following files embed [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/blob/main/packages/babel-plugin-jsx-dom-expressions) MIT:
`/packages/babel-plugin-transform-solid-jsx-ad-taro-components/src/*`
See `/LICENSE` for details of the license.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
src/
rollup.config.js
test/
coverage/
.travis.yml
*.config.js
phy-lei marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License
phy-lei marked this conversation as resolved.
Show resolved Hide resolved

Copyright (c) 2018-2019 Ryan Carniato

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# babel-plugin-transform-solid-jsx-ad-taro-components
phy-lei marked this conversation as resolved.
Show resolved Hide resolved

fork from [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/blob/main/packages/babel-plugin-jsx-dom-expressions) version: 0.37.19

This package is a JSX compiler built for [DOM Expressions](https://github.com/ryansolid/dom-expressions) to provide a general JSX to DOM transformation for reactive libraries that do fine grained change detection. This package aims to convert JSX statements to native DOM statements and wrap JSX expressions with functions that can be implemented with the library of your choice. Sort of like a JSX to Hyperscript for fine change detection.

## What Has Been Modified?
- Added uniqueTransform configuration, defaulting to false, indicating that the following processing should not be performed.
- Within the transformElement function of the universal module, perform matching against components from @tarojs/components. Modify the transformation of these components such that they are instead invoked via createElement calls.

### Example
```jsx
import { View, Text, Button } from '@tarojs/components';

const Component = () => {
return (
<View class="index">
<View>
<Text>Hello world! </Text>
</View>
<Button>set class</Button>
</View>
);
};
```

Compiles to:
```jsx
import { createTextNode as _$createTextNode } from "@tarojs/plugin-framework-react/dist/reconciler";
import { insertNode as _$insertNode } from "@tarojs/plugin-framework-react/dist/reconciler";
import { setProp as _$setProp } from "@tarojs/plugin-framework-react/dist/reconciler";
import { createElement as _$createElement } from "@tarojs/plugin-framework-react/dist/reconciler";
import { View, Text, Button } from "@tarojs/components";
export default function Index() {
return function () {
var _el$ = _$createElement("view"),
_el$2 = _$createElement("view"),
_el$3 = _$createElement("text"),
_el$5 = _$createElement("button");
_$insertNode(_el$, _el$2);
_$insertNode(_el$, _el$5);
_$setProp(_el$, "class", "index");
_$insertNode(_el$2, _el$3);
_$insertNode(_el$3, _$createTextNode("Hello world! "));
_$insertNode(_el$5, _$createTextNode("set class"));
return _el$;
}();
}
```

> The purpose of doing so is to ensure compatibility by aligning the compilation results of Taro components within mini programs with those of original tags.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const jsxTransform = require('./dist')

module.exports = function (context, options = {}) {
const plugins = [
[
jsxTransform,
Object.assign(
{
moduleName: 'solid-js/web',
builtIns: [
'For',
'Show',
'Switch',
'Match',
'Suspense',
'SuspenseList',
'Portal',
'Index',
'Dynamic',
'ErrorBoundary',
],
contextToCustomElements: true,
wrapConditionals: true,
generate: 'dom',
uniqueTransform: false,
},
options
),
],
]

return {
plugins,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
'moduleDirectories': ['node_modules', 'packages'],
'testEnvironment': 'jsdom',
'collectCoverageFrom': [
'./index.js'
],
'transform': {
'^.+\\.jsx?$': 'babel-jest'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "babel-plugin-transform-solid-jsx-ad-taro-components",
"description": "A JSX to DOM plugin that wraps expressions for fine grained change detection",
"version": "4.0.0-beta.45",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/NervJS/taro.git"
},
"bugs": {
"url": "https://github.com/NervJS/taro/issues"
},
"readmeFilename": "README.md",
"main": "index.js",
"files": [
"dist"
],
"sideEffects": false,
"scripts": {
"build": "rollup -c --bundleConfigAsCjs",
"test": "pnpm run build && jest --no-cache",
"test:coverage": "pnpm run build && jest --coverage --no-cache",
"prepublishOnly": "pnpm run build",
"prepare": "pnpm run build"
},
"dependencies": {
"@babel/helper-module-imports": "7.18.6",
"@babel/plugin-syntax-jsx": "^7.18.6",
"@babel/types": "^7.20.7",
"html-entities": "2.3.3",
"validate-html-nesting": "^1.2.1"
},
"devDependencies": {
"@babel/core": "^7.8.0",
"@babel/preset-env": "^7.20.2",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"babel-jest": "^29.3.1",
"babel-plugin-tester": "^11.0.4",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.3.1",
"jest-resolve": "^29.3.1",
"jsdom": "^21.0.0",
"rollup": "^4.9.5",
"rollup-plugin-node-externals": "^4.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import nodeResolve from '@rollup/plugin-node-resolve'
import path from 'path'

const plugins = [
nodeResolve({
rootDir: path.join(process.cwd(), '../..'),
moduleDirectories: ['node_modules', 'packages'],
}),
]

export default {
input: 'src/index.js',
external: [
'@babel/plugin-syntax-jsx',
'@babel/helper-module-imports',
'@babel/types',
'html-entities',
'validate-html-nesting',
],
output: {
file: 'dist/index.js',
format: 'cjs',
exports: 'auto',
},
plugins,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default [
'area',
'base',
'br',
'col',
'embed',
'hr',
'img',
'input',
'keygen',
'link',
'menuitem',
'meta',
'param',
'source',
'track',
'wbr'
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default {
moduleName: 'dom',
generate: 'dom',
hydratable: false,
delegateEvents: true,
delegatedEvents: [],
builtIns: [],
requireImportSource: false,
wrapConditionals: true,
omitNestedClosingTags: false,
contextToCustomElements: false,
staticMarker: '@once',
effectWrapper: 'effect',
memoWrapper: 'memo',
validate: true
}