GreatAuk / plugin-web-update-notification

Detect webpage updates and notify user to reload. support Vite, Umijs, and Webpack.
MIT License
490 stars 42 forks source link

Vite build: error during build #53

Closed huihui14569 closed 9 months ago

huihui14569 commented 10 months ago
TypeError: hook is not a function
    at applyHtmlTransforms (file:///Users/xxx/projects/node_modules/vite/dist/node/chunks/dep-2faf2534.js:43464:27)
    at Object.generateBundle (file:///Users/xxx/projects/node_modules/vite/dist/node/chunks/dep-2faf2534.js:43384:32)
    at file:///Users/xxx/projects/node_modules/rollup/dist/es/shared/node-entry.js:25544:40

node version: v16.20.2

vite/dist/node/chunks/dep-2faf2534.js:43464:27 part code ↓

    for (const hook of hooks) {
        const res = await hook(html, ctx);
        if (!res) {
            continue;
        }
        if (typeof res === 'string') {
            html = res;
        }
        else {
            let tags;
            if (Array.isArray(res)) {
                tags = res;
            }
            else {
                html = res.html || html;
                tags = res.tags;
            }
            const headTags = [];
            const headPrependTags = [];
            const bodyTags = [];
            const bodyPrependTags = [];
            for (const tag of tags) {
                if (tag.injectTo === 'body') {
                    bodyTags.push(tag);
                }
                else if (tag.injectTo === 'body-prepend') {
                    bodyPrependTags.push(tag);
                }
                else if (tag.injectTo === 'head') {
                    headTags.push(tag);
                }
                else {
                    headPrependTags.push(tag);
                }
            }
            html = injectToHead(html, headPrependTags, true);
            html = injectToHead(html, headTags);
            html = injectToBody(html, bodyPrependTags, true);
            html = injectToBody(html, bodyTags);
        }
    }
    return html;
}

package.json:

  "name": "arco-design-pro-vue",
  "description": "Arco Design Pro for Vue",
  "version": "1.0.0",
  "private": true,
  "author": "ArcoDesign Team",
  "license": "MIT",
  "scripts": {
    "dev": "vite --config ./config/vite.config.dev.ts",
    "build": "vue-tsc --noEmit && vite build --config ./config/vite.config.prod.ts",
    "preview": "npm run build && vite preview --host",
    "type:check": "vue-tsc --noEmit --skipLibCheck"
  },
  "dependencies": {
    "@amap/amap-jsapi-loader": "^1.0.1",
    "@arco-design/web-vue": "^2.53.3",
    "@tinymce/tinymce-vue": "^5.1.1",
    "@vueuse/components": "^10.1.0",
    "@vueuse/core": "^10.1.0",
    "arco-design-pro-vue": "^2.7.2",
    "axios": "^0.24.0",
    "clipboard": "^2.0.11",
    "dayjs": "^1.11.10",
    "echarts": "^5.4.3",
    "html2canvas": "^1.4.1",
    "js-file-download": "^0.4.12",
    "lodash": "^4.17.21",
    "mathjs": "^11.11.1",
    "mitt": "^3.0.1",
    "nprogress": "^0.2.0",
    "pinia": "^2.0.23",
    "qrcode.vue": "^3.4.1",
    "query-string": "^8.0.3",
    "sortablejs": "^1.15.0",
    "spark-md5": "^3.0.2",
    "stylelint-config-prettier": "9.0.5",
    "uuid": "^9.0.1",
    "vue": "^3.2.40",
    "vue-echarts": "^6.2.3",
    "vue-router": "^4.0.14",
    "vue3-draggable-resizable": "^1.6.5",
    "vuedraggable": "^4.1.0"
  },
  "devDependencies": {
    "@arco-plugins/vite-vue": "^1.4.5",
    "@plugin-web-update-notification/vite": "^1.7.0",
    "@types/lodash": "^4.14.200",
    "@types/mockjs": "^1.0.9",
    "@types/nprogress": "^0.2.0",
    "@types/sortablejs": "^1.15.4",
    "@types/spark-md5": "^3.0.3",
    "@types/uuid": "^9.0.6",
    "@typescript-eslint/eslint-plugin": "^5.40.0",
    "@typescript-eslint/parser": "^5.40.0",
    "@vitejs/plugin-vue": "^3.1.2",
    "@vitejs/plugin-vue-jsx": "^2.0.1",
    "@vue/babel-plugin-jsx": "^1.1.5",
    "consola": "^2.15.3",
    "cross-env": "^7.0.3",
    "less": "^4.1.3",
    "mockjs": "^1.1.0",
    "rollup": "^3.29.4",
    "rollup-plugin-visualizer": "^5.11.0",
    "typescript": "^4.8.4",
    "unplugin-vue-components": "^0.24.1",
    "vite": "^3.2.5",
    "vite-plugin-compression": "^0.5.1",
    "vite-plugin-eslint": "^1.8.1",
    "vite-plugin-imagemin": "^0.5.3",
    "vite-svg-loader": "^3.6.0",
    "vue-tsc": "^1.6.5"
  },
  "engines": {
    "node": ">=14.0.0"
  },
  "resolutions": {
    "bin-wrapper": "npm:bin-wrapper-china",
    "rollup": "^3.29.4",
    "gifsicle": "5.2.0"
  }
}
GreatAuk commented 10 months ago

可以暂时用下 v1.66v1.54 的版本。周末修下兼容问题