unplugin-vue2-script-setup: Cannot set properties of undefined (setting'render').

Hello, I encountered a problem when using Vue-cli to package into the production environment: Cannot set properties of undefined (setting’render’).

The following are my few file configurations:

package.json

{
  "name": "vue-cli",
  "private": true,
  "scripts": {
    "dev": "vue-cli-service serve",
    "build": "vue-tsc --noEmit && vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "@vue/composition-api": "^1.2.4",
    "core-js": "^3.16.4",
    "vue": "^2.6.11"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^4.5.13",
    "@vue/cli-plugin-typescript": "^4.5.13",
    "@vue/cli-service": "^4.5.13",
    "typescript": "^4.4.2",
    "unplugin-vue2-script-setup": "workspace:*",
    "vue-template-compiler": "^2.6.14",
    "vue-tsc": "^0.3.0"
  }
}

vue.config.js

/* eslint-disable @typescript-eslint/no-var-requires */

const ScriptSetup = require('unplugin-vue2-script-setup/webpack')

/**
 * @type {import('@vue/cli-service').ProjectOptions}
 */
module.exports = {
  configureWebpack: {
    plugins: [
      ScriptSetup({
        refTransform: true,
      }),
    ],
  },
  chainWebpack(config) {
    // disable type check and let `vue-tsc` handles it
    config.plugins.delete('fork-ts-checker')

    // disable cache for testing, you should remove this in production
    config.module.rule('vue').uses.delete('cache-loader')
    config.module.rule('js').uses.delete('cache-loader')
    config.module.rule('ts').uses.delete('cache-loader')
    config.module.rule('tsx').uses.delete('cache-loader')
  },
}

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

This plugin is conflicting with thread-loader for some reason, the current workaround is passing parallel: false in your vue.config.js

@antfu First of all, I am really sorry for not providing a detailed example.

The following is my system information:

  • System: OS: Windows 10 10.0.19041 CPU: (8) x64 Intel® Core™ i7-10510U CPU @ 1.80GHz Memory: 6.84 GB / 15.84 GB
  • Binaries: Node: 14.15.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD
  • Browsers: Edge: Spartan (44.19041.1266.0), Chromium (95.0.1020.40) Internet Explorer: 11.0.19041.1202

I have provided a link to the project, hoping to find the problem.

https://github.com/maomincoding/vue2-cli-script-setup


I found the problem like this:

1. First I run the command

yarn

2. Startup project

yarn dev

There is no problem in the development environment.

微信截图_20211102103510

3. Deploy to production environment

yarn build

At this time, I found this error in the production environment.

微信截图_20211102103202


The above is the problem I encountered, thanks.

We temporarily close this due to the lack of enough information. Please provide a minimal reproduction to reopen the issue. Thanks.