timjroberts / cucumber-js-tsflow

Provides 'specflow' like bindings for Cucumber.js in TypeScript 1.7+.
MIT License
133 stars 34 forks source link

Improve support for packages using "type": "module" in their package.json #151

Closed bmac closed 1 month ago

bmac commented 4 months ago

I have a remix project where I'm using cucumber-tsflow and the root of my project has "type": "module" in it's package.json. Unfortunately this changes how node resolves modules in a way that makes it which makes it somewhat cumbersome to work with cucumber-tsflow's exports. As a result I end up doing this:

import TsFlow from "cucumber-tsflow";
const { binding, then, when, after, afterAll, before } = TsFlow;

Annoyingly, the usually fix for this issue is for the library to accept some additional complexity and ship multiple implementations one in the commonjs format and one in the esm format. So that is what the PR attempts to do.

The current implementation of this pr would require a major version bump because "type": "module" users such as myself would no longer see a default export and would need to change their code to use named exports.

// This errors
import TsFlow from "cucumber-tsflow";

// This works
import { binding, then, when, after, afterAll, before } from "cucumber-tsflow";

I don't believe there is any impact for user without "type": "module". Additionally if you would prefer to avoid a major version bump we can create a default export for the "type": "module" users that matches the current behavior.

Fryuni commented 4 months ago

Can we have tests for ESM support?

ccremer commented 3 months ago

I'd love to see this feature as well. Is there an update?

Fryuni commented 3 months ago

I'm not personally using cucumber-tsflow on any ESM project, so I'm not pushing for this myself.

I don't have any other points besides the comments above, if anyone wants to add tests for it I'll be glad to review 😁

bmac commented 3 months ago

I'll try to find some time later this week to add tests and clean this up.

github-actions[bot] commented 1 month ago

This PR is stale because it has been 60 days with no activity. Remove stale lable or comment or this will be closed in 7 days.

github-actions[bot] commented 1 month ago

There hasn't been any activity on this PR for 67 days. Closing it as Spoiled.