Skip to content

Fixed the window ci problem#47680

Open
pratibha-builds wants to merge 2 commits intojoomla:6.2-devfrom
pratibha-builds:fix-esm-windows
Open

Fixed the window ci problem#47680
pratibha-builds wants to merge 2 commits intojoomla:6.2-devfrom
pratibha-builds:fix-esm-windows

Conversation

@pratibha-builds
Copy link
Copy Markdown

Pull Request resolves #47679

  • I read the Generative AI policy and my contribution is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

This PR fixes a Windows-specific issue in the Joomla build process where npm install / asset build fails due to invalid ESM import paths.

On Windows, absolute file paths like:

C:\Users\...

were passed directly into dynamic import() calls. Node.js ESM loader requires valid URLs (file:// scheme), which caused the error:

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]

To resolve this:

  • All dynamic imports using file paths are converted using:

    pathToFileURL(resolvedPath).href
  • Paths are normalized using path.resolve()

  • Fixed JSON module import in TinyMCE builder

  • Updated Rollup config in Codemirror builder using inlineDynamicImports: true to avoid multi-chunk output errors

This ensures the build works correctly on Windows systems.


Testing Instructions

  1. Clone Joomla repository on Windows
  2. Switch to 6.2-dev branch
  3. Run:
npm install

Actual result BEFORE applying this Pull Request

  • npm install fails during build
  • Error:
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]
  • In some cases:
RollupError: Invalid value for option "output.file"

Screenshot (Before Fix)

cli_error_fix

Expected result AFTER applying this Pull Request

  • npm install completes successfully
  • All build steps execute without errors
  • Joomla assets are generated correctly

Screenshot (After Fix)

image

Additional Context

While testing, it was observed that running:

composer install

may fail if required PHP extensions (gd, sodium, ldap and zip) are missing.
This is an environment setup issue and not related to this bug, but it may affect contributors during setup.


Link to documentations

Relevant references:

@joomla-cms-bot joomla-cms-bot added NPM Resource Changed This Pull Request can't be tested by Patchtester PR-6.2-dev labels Apr 24, 2026
@CSGoat0
Copy link
Copy Markdown

CSGoat0 commented Apr 24, 2026

I have tested this item ✅ successfully on 3f33579

This works.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/47680.

format: targetPath.endsWith('core.js') ? 'iife' : 'es',
sourcemap: false,
file: targetPath,
inlineDynamicImports: true,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not looks like related to the issue. Explain

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out.

While working on the Windows ESM issue, I encountered an additional failure in the Codemirror build step:

RollupError: Invalid value for option "output.file"

This happens because Codemirror uses dynamic imports, which causes Rollup to generate multiple chunks. In that case, using output.file is invalid unless inlineDynamicImports is enabled or output.dir is used.

To keep the existing single-file output behavior consistent, I added inlineDynamicImports: true.

However, I understand this is not directly related to the original ESM issue. I can remove this change and keep the PR focused if preferred.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am always concerned when the same post is made by a completely different person. The first version of this comment was made by @devesht-ML - github emails all comments - even if they are subsequently deleted

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this came because i am working with team so unfortunately that person does this reply.
I was sorry for this behaviour and fault.

Copy link
Copy Markdown
Member

@Fedik Fedik Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not like this change, but I cannot currently check.

@dgrammatiko can you please have an eye? Whether it does not break final result

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other changes with the path/url are fine, this line NO!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dgrammatiko Do i have to remove this [inlineDynamicImports: true,] part.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fedik @dgrammatiko
Hello, I have tested the fix with and without that line.

The path/URL changes fixes ERR_UNSUPPORTED_ESM_URL_SCHEME.

The inlineDynamicImports: true line fixes another error:
npm error code 1 npm error path D:\(my path to joomla project)\joomla-cms npm error command failed npm error command C:\Windows\system32\cmd.exe /d /s /c node --env-file=./build/production.env build/build.mjs build -a npm error A complete log of this run can be found in: C:\(my path to the local)\Local\npm-cache\_logs\2026-04-25T20_19_31_521Z-debug-0.log

When I removed that line, I saw the error.
I see that you have agreed on the URL/Path solution. I tested it on windows, I don't know about other OSs.

If you think that the line inlineDynamicImports: true is a wrong fix to the error I mentioned above, then I suggest keeping the fix of ERR_UNSUPPORTED_ESM_URL_SCHEME in this PR, removing inlineDynamicImports: true and opening another issue with the other error requiring a proper fix.

In summary: there is now 2 separated errors, one documented in an issue and another one isn't.

Copy link
Copy Markdown

@CSGoat0 CSGoat0 Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pratibha-builds, I see that the maintainers asked for a detailed explanation of the line. It would be helpful if you can explain how this line solves the problem and if it's safe. You can also answer on their concern about if this is true: This will probably undo the whole concept of importmaps.

This will help, thanks.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback and review.

I tested the changes on Windows and observed two separate issues:

  1. The original issue:
    ERR_UNSUPPORTED_ESM_URL_SCHEME
    → This is resolved by converting paths using pathToFileURL(), and works as expected.

  2. A separate issue in the Codemirror build:
    RollupError: Invalid value for option "output.file"

I initially added inlineDynamicImports: true because it allows Rollup to inline dynamic imports and avoid the multi-chunk error. However, I understand this changes bundling behavior and may interfere with importmaps, as mentioned.

To keep this PR focused and safe, I have removed the inlineDynamicImports change.

The Rollup issue appears to be unrelated and likely needs a separate discussion or fix (e.g. using output.dir or adjusting module handling properly).

Please let me know if you would like me to open a separate issue for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug NPM Resource Changed This Pull Request can't be tested by Patchtester PR-6.2-dev

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants