antfu / vite-ssg

Static site generation for Vue 3 on Vite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

After updating to 0.17.5 throws SyntaxError: The requested module 'vue' does not provide an export named 'ref'

daief opened this issue · comments

commented

When I use vite-ssg@0.15.1 with vue@3.2.19 on Node v12, everything works fine.

Toady I update to vite-ssg@0.17.5, vue@3.2.26 and Node v14.3.0, there is a error when exec vite-ssg build.

> vite-ssg build

[vite-ssg] Build for client...
vite v2.6.13 building for production...
✓ 75 modules transformed.
dist/index.html                      0.82 KiB
dist/ssr-manifest.json               7.68 KiB
dist/assets/tooltip.35c50bc5.js      11.73 KiB / gzip: 1.08 KiB
dist/assets/tab.258aa7fa.js          17.60 KiB / gzip: 1.22 KiB
dist/assets/mask.87f7a525.js         4.11 KiB / gzip: 1.08 KiB
dist/assets/table.bbc295d3.js        15.67 KiB / gzip: 2.05 KiB
dist/assets/icons.2d46efcd.js        1.18 KiB / gzip: 0.67 KiB
dist/assets/menu.637feb5c.js         16.32 KiB / gzip: 1.71 KiB
dist/assets/breadcrumb.4095e6cc.js   4.81 KiB / gzip: 0.78 KiB
dist/assets/drawer.5a75b21b.js       21.44 KiB / gzip: 2.56 KiB
dist/assets/button.f540d487.js       39.56 KiB / gzip: 3.48 KiB
dist/assets/badge.ce7e4a9d.js        18.38 KiB / gzip: 1.89 KiB
dist/assets/artboard.b9a756be.js     6.17 KiB / gzip: 0.97 KiB
dist/assets/avatar.71c76a31.js       24.84 KiB / gzip: 1.56 KiB
dist/assets/alert.87b02d6d.js        7.85 KiB / gzip: 1.15 KiB
dist/assets/app.7f392c0f.css         22.83 KiB / gzip: 5.55 KiB
dist/assets/app.88bb4a0d.js          102.51 KiB / gzip: 24.08 KiB
dist/assets/vendor.88a64974.js       85.99 KiB / gzip: 33.98 KiB

[vite-ssg] Build for server...
vite v2.6.13 building SSR bundle for production...
✓ 51 modules transformed.
.vite-ssg-temp/assets/style.481053b2.css   35.89 KiB
.vite-ssg-temp/main.mjs                    631.01 KiB

[vite-ssg] An internal error occurred.
[vite-ssg] Please report an issue, if none already exists: https://github.com/antfu/vite-ssg/issues
(node:22583) UnhandledPromiseRejectionWarning: file:///Users/daief/Documents/fe/mime/daisyui-vue/node_modules/.pnpm/registry.npmmirror.com+vite-ssg@0.17.5_cce7363ba702032af45a4a4ed29675e6/node_modules/vite-ssg/dist/chunks/ClientOnly.mjs:1
import { defineComponent, ref, onMounted } from 'vue';
                          ^^^
SyntaxError: The requested module 'vue' does not provide an export named 'ref'
    at ModuleJob._instantiate (internal/modules/esm/module_job.js:97:21)
    at async ModuleJob.run (internal/modules/esm/module_job.js:135:5)
    at async Loader.import (internal/modules/esm/loader.js:178:24)
    at async build (/Users/daief/Documents/fe/mime/daisyui-vue/node_modules/.pnpm/registry.npmmirror.com+vite-ssg@0.17.5_cce7363ba702032af45a4a4ed29675e6/node_modules/vite-ssg/dist/node/cli.cjs:180:44)
    at async Object.handler (/Users/daief/Documents/fe/mime/daisyui-vue/node_modules/.pnpm/registry.npmmirror.com+vite-ssg@0.17.5_cce7363ba702032af45a4a4ed29675e6/node_modules/vite-ssg/dist/node/cli.cjs:294:3)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:22583) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:22583) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This is the file: node_modules/vite-ssg/dist/chunks/ClientOnly.mjs.

import { defineComponent, ref, onMounted } from 'vue';

function documentReady(_passThrough) {
  if (document.readyState === "loading") {
    return new Promise((resolve) => {
      document.addEventListener("DOMContentLoaded", () => resolve(_passThrough));
    });
  }
  return Promise.resolve(_passThrough);
}

const ClientOnly = defineComponent({
  setup(props, { slots }) {
    const mounted = ref(false);
    onMounted(() => mounted.value = true);
    return () => {
      return mounted.value && slots.default && slots.default({});
    };
  }
});

export { ClientOnly as C, documentReady as d };

ClientOnly.js looks good. I can't find the cause of the problem and need your help. Thank you !

commented

Finally I update Node to v14.18.2, it works fine again.