vitejs / vite-plugin-vue

Vite Vue Plugins
MIT License
490 stars 154 forks source link

ReferenceError: __name is not defined #191

Closed 52javascript closed 1 year ago

52javascript commented 1 year ago

Related plugins

Describe the bug

When I use rollup to build vue3 , the error append

Reproduction

11

Steps to reproduce

gulp --require @esbuild-kit/cjs-loader -f gulpfile.ts


import { rollup } from 'rollup'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import esbuild, { minify as minifyPlugin } from 'rollup-plugin-esbuild'
import scss from 'rollup-plugin-scss'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import VueMacros from 'unplugin-vue-macros/rollup'

const buildModules = async () => {
  const bundle = await rollup({
    input: app,
    plugins: [
      VueMacros({
        setupComponent: false,
        setupSFC: false,
        plugins: {
          vue: vue(),
          vueJsx: vueJsx()
        }
      }),
      nodeResolve({
        extensions: ['.mjs', '.js', '.json', '.ts'],
        browser: true
      }),
      commonjs(),
      json(),
      scss(),
      esbuild({
        sourceMap: false,
        target,
        legalComments: 'eof',
        loaders: {
          '.vue': 'ts'
        }
      }),
      minifyPlugin({
        target,
        sourceMap: false
      })
    ],
    treeshake: true
  })
}

export default buildModules
{
  "name": "@wangtiansoft/build",
  "version": "1.0.0",
  "main": "index.js",
  "private": true,
  "scripts": {
    "start": "gulp --require @esbuild-kit/cjs-loader -f gulpfile.ts"
  },
  "devDependencies": {
    "@esbuild-kit/cjs-loader": "^2.2.1",
    "@rollup/plugin-commonjs": "^24.0.1",
    "@rollup/plugin-json": "^6.0.0",
    "@rollup/plugin-node-resolve": "^15.0.1",
    "@rollup/plugin-terser": "^0.4.0",
    "@types/gulp": "^4.0.12",
    "@types/yargs": "^17.0.24",
    "@vitejs/plugin-vue": "^4.2.3",
    "@vitejs/plugin-vue-jsx": "^3.0.1",
    "esbuild": "^0.15.8",
    "fast-glob": "^3.2.12",
    "fs-extra": "^11.1.0",
    "gulp": "^4.0.2",
    "lodash": "^4.17.21",
    "postcss": "^8.4.21",
    "rimraf": "^4.1.2",
    "rollup": "^3.15.0",
    "rollup-plugin-esbuild": "^5.0.0",
    "rollup-plugin-scss": "^4.0.0",
    "rollup-plugin-vue": "6",
    "unplugin-vue-macros": "^1.8.2",
    "yargs": "^17.7.1"
  }
}

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (16) x64 AMD Ryzen 7 6800H with Radeon Graphics         
    Memory: 11.80 GB / 27.69 GB
  Binaries:
    Node: 16.20.0 - E:\env\nodejs\node.EXE
    Yarn: 1.22.19 - E:\env\nodejs\yarn.CMD
    npm: 8.19.4 - E:\env\nodejs\npm.CMD
    pnpm: 8.6.1 - E:\env\nodejs\pnpm.CMD
  Browsers:
    Edge: Spartan (44.22621.1848.0), Chromium (114.0.1823.58)
    Internet Explorer: 11.0.22621.1

Used Package Manager

pnpm

Logs

@wangtiansoft/build@1.0.0 start E:\WebstormProjects\wt-crud-v2\build gulp --require @esbuild-kit/cjs-loader -f gulpfile.ts

[14:17:45] Requiring external module @esbuild-kit/cjs-loader [14:17:47] Using gulpfile E:\WebstormProjects\wt-crud-v2\build\gulpfile.ts [14:17:47] Starting 'default'... [14:17:47] Starting 'clean'...

wt-crud-v2@1.0.0 clean E:\WebstormProjects\wt-crud-v2 rimraf dist

[14:17:47] Finished 'clean' after 617 ms [14:17:47] Starting 'build'... [14:17:49] 'build' errored after 1.43 s [14:17:49] ReferenceError: __name is not defined at SortTemplate (eval at cloneSort (E:\WebstormProjects\wt-crud-v2\node_modules.pnpm\registry.npmmirror.com+source-map-js@1.0.2\node_modules\source-map-js\lib\quick-sort.js:1:848), :3:107) at cloneSort (e:\WebstormProjects\wt-crud-v2\node_modules.pnpm\registry.npmmirror.com+source-map-js@1.0.2\node_modules\source-map-js\lib\quick-sort.js:112:10) at exports.quickSort (e:\WebstormProjects\wt-crud-v2\node_modules.pnpm\registry.npmmirror.com+source-map-js@1.0.2\node_modules\source-map-js\lib\quick-sort.js:128:19)
at BasicSourceMapConsumer.SourceMapConsumer_parseMappings (e:\WebstormProjects\wt-crud-v2\node_modules.pnpm\registry.npmmirror.com+source-map-js@1.0.2\node_modules\source-map-js\lib\source-map-consumer.js:604:9) at BasicSourceMapConsumer.get (e:\WebstormProjects\wt-crud-v2\node_modules.pnpm\registry.npmmirror.com+source-map-js@1.0.2\node_modules\source-map-js\lib\source-map-consumer.js:70:12) at BasicSourceMapConsumer.SourceMapConsumer_eachMapping (e:\WebstormProjects\wt-crud-v2\node_modules.pnpm\registry.npmmirror.com+source-map-js@1.0.2\node_modules\source-map-js\lib\source-map-consumer.js:136:23) at mapLines (e:\WebstormProjects\wt-crud-v2\node_modules.pnpm\registry.npmmirror.com+@vue+compiler-sfc@3.3.4\node_modules\@vue\compiler-sfc\dist\compiler-sfc.cjs.js:3672:18) at doCompileTemplate (e:\WebstormProjects\wt-crud-v2\node_modules.pnpm\registry.npmmirror.com+@vue+compiler-sfc@3.3.4\node_modules\@vue\compiler-sfc\dist\compiler-sfc.cjs.js:3644:13) at Object.compileTemplate (e:\WebstormProjects\wt-crud-v2\node_modules.pnpm\registry.npmmirror.com+@vue+compiler-sfc@3.3.4\node_modules\@vue\compiler-sfc\dist\compiler-sfc.cjs.js:3587:12) at compile (E:\WebstormProjects\wt-crud-v2\node_modules.pnpm\registry.npmmirror.com+@vitejs+plugin-vue@4.2.3_vite@4.3.9_vue@3.3.4\node_modules\@vitejs\plugin-vue\dist\index.cjs:167:35) [14:17:49] 'default' errored after 2.08 s  ELIFECYCLE  Command failed with exit code 1.

Process finished with exit code 1

Validations

github-actions[bot] commented 1 year ago

Hello @52javascript. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

dremtri commented 1 year ago

link to reproduction: https://stackblitz.com/edit/typescript-budg4p?file=start.yml

hanrea commented 1 year ago

I encountered the same problem, It is related to vue@3.3.x , Attempt to lower version like 3.2.45.