-
Notifications
You must be signed in to change notification settings - Fork 568
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
Using Vite with custom Accessor classes #524
Comments
Thanks @sebastianfrey. I was able to get Accessor decorators working in a test app by adding the following to the "experimentalDecorators": true, I'll add a note to that SDK documentation page you mentioned above. I didn't see it mentioned anywhere that the core API is currently using legacy decorators. For reference, in case others come across this thread, the error message will be similar to this: |
Hi @andygup, thanks for your feedback on this. Some additional notes: For me the error message When using For import reactSwc from "@vitejs/plugin-react-swc";
export default defineConfig({
plugins: [
reactSwc({
// Requires experimentalDecorators in tsconfig
tsDecorators: true,
}),
]
}); Note: It's required, as stated out by @andygup, to set experimentalDecorators to true in But for
So when using |
Recently I migrated a Typescript app from CRA to Vite that contained some classes that used Accessor decorators as described here. The problem, was that Vite failed to serve those classes, because Accessor decorators must be transpiled by typescript.
As solution, I have created a simple configurable Vite plugin, which allows to transform classes with custom Accessor decorators on the fly using typescript. I thought this might be useful for someone else in the future, so I wanted to share this plugin here:
vite-arcgis-plugin.ts
Inside vite.config.ts the plugin can used in the following way:
The text was updated successfully, but these errors were encountered: