lint_css job throwing ERR_UNSUPPORTED_DIR_IMPORT error with stylelint 16.x
Hi,
I think that the lint_css job may need a small modification in the "--custom-formatter" parameter in order to work properly with stylelint 16.x. (The following thread seems to suggest that's where the problem lies: <https://github.com/eddies/stylelint-junit-formatter/issues/12\>)
When I run the lint_css job as currently configured in this project (set to Drupal 10.4, 4.x-dev branch), the job fails, with the following error preventing successful completion:
$ node ${CI_LINT_NODE_BIN_DIR}/stylelint --config ${CI_CONFIG_STYLELINT} --ignore-path ${CI_CONFIG_STYLELINT_IGNORE} --custom-formatter ${CI_LINT_NODE_PACKAGE}/node_modules/stylelint-gitlabci-formatter --output-file ${CI_PROJECT_DIR}/report-${CI_JOB_NAME}/${CI_JOB_NAME}_junit.xml "${CI_DIRS_LINT_CSS}"
node:internal/process/promises:391
triggerUncaughtException(err, true /* fromPromise */);
^
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/opt/drupal/public/core/node_modules/stylelint-gitlabci-formatter' is not supported resolving ES modules imported from /builds/dghi-sites/drupal-sites/dghi-d8/public/core/node_modules/stylelint/lib/utils/dynamicImport.mjs
Did you mean to import "/builds/dghi-sites/drupal-sites/dghi-d8/public/core/node_modules/stylelint-gitlabci-formatter/index.js"?
at finalizeResolution (node:internal/modules/esm/resolve:271:11)
at moduleResolve (node:internal/modules/esm/resolve:952:10)
at defaultResolve (node:internal/modules/esm/resolve:1188:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:642:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:591:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:574:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:236:38)
at ModuleLoader.import (node:internal/modules/esm/loader:539:34)
at defaultImportModuleDynamicallyForModule (node:internal/modules/esm/utils:215:31)
at importModuleDynamicallyCallback (node:internal/modules/esm/utils:254:12) {
code: 'ERR_UNSUPPORTED_DIR_IMPORT',
url: 'file:///opt/drupal/public/core/node_modules/stylelint-gitlabci-formatter'
}
If I modify the lint_css job to change this line (line 235 in .gitlab-ci/jobs.gitlab-ci.yml):
--custom-formatter ${CI_LINT_NODE_PACKAGE}/node_modules/stylelint-gitlabci-formatter
...to become:
--custom-formatter ${CI_LINT_NODE_PACKAGE}/node_modules/stylelint-gitlabci-formatter/index.js
then the job runs successfully, or at least without fatal errors/exceptions.
Currently, I have just inserted the entire lint_css job with the modification above at the bottom of my .gitlab-ci.yml file, but I'm hopeful that if the fix above is indeed the problem, I can go back to using the repository's job definitions.
If you need more information, or you're not seeing this issue on your end, I can try to provide more details.
All that aside, though, I also wanted to thank you for such a great project! You've made things so much easier for us to incorporate GitLab-CI features in our Drupal work. We really appreciate it!
-- Ken