-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
ConfirmationService: require is not defined #1897
Comments
This issue still occurs in 3.11.0. Tried both in a local project and by forking the linked codesandbox and bumping primevue to 3.11.0. Same exact error. However if you simply refer to this function by another name, the error disappears: // If this code is present, Nuxt 3 fails to even compile:
confirm.require({message: 'U sure?'})
// However, this works flawlessly:
const doTheDialog = confirm.require
doTheDialog({message: 'U sure?'}) Looks like it is some obscure issue with the Hope this helps. |
Haha it works ! I would never have guessed. Thanks a lot ! |
Thanks @adlpz took me all the morning. Shouldn't be this issue reopened? |
@adlpz Thanks, that did the job :) I used the following in my code: const { require: confirmRequire } = useConfirm() |
vie console.log i can see the function require is defined, but calling it results in nothing. no error or warning. i can just guess this is still somehow related with the reserved require keyword. update
update 2 okay found the reason, i simply was not aware that the confirm.require method relays on the ConfirmDialog component. at least 2 hours wasted. thanks anyways. |
I'm submitting a ... (check one with "x")
Current behavior
Whenever my code contains
confirm.require()
the app breaks withReferenceError: require is not defined
. When I inspect this error in browser I can indeed seeconst { defineComponent } = require('vue');
added in the component where I includedconfirm.require()
. This defineComponent seems to not be used and if I commentconfirm.require()
, the error and the require goes away.Expected behavior
It should not add
const { defineComponent } = require('vue');
when usingconfirm.require()
Minimal reproduction of the problem with instructions
https://codesandbox.io/s/bug-primevue-nuxt-3-bnq9d?file=/pages/test.vue
The page index.vue is there to illustrate that the app works fine. Note that the codesandbox repro is not ideal and has sometimes bugs not related to this one. If you want to reproduce locally please follow this link and copy/paste plugins/primevue.ts & test.vue from codesandbox.
What is the motivation / use case for changing the behavior?
The use case is displaying a confirm dialog when clicking a button. The behavior that should be change is adding
const { defineComponent } = require('vue');
when callingconfirm.require()
. I looked in the source code and could not find where it would happenPlease tell us about your environment:
Linux version: 20.04
Vue version: 3.2.22
Nuxt version: 3.0.0-27296172.f5307f9
Vite version: 2.6.14
PrimeVue version: 3.10.0
Browser: all
The text was updated successfully, but these errors were encountered: