gianlucamangiapelo / wdio-azure-devops-service

Custom WDIO service to publish WebdriverIO results on Azure DevOps Test Plans.
MIT License
8 stars 5 forks source link

ESM import fails #12

Open halovanic opened 1 year ago

halovanic commented 1 year ago

When I try to use import AzureDevopsService from "@gmangiapelo/wdio-azure-devops-service" in V8 with a plain JavaScript project (no TypeScript or Babel to modify node_modules), it fails on internal imports:

Error: Failed to initilialise launcher service unknown: Error: Couldn't initialise "@gmangiapelo/wdio-azure-devops-service".
C:\dev\e2e\node_modules\@gmangiapelo\wdio-azure-devops-service\dist\esm\index.js:1
import AzureDevopsService from './azure-devops-service';

One way I was able to resolve this was:

  1. Change the type of both of your modules to "module" in package.json
  2. Update all file imports to use a full .js path reference as Node's module system is not as forgiving as Babel or TypeScript's.

A simpler way seems to be to simply set your import reference in wdio-azure-devops-service's package.json to also point to the cjs version as with require. This seems to work correctly in an import scenario without having to alter anything further.

CrochetCat commented 4 months ago

I'm having the same issues but don't seem to be able to get your fixes working. Doesn't seem like there have been any updates in some time.

Gajhenthran commented 2 months ago

@halovanic can you please explain how you made it work in detail?

Gajhenthran commented 2 months ago

@gianlucamangiapelo This ESM error is still happening, can you provide a solution for this!! Thanks.