Named export 'createAuth0' not found when building using vite-ssg
lukaspoloki opened this issue · comments
Describe the bug
So I am trying to use auth0-vue and there is this error showing up when I try to build with vite-ssg (for now I worked this around by using normal vite build)
here is the error message:
`import { createAuth0, useAuth0 } from "@auth0/auth0-vue";
^^^^^^^^^^^
SyntaxError: Named export 'createAuth0' not found. The requested module '@auth0/auth0-vue' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@auth0/auth0-vue';
const { createAuth0, useAuth0 } = pkg;`
in my vite config I have this imported in autoimports:
`AutoImport({
imports: [
{
'@auth0/auth0-vue': [
'createAuth0',
'useAuth0',
],
'axios': [
// default imports
['default', 'axios'], // import { default as axios } from 'axios',
],
'vue3-cookies': [
['globalCookiesConfig', 'useCookies'],
],
},
],
vueTemplate: true,
}),`
and I am using createAuth0 in my module called auth0.ts like so
`import config from '/config.json'/types'
import { type UserModule } from '
export const install: UserModule = ({ app }) => {
if (config.auth0) {
app.use(
createAuth0({
domain: config.auth0.domain,
client_id: config.auth0.client_id,
redirect_uri: window.location.origin,
cacheLocation: 'localstorage',
audience: config.auth0.audience,
useRefreshTokens: true,
scope: 'church',
}),
)
}
}`
Reproduction
add package auth0 and use it in your project, then build app using vite-ssg
System Info
using visual studio, but it fails on github pipeline as well
Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
- The provided reproduction is a minimal reproducible of the bug.
Have you try this?
// vite.config.ts
export default defineConfig({
// ...,
ssr: {
noExternal: [‘@auth0/auth0-vue’],
},
})