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

Importing the alphaTab WebPack plugin in ESM fails. #1523

Closed
1 task done
Danielku15 opened this issue Jun 1, 2024 · 0 comments · Fixed by #1539
Closed
1 task done

Importing the alphaTab WebPack plugin in ESM fails. #1523

Danielku15 opened this issue Jun 1, 2024 · 0 comments · Fixed by #1539
Assignees
Labels
area-bundlers Related to the bundler plugins like webpack and vite platform-javascript Related to the JavaScript version of alphaTab state-accepted This is a valid topic to work on.
Milestone

Comments

@Danielku15
Copy link
Member

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

import { AlphaTabWebPackPlugin } from "@coderline/alphatab/webpack"; in a ESM file leads to import errors like:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'D:\Dev\alphaTabSamplesWeb\src\webpack-nextjs\node_modules\webpack\lib\util\identifier' imported from D:\Dev\alphaTabSamplesWeb\src\webpack-nextjs\node_modules\@coderline\alphatab\dist\alphaTab.webpack.mjs
Did you mean to import webpack-nextjs/node_modules/webpack/lib/util/identifier.js?

This is because for ESM imports in node file extensions are mandatory: https://nodejs.org/api/esm.html#esm_mandatory_file_extensions

But the webpack plugin imports some webpack files directly without extension

image

Expected Behavior

Imports must work.

Steps To Reproduce

  1. npx create-next-app@latest
  2. Add import { AlphaTabWebPackPlugin } from "@coderline/alphatab/webpack"; to the next.config.mjs
  3. npm run dev

Link to jsFiddle, CodePen, Project

No response

Found in Version

1.3

Platform

Web

Environment

- node v20.9.0
- npm 10.2.3

Anything else?

Adding the .js extension to the modules fixes the problem. In CJS files the require without extension works.

@Danielku15 Danielku15 added the state-needs-triage Bug not triaged yet. label Jun 1, 2024
@Danielku15 Danielku15 self-assigned this Jun 1, 2024
@Danielku15 Danielku15 added 🕷️ type-bug state-accepted This is a valid topic to work on. platform-javascript Related to the JavaScript version of alphaTab area-bundlers Related to the bundler plugins like webpack and vite and removed state-needs-triage Bug not triaged yet. labels Jun 1, 2024
@Danielku15 Danielku15 moved this to Todo in alphaTab 1.4-1.x Jun 1, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in alphaTab 1.4-1.x Jun 15, 2024
@Danielku15 Danielku15 added this to the 1.4.0 milestone Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-bundlers Related to the bundler plugins like webpack and vite platform-javascript Related to the JavaScript version of alphaTab state-accepted This is a valid topic to work on.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant