Skip to content
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

[vite-plugin-alphatab-url] plugins is not a function #1575

Closed
1 task done
bali182 opened this issue Jul 9, 2024 · 1 comment
Closed
1 task done

[vite-plugin-alphatab-url] plugins is not a function #1575

bali182 opened this issue Jul 9, 2024 · 1 comment
Assignees
Labels
state-needs-triage Bug not triaged yet.

Comments

@bali182
Copy link

bali182 commented Jul 9, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When executing vite build with the alphaTab plugin I get an error. I don't experience any issues when I run it in development mode using the vite command. The error when running vite build looks like this:

vite v4.5.3 building for production...
✓ 100 modules transformed.
✓ built in 610ms
[vite-plugin-alphatab-url] plugins is not a function
file: E:/code/dawn/node_modules/@coderline/alphatab/dist/alphaTab.mjs
error during build:
TypeError: plugins is not a function
    at bundleWorkerEntry (E:\code\dawn\node_modules\@coderline\alphatab\dist\alphaTab.vite.js:1688:24)
    at async workerFileToUrl (E:\code\dawn\node_modules\@coderline\alphatab\dist\alphaTab.vite.js:1654:29)
    at async Object.transform (E:\code\dawn\node_modules\@coderline\alphatab\dist\alphaTab.vite.js:1852:32)
    at async transform (file:///E:/code/dawn/node_modules/rollup/dist/es/shared/node-entry.js:24449:16)
    at async ModuleLoader.addModuleSource (file:///E:/code/dawn/node_modules/rollup/dist/es/shared/node-entry.js:24649:30)

The relevant piece of code in in alphaTab.vite.js looks like this:

const bundle = await rollup({
    ...rollupOptions,
    input,
    // plugins seems to be missing here
    plugins: await plugins(newBundleChain),
    preserveEntrySignatures: false
});

Expected Behavior

The build to successfully complete

Steps To Reproduce

My config is pretty simple (it's a typescript project):

I'm trying to build using:

vite build

This is my vite.config.ts file

import { defineConfig } from 'vite'
import { alphaTab } from '@coderline/alphatab/vite'
import react from '@vitejs/plugin-react'

export default defineConfig({
  plugins: [alphaTab(), react()],
  appType: 'spa',
})

And this is how I import alphatab:

// In one file:
import { AlphaTabApi, synth } from '@coderline/alphatab'

// In another file, just typings:
import type { CoreSettings, PlayerSettings } from '@coderline/alphatab'

Link to jsFiddle, CodePen, Project

I don't know if this can be demonstrated on jsfiddle or codepen, but I made a very simple repro repo:
https://github.com/bali182/alphatab-vite-build-bug-repro

Found in Version

1.3

Platform

Web

Environment

- **OS**: Win 11 Home
- **Browser**: Not relevant
- **.net Version**: Not relevant

Anything else?

No response

@bali182 bali182 added the state-needs-triage Bug not triaged yet. label Jul 9, 2024
@bali182
Copy link
Author

bali182 commented Jul 12, 2024

It's my bad, my vite version was one major version behind current. Should have started with checking that. After updating to vite 5.3.3 it builds fine both alphatab 1.3 and 1.4 alpha

@bali182 bali182 closed this as completed Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state-needs-triage Bug not triaged yet.
Projects
None yet
Development

No branches or pull requests

2 participants