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
Compatibility with Nuxt 3 #93
Comments
Same for me. To reproduce: https://github.com/fabiofcs/SandBoxErrorNuxtDecorator/tree/mainEnvironment: Versions: The erro LOG: ERROR Unexpected character '@' (Note that you need plugins to import files that are not JavaScript)
file: C:/Users/User/GitHubFette/SandBoxErrorNuxtDecorator/components/Test.vue?vue&type=script&lang.ts:4:0
2: import { Vue, Component } from "vue-facing-decorator";
3:
4: @Component
^
5: export default class Test extends Vue {
6: helloWorld = "hello world";
ERROR Nuxt Build Error: Unexpected character '@' (Note that you need plugins to import files that are not JavaScript)
at error (/C:/Users/User/GitHubFette/SandBoxErrorNuxtDecorator/node_modules/rollup/dist/es/shared/node-entry.js:2287:30)
at Module.error (/C:/Users/User/GitHubFette/SandBoxErrorNuxtDecorator/node_modules/rollup/dist/es/shared/node-entry.js:13745:16)
at Module.tryParse (/C:/Users/User/GitHubFette/SandBoxErrorNuxtDecorator/node_modules/rollup/dist/es/shared/node-entry.js:14476:25)
at Module.setSource (/C:/Users/User/GitHubFette/SandBoxErrorNuxtDecorator/node_modules/rollup/dist/es/shared/node-entry.js:14077:39)
at ModuleLoader.addModuleSource (/C:/Users/User/GitHubFette/SandBoxErrorNuxtDecorator/node_modules/rollup/dist/es/shared/node-entry.js:24649:20)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
error Command failed with exit code 1. |
Try this in
|
I already have this conf and it fails with it |
@ruojianll config was added to "sandbox code" but is getting the same error: |
I found solution for this. I replaced setting for nuxt.config.ts like this.
It works fine. |
@skht777 The package in the sandbox was upgraded to the latest:
|
@stembrino
|
I've managed to run The setting you need to add to your
You can check it here by running |
It is also worked fine in my project. |
Thanks @flosca it fixes the build issue. However now the dev command doesn't work, the page is loading endlessly without displaying anything. The only difference in my config is that i'm trying to use Vuetify alongside
|
@laurentfirdion I've tuned Vuetify using this module: https://github.com/userquin/vuetify-nuxt-module/, it works easily with minimal description from their docs |
I tried all night, if you want to use Change your nuxt.config.ts// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
vite: {
vue: {
script: {
babelParserPlugins: ["decorators"],
},
},
vueJsx: {
babelPlugins: [["@babel/plugin-proposal-decorators", { version: "2023-05" }]],
},
},
}); Check your package.json's dependencies"dependencies": {
"nuxt": "^3.10.0",
"vue": "^3.4.15",
"vue-router": "^4.2.5",
"vue-facing-decorator": "^3.0.4",
"@babel/core": "^7.23.9",
"@babel/runtime": "^7.23.9",
"@babel/preset-env": "^7.23.9",
"@babel/plugin-proposal-decorators": "^7.23.9",
"@babel/plugin-transform-class-properties": "^7.23.3",
"@babel/plugin-transform-runtime": "^7.23.9"
} No need to write any Babel plugins, it done! import { Component, Vue, toNative } from "vue-facing-decorator";
@Component({
render(this: IndexView) {
return <button>Hello world</button>;
},
})
class IndexView extends Vue {}
export default toNative(IndexView); |
@laurentfirdion Did these suggestions end up resolving the issue for you, or would you still say there are issues on the vue-facing-decorator side here that need to be addressed? |
@rdhelms bumped the dependency of the Nuxt project and the dev mode is working without any additional configuration. However, it's not possible to generate the static files with "@nuxt/devtools": "latest",
"nuxt": "^3.10.2",
"vue": "^3.4.19",
"vue-facing-decorator": "^3.0.4",
"vue-router": "^4.2.5" As far as I searched, I didn't find anything in official docs to solve this problem. |
@rdhelms if I downgrade the Nuxt to version 3.5.2, the
"@nuxt/devtools": "latest",
"nuxt": "3.5.2",
"vue": "^3.4.19",
"vue-facing-decorator": "^3.0.4",
"vue-router": "^4.2.5" Demo: https://github.com/stembrino/poc-sandbox-rrror-nuxt-decorator/blob/nuxt-3-5-2/package.json |
@rdhelms I'm facing the same issue raised by @stembrino : the generate and build mode are broken with Nuxt version 3.10.X. I know it has worked with older versions of Nuxt but downgrading cannot be a long terme solution. I will say that this nice package is too fragile to be included in a production project. I will personally migrate to Nuxt3/Vue3 without the class component style. Thanks for the effort though |
sorry @laurentfirdion I've mentioned the wrong name 😊. I totally agree with you. |
@laurentfirdion @stembrino Here's a tiny Nuxt demo app using Nuxt 3.10.2 and vue-facing-decorator 3.0.4, which seems to be working as far as I can tell for both the Here it is on GitHub: |
@rdhelms & @laurentfirdion vite: {
esbuild: {
tsconfigRaw: {},
},
}, Without it, it's not possible, @rdhelms I've tested this in your repo |
@rdhelms is this could be considered a solution? I don't know, it seems a little confusing, it seems more like a "workaround". Maybe this could be more consistent: vite: {
esbuild: {
tsconfigRaw: {compilerOptions: {experimentalDecorators: true}},
},
}, Also, in the previous version, it's not required to use this... |
@stembrino My understanding is that the core issue here lies with esbuild's support for decorators (evanw/esbuild#104) which in turn impacts nuxt's support for decorators (nuxt/nuxt#14126). Until those are fully resolved, I believe we're left in the meantime (based on some of the comments in those issues) with needing to use workarounds like the one above. In terms of "why" this workaround works, I think it's because we need to ensure that the I would agree that your last suggestion seems more clear than the empty object. Even though the empty object is technically enough to allow the tsconfig's I just double checked, and your suggestion does definitely also work, so I think that seems like the solution for now until the upstream projects finalize their decorator support. Would be interested to hear if others still have issues even with this config, though. In export default defineNuxtConfig({
devtools: { enabled: false },
vite: {
esbuild: {
tsconfigRaw: {
compilerOptions: {
experimentalDecorators: true,
},
},
},
},
}); And in {
"extends": "./.nuxt/tsconfig.json",
"compilerOptions": {
"experimentalDecorators": true
}
}
|
@rdhelms thanks for the support. It's clear and closed for me, at least at this moment. |
@rdhelms thanks it solved all the issue. We can consider the issue closed at this point |
The package seems not compatible with a Nuxt 3 project
It is working with the "dev" script but the build script fails wih the error [nuxt:composable-keys] Unexpected character '@' which refers to the use of @component (and I guess any use of a decorator).
The dev script works with warning regarding to the use of vite.config.js file (which is not supported by Nuxt but magically works in dev server mode).
I tried to put the vite.config.js recommended configuration in the nuxt.config.ts vite option but all attempts have failed.
If anyone has succeed to use this package with Nuxt3, I would be very interested by his input.
The text was updated successfully, but these errors were encountered: