-
Notifications
You must be signed in to change notification settings - Fork 204
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
alphaTab can't work with vue3 #699
Comments
This topic is discussed already some other issues and also here in the documentation: https://alphatab.net/docs/getting-started/installation-web#bundling You must take care of the correct bundling aspects in your project. This is nothing alphaTab can do for you. alphaTab needs to spawn WebWorkers with the file it is contained in (or manually specified). I couldn't see any appropriate WebPack configuration in the project to take care of this. I have it on my todo list to evaluate some solutions for the most common bundlers (WebPack and Rollup) but I haven't found the time yet to dive into this topic and prepare some recommendations. The WebPack/Vue community might be better able to help on this particular case where libraries require WebWorkers to work. Additionally your example doesn't seem to be fully set up yet. In my test the actual setup code was not called and there wasn't even an attempt to initialize alphaTab. |
Thanks. You could click on the |
Ah, I didn't realize that I played a bit around today with webpack but could not yet find some good solution how alphaTab can improve the situation. I separated alphaTab into an own chunk to solve the issue of being bundled with Vue: const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
lintOnSave: false,
pluginOptions: {
vuetify: {
// https://github.com/vuetifyjs/vuetify-loader/tree/next/packages/vuetify-loader
}
},
configureWebpack: config => {
config.optimization.splitChunks.cacheGroups.alphatab = {
chunks: 'all',
name: 'chunk-alphatab',
priority: config.optimization.splitChunks.cacheGroups.defaultVendors.priority + 10,
test: /.*node_modules.*alphatab.*/
};
}
}); But WebPack still causes some troubles with this approach. First of all I could not really find a good way to detect from within alphaTab in which chunk it is now contained. In the mentioned example I could not obtain But secondly WebPack also prevents and global initialization routines to run unless somebody imports alphaTab (which doesn't really happen in this case). There are various approaches outside of alphaTab that could help but it requires some heavy lifting on the integration side. You would wrap alphaTab into an own module where you need to take care that bundling and URL resolving works. I gave it a try according to what is discussed here. But it seems Vue.js has again some special configurations which spoil the built-in WebWorker features to work. Instead of actually producing a web worker asset from TypeScript, the worker URL is actually resolved to a TypeScript files. As you can see: there are so many aspects involved in these frameworks that make it hard for alphaTab to solve this within the library. The whole concept of bundling (no matter if WebPack or Rollup) does simply not integrate well with the API design they standarized for WebWorkers and AudioWorklets which require a particular file to be loaded as Worker. Examples are typically very minimalistic. The biggest questionmark I have is: Why does WebPack rewrite The only realistic solution I see for the future is to create an own WebPack and Rollup plugin which takes care of a proper handling of the chunks and related URLs. The minimalistic default features seem to fail to provide a solution to this setup where one bundle is used as worker and as dependency. |
Closing this issue in favor of #759 |
Is there an existing issue for this?
Current Behavior
I am trying to use vue3 to implement https://www.alphatab.net/docs/getting-started/installation-web#initializing-alphatab, but it doesn't work, here is my code:
Expected Behavior
it can work with vue3 correctly.
Steps To Reproduce
https://github.com/Claroja/testforalphaTab
Link to jsFiddle, CodePen, Project
https://github.com/Claroja/testforalphaTab/blob/main/src/components/HelloWorld.vue
Found in Version
1.2
Platform
Web
Environment
Anything else?
I found some useful information in #662. Then I put the
alphaTab.js
intopublic/index.html
. It works, but it's inelegant.The text was updated successfully, but these errors were encountered: