Vue3安装pixi.js 项目无法识别 ?. 语法,导致报错Module parse failed: Unexpected token

error in ./node_modules/@pixi/assets/lib/resolver/parsers/resolveTextureUrl.mjs

Module parse failed: Unexpected token (9:62)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| test: loadTextures.test,
| parse: (value) => ({

> resolution: parseFloat(settings.RETINA_PREFIX.exec(value)?.[1] ?? "1"),
| format: value.split(".").pop(),
| src: value

**@ ./node_modules/****@pixi/**assets/lib/index.mjs 20:0-77 20:0-77

pixi.js 是最新版本,7.2.4

低版本没发现有问题

问题原因:

因为导入的组件库是直接上源码的,必须告知webpack,需要编译一下这个库,让源码中的es6、es7的特性转换为es5

解决方案:

1.在vue.config.js 里面加上 transpileDependencies: ['/@pixi/']

module.exports = {

transpileDependencies: ['/@name/']

}

name 找报错的node_modules 里依赖的路径 **@ ./node_modules/****@pixi/**assets/lib/index.mjs 20:0-77 20:0-77

参考:项目无法识别 ?. 语法,导致报错Module parse failed: Unexpected token

相关推荐
SoaringHeart19 小时前
Flutter调试组件:打印任意组件尺寸位置信息 NRenderBox
前端·flutter
晚风予星20 小时前
Ant Design Token Lens 迎来了全面升级!支持在 .tsx 或 .ts 文件中直接使用 Design Token
前端·react.js·visual studio code
sunny_20 小时前
⚡️ vite-plugin-oxc:从 Babel 到 Oxc,我为 Vite 写了一个高性能编译插件
前端·webpack·架构
GIS之路20 小时前
ArcPy 开发环境搭建
前端
林小帅1 天前
【笔记】OpenClaw 架构浅析
前端·agent
林小帅1 天前
【笔记】OpenClaw 生态系统的多语言实现对比分析
前端·agent
程序猿的程1 天前
开源一个 React 股票 K 线图组件,传个股票代码就能画图
前端·javascript
不爱说话郭德纲1 天前
告别漫长的HbuilderX云打包排队!uni-app x 安卓本地打包保姆级教程(附白屏、包体积过大排坑指南)
android·前端·uni-app
大雨还洅下1 天前
前端JS: 虚拟dom是什么? 原理? 优缺点?
javascript
唐叔在学习1 天前
[前端特效] 左滑显示按钮的实现介绍
前端·javascript