wcm-io-frontend / aem-clientlib-generator

Creates configuration files for AEM ClientLibs and synchronizes assets.
Apache License 2.0
62 stars 32 forks source link

Issue #48: changed from commonjs to es6 modules #49

Open austen-wade opened 1 year ago

austen-wade commented 1 year ago

https://github.com/wcm-io-frontend/aem-clientlib-generator/issues/48

I have tested this change on two separate ui.frontend repositories and they seem to work. I configured the repositories as follows:

I did not encounter any issue with either build.

Also, yargs had to be updated itself to latest for esmodules support. The api has slightly changed as the imported item is no longer a singleton.

stefanseifert commented 1 year ago

i would like to switch our frontend modules to "type=module" as well.

i tried your branch, but failed to execute it on windows - seems to be a windows-specific path problem. when executing i got:

[ERROR] [nodejs] Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
[INFO] [nodejs]     at new NodeError (node:internal/errors:372:5)
[INFO] [nodejs]     at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1120:11)
[INFO] [nodejs]     at defaultResolve (node:internal/modules/esm/resolve:1200:3)
[INFO] [nodejs]     at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
[INFO] [nodejs]     at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
[INFO] [nodejs]     at ESMLoader.import (node:internal/modules/esm/loader:380:22)
[INFO] [nodejs]     at importModuleDynamically (node:internal/modules/esm/translators:106:35)
[INFO] [nodejs]     at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
[INFO] [nodejs]     at file:///C:/temp/betacloudProject/frontend/node_modules/aem-clientlib-generator/bin/clientlib-cli.js:48:1
[INFO] [nodejs]     at ModuleJob.run (node:internal/modules/esm/module_job:198:25) {
[ERROR] [nodejs]   code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'

seems to work fine on linux!

mbehzad commented 1 year ago

Hi @austen-wade ,

cheers