From a3353172cfb624fed1cbee3663aee4de8e446b5b Mon Sep 17 00:00:00 2001 From: zealotchen Date: Wed, 6 Nov 2024 21:37:33 +0800 Subject: [PATCH 1/2] fix(js): add NamedModulesPlugin --- .../hippy-react-demo/scripts/hippy-webpack.android-vendor.js | 1 + .../examples/hippy-react-demo/scripts/hippy-webpack.android.js | 1 + .../hippy-react-demo/scripts/hippy-webpack.ios-vendor.js | 1 + driver/js/examples/hippy-react-demo/scripts/hippy-webpack.ios.js | 1 + .../hippy-react-demo/scripts/hippy-webpack.web-renderer.dev.js | 1 + .../hippy-react-demo/scripts/hippy-webpack.web-renderer.js | 1 + .../examples/hippy-react-demo/scripts/hippy-webpack.web.dev.js | 1 + driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web.js | 1 + .../hippy-vue-demo/scripts/hippy-webpack.android-vendor.js | 1 + .../js/examples/hippy-vue-demo/scripts/hippy-webpack.android.js | 1 + .../examples/hippy-vue-demo/scripts/hippy-webpack.ios-vendor.js | 1 + driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.ios.js | 1 + .../hippy-vue-next-demo/scripts/hippy-webpack.android-vendor.js | 1 + .../hippy-vue-next-demo/scripts/hippy-webpack.android.js | 1 + .../hippy-vue-next-demo/scripts/hippy-webpack.ios-vendor.js | 1 + .../js/examples/hippy-vue-next-demo/scripts/hippy-webpack.ios.js | 1 + 16 files changed, 16 insertions(+) diff --git a/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.android-vendor.js b/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.android-vendor.js index 3352ea03d3d..4dcfe8c83bf 100644 --- a/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.android-vendor.js +++ b/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.android-vendor.js @@ -18,6 +18,7 @@ module.exports = { library: 'hippyReactBase', }, plugins: [ + new webpack.NamedModulesPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production'), __PLATFORM__: JSON.stringify(platform), diff --git a/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.android.js b/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.android.js index 0ec17eea641..20a4e1556a4 100644 --- a/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.android.js +++ b/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.android.js @@ -22,6 +22,7 @@ module.exports = { // publicPath: 'https://xxx/hippy/hippyReactDemo/', }, plugins: [ + new webpack.NamedModulesPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production'), __PLATFORM__: JSON.stringify(platform), diff --git a/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.ios-vendor.js b/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.ios-vendor.js index d452d0bd22b..2d6134ae4d7 100644 --- a/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.ios-vendor.js +++ b/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.ios-vendor.js @@ -18,6 +18,7 @@ module.exports = { library: 'hippyReactBase', }, plugins: [ + new webpack.NamedModulesPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production'), __PLATFORM__: JSON.stringify(platform), diff --git a/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.ios.js b/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.ios.js index 481cbc5ab0a..ec799757cb5 100644 --- a/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.ios.js +++ b/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.ios.js @@ -22,6 +22,7 @@ module.exports = { // publicPath: 'https://xxx/hippy/hippyReactDemo/', }, plugins: [ + new webpack.NamedModulesPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production'), __PLATFORM__: JSON.stringify(platform), diff --git a/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web-renderer.dev.js b/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web-renderer.dev.js index 793d00bb4ba..52f7c6867fa 100644 --- a/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web-renderer.dev.js +++ b/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web-renderer.dev.js @@ -29,6 +29,7 @@ module.exports = { globalObject: '(0, eval)("this")', }, plugins: [ + new webpack.NamedModulesPlugin(), new HtmlWebpackPlugin({ inject: true, scriptLoading: 'blocking', diff --git a/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web-renderer.js b/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web-renderer.js index 376365e717a..d15bec933fd 100644 --- a/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web-renderer.js +++ b/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web-renderer.js @@ -17,6 +17,7 @@ module.exports = { path: path.resolve(`./dist/${platform}/`), }, plugins: [ + new webpack.NamedModulesPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production'), __PLATFORM__: JSON.stringify(platform), diff --git a/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web.dev.js b/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web.dev.js index 29938d273bd..b3a6c539f7c 100644 --- a/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web.dev.js +++ b/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web.dev.js @@ -25,6 +25,7 @@ module.exports = { path: path.resolve(`./dist/${platform}/`), }, plugins: [ + new webpack.NamedModulesPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('development'), __PLATFORM__: JSON.stringify(platform), diff --git a/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web.js b/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web.js index aa661369fc1..8a055cb4401 100644 --- a/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web.js +++ b/driver/js/examples/hippy-react-demo/scripts/hippy-webpack.web.js @@ -18,6 +18,7 @@ module.exports = { path: path.resolve(`./dist/${platform}/`), }, plugins: [ + new webpack.NamedModulesPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production'), __PLATFORM__: JSON.stringify(platform), diff --git a/driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.android-vendor.js b/driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.android-vendor.js index dd0a29d751d..7bd76b3a139 100644 --- a/driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.android-vendor.js +++ b/driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.android-vendor.js @@ -31,6 +31,7 @@ module.exports = { library: 'hippyVueBase', }, plugins: [ + new webpack.NamedModulesPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production'), __PLATFORM__: JSON.stringify(platform), diff --git a/driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.android.js b/driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.android.js index ae08ea81ea0..b7a42a1c073 100644 --- a/driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.android.js +++ b/driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.android.js @@ -43,6 +43,7 @@ module.exports = { // publicPath: 'https://xxx/hippy/hippyVueDemo/', }, plugins: [ + new webpack.NamedModulesPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production'), __PLATFORM__: JSON.stringify(platform), diff --git a/driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.ios-vendor.js b/driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.ios-vendor.js index 78b5ef6d2af..9d04455b698 100644 --- a/driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.ios-vendor.js +++ b/driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.ios-vendor.js @@ -31,6 +31,7 @@ module.exports = { library: 'hippyVueBase', }, plugins: [ + new webpack.NamedModulesPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production'), __PLATFORM__: JSON.stringify(platform), diff --git a/driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.ios.js b/driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.ios.js index 891d9564a66..f16be6650ca 100644 --- a/driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.ios.js +++ b/driver/js/examples/hippy-vue-demo/scripts/hippy-webpack.ios.js @@ -43,6 +43,7 @@ module.exports = { // publicPath: 'https://xxx/hippy/hippyVueDemo/', }, plugins: [ + new webpack.NamedModulesPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production'), __PLATFORM__: JSON.stringify(platform), diff --git a/driver/js/examples/hippy-vue-next-demo/scripts/hippy-webpack.android-vendor.js b/driver/js/examples/hippy-vue-next-demo/scripts/hippy-webpack.android-vendor.js index 9c6a2163ff7..a8689aece99 100644 --- a/driver/js/examples/hippy-vue-next-demo/scripts/hippy-webpack.android-vendor.js +++ b/driver/js/examples/hippy-vue-next-demo/scripts/hippy-webpack.android-vendor.js @@ -19,6 +19,7 @@ module.exports = { library: 'hippyVueBase', }, plugins: [ + new webpack.NamedModulesPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production'), __PLATFORM__: JSON.stringify(platform), diff --git a/driver/js/examples/hippy-vue-next-demo/scripts/hippy-webpack.android.js b/driver/js/examples/hippy-vue-next-demo/scripts/hippy-webpack.android.js index 3fc2de49fc3..c6188b5a3ca 100644 --- a/driver/js/examples/hippy-vue-next-demo/scripts/hippy-webpack.android.js +++ b/driver/js/examples/hippy-vue-next-demo/scripts/hippy-webpack.android.js @@ -31,6 +31,7 @@ module.exports = { // publicPath: 'https://xxx/hippy/hippyVueNextDemo/', }, plugins: [ + new webpack.NamedModulesPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production'), __PLATFORM__: JSON.stringify(platform), diff --git a/driver/js/examples/hippy-vue-next-demo/scripts/hippy-webpack.ios-vendor.js b/driver/js/examples/hippy-vue-next-demo/scripts/hippy-webpack.ios-vendor.js index fdaa19a76ad..a23657ec9fb 100644 --- a/driver/js/examples/hippy-vue-next-demo/scripts/hippy-webpack.ios-vendor.js +++ b/driver/js/examples/hippy-vue-next-demo/scripts/hippy-webpack.ios-vendor.js @@ -19,6 +19,7 @@ module.exports = { library: 'hippyVueBase', }, plugins: [ + new webpack.NamedModulesPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production'), __PLATFORM__: JSON.stringify(platform), diff --git a/driver/js/examples/hippy-vue-next-demo/scripts/hippy-webpack.ios.js b/driver/js/examples/hippy-vue-next-demo/scripts/hippy-webpack.ios.js index c8fed863d6c..a8154d41539 100644 --- a/driver/js/examples/hippy-vue-next-demo/scripts/hippy-webpack.ios.js +++ b/driver/js/examples/hippy-vue-next-demo/scripts/hippy-webpack.ios.js @@ -31,6 +31,7 @@ module.exports = { // publicPath: 'https://xxx/hippy/hippyVueNextDemo/', }, plugins: [ + new webpack.NamedModulesPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production'), __PLATFORM__: JSON.stringify(platform), From f6c797f4040d81738ec8adc60c1b52508dc5d3d1 Mon Sep 17 00:00:00 2001 From: zealotchen Date: Wed, 6 Nov 2024 21:40:15 +0800 Subject: [PATCH 2/2] feat(vue-next): fix websocket event not bind --- .../hippy-vue-next/src/runtime/websocket/websocket.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/driver/js/packages/hippy-vue-next/src/runtime/websocket/websocket.ts b/driver/js/packages/hippy-vue-next/src/runtime/websocket/websocket.ts index 56291434bf5..77eb576a5e9 100644 --- a/driver/js/packages/hippy-vue-next/src/runtime/websocket/websocket.ts +++ b/driver/js/packages/hippy-vue-next/src/runtime/websocket/websocket.ts @@ -52,9 +52,6 @@ const WEB_SOCKET_MODULE_NAME = 'websocket'; // native event name for websocket const WEB_SOCKET_NATIVE_EVENT = 'hippyWebsocketEvents'; -// whether the websocket event listener has been bound -let isBindWebsocketEvent = false; - /** * determine whether it is a legitimate websocket event * @@ -116,11 +113,7 @@ class WebSocket { ...extrasHeaders, }; - if (!isBindWebsocketEvent) { - // The bus is global, if it is multi-instance, there may be problems, to be verified fixme - isBindWebsocketEvent = true; - EventBus.$on(WEB_SOCKET_NATIVE_EVENT, this.onWebSocketEvent); - } + EventBus.$on(WEB_SOCKET_NATIVE_EVENT, this.onWebSocketEvent); if (!url) { throw new TypeError('Invalid WebSocket url');