CoderLine / alphaTab

alphaTab is a cross platform music notation and guitar tablature rendering library.
http://www.alphatab.net
Mozilla Public License 2.0
1.24k stars 202 forks source link

Importing the alphaTab WebPack plugin in ESM fails. #1523

Closed Danielku15 closed 3 months ago

Danielku15 commented 4 months ago

Is there an existing issue for this?

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.