Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builderror #6

Closed
delisteam opened this issue May 5, 2022 · 6 comments
Closed

builderror #6

delisteam opened this issue May 5, 2022 · 6 comments

Comments

@delisteam
Copy link

delisteam commented May 5, 2022

开发环境的时候正常,打包构建的时候如果fileRegex写了/.js$|.jsx$|.vue$/就报错
vite.config.js:
defineConfig({
plugins: [
requireTransform({
fileRegex: /.js$|.jsx$|.vue$/,
})
],
})
只写.vue正常打包
requireTransform({
fileRegex: /.vue$/,
}),

错误日志
✓ 516 modules transformed.
[vite_plugin_require_transform] Unexpected token (1:33) - make sure this is an expression.

1 | (vite_plugin_require_transform./)
| ^
file: C:/Users/Administrator/Desktop/xx/node_modules/_call-bind@1.0.2@call-bind/callBound.js:1:33
error during build:
SyntaxError: Unexpected token (1:33) - make sure this is an expression.
1 | (vite_plugin_require_transform./)
| ^
at instantiate (...\node_modules_@babel_parser@7.17.10@@babel\parser\lib\index.js:72:32)
at constructor (..._@babel_parser@7.17.10@@babel\parser\lib\index.js:358:12)
at Parser.raise (...\node_modules_@babel_parser@7.17.10@@babel\parser\lib\index.js:3335:19)

@WarrenJones
Copy link
Owner

can you provide a minimal repo link that can reproduce the problem you ran into?or just list the source code that cause the error

@yuguaa
Copy link

yuguaa commented Jul 6, 2022

#6 (comment)
请问怎么解决的啊

@WarrenJones
Copy link
Owner

#6 (comment) 请问怎么解决的啊

可以提供下报错的文件或者截图么

@yuguaa
Copy link

yuguaa commented Jul 8, 2022

#6 (comment) 请问怎么解决的啊

可以提供下报错的文件或者截图么

antd引入的一个插件报错了,配了external不打包他了

@baoweijun
Copy link

开发环境的时候正常,打包构建的时候如果fileRegex写了/.js$|.jsx$|.vue$/就报错 vite.config.js: defineConfig({ plugins: [ requireTransform({ fileRegex: /.js$|.jsx$|.vue$/, }) ], }) 只写.vue正常打包 requireTransform({ fileRegex: /.vue$/, }),

错误日志 ✓ 516 modules transformed. [vite_plugin_require_transform] Unexpected token (1:33) - make sure this is an expression.

1 | (vite_plugin_require_transform./)
| ^
file: C:/Users/Administrator/Desktop/xx/node_modules/call-bind@1.0.2@call-bind/callBound.js:1:33
error during build:
SyntaxError: Unexpected token (1:33) - make sure this is an expression.
1 | (vite_plugin_require_transform./)
| ^
at instantiate (...\node_modules
@babel_parser@7.17.10@@babel\parser\lib\index.js:72:32)
at constructor (...@babel_parser@7.17.10@@babel\parser\lib\index.js:358:12)
at Parser.raise (...\node_modules
@babel_parser@7.17.10@@babel\parser\lib\index.js:3335:19)

你解决了吗

@zkk2019
Copy link

zkk2019 commented May 10, 2024

需要下载一个包 @rollup/plugin-commonjs
然后在 plugins 第一项使用

import commonjs from '@rollup/plugin-commonjs'

plugins: [
commonjs(),
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants