-
-
Notifications
You must be signed in to change notification settings - Fork 689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make cucumber-expressions compatible with both cjs and esm #1743
Make cucumber-expressions compatible with both cjs and esm #1743
Conversation
Yes, the build still have to be fixed. I already have some ideas for that, this is not an issue (yet 😅) |
That way we will avoid duplication of ts-node section in packages tsconfig.json. Once all module have been converted, we will be able to move the ts-node configuration into the root level tsconfig.json.
…s/package.json' files
It should be ready now.
The legacy one will be removed once all the packages in the monorepo will be converted. We will need the It looks like a lot of files to review. But actually, all the There is a new template project Also you may notice that there is that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me.
One query: this whole topic got kicked off because some packages that we depend on are starting to publish as ESM only, which causes us an issue because you can't require
ESM modules. So with that in mind, how does the CommonJS code that we generate in the "cjs" version here handle those cases?
tsconfig.build-esm.json
Outdated
"extends": "./tsconfig.build.json", | ||
"compilerOptions": { | ||
"lib": [ | ||
"es6" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I don't think we need to go as far down as ES5 or ES6 - our minimum support is Node 12 so it can be ES2019.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll give it a try
Indeed, we'll have the same issue. We could imagine, for example, migrating all @cucumber/packages one by one using the proposed cjs/esm technique. That way we may be able to convert cucumber-js relatively easily. Then once cucumber-js has been converted, we can update those dependencies by removing the support for cjs just for the impacted packages. I don't say we will be able to do it that way. But this is at least a first step into moving to esm. |
@aslakhellesoy no objection into merging this PR? |
The cjs packages we build will fail at runtime if they depend on esm-only modules. There is no point in releasing a package that doesn’t work, so we should test that it works before we release it. Can we add a |
We could, but there is no point to do so. The build would have failed in such case. And |
I am actually facing some difficulties: while I was trying to move With ESM, there is no Any idea how we could going through this? |
With @aslakhellesoy we have identified a workaround to avoid the issue I mentioned earlier |
@aslakhellesoy agree to merge? |
Awesome!!!! |
This is another approach to gently make the packages compatible with ESM.
Refs. #1709
The idea is pretty close to PR#1709. Main differences are:
The global idea is:
module
(ESM).js
extensions anyway 🙄So, JavaScript folks (@aslakhellesoy @charlierudolph @davidjgoss, and actually anyone) what do you think?
I have already used that technique for
reindent-template-literals
, so if you want to take a look on how it works, you can take a look on the tiny package here: https://gitlab.com/kao98/reindent-template-literals. It has some acceptance tests which illustrate the usage of such package: https://gitlab.com/kao98/reindent-template-literals/-/tree/main/tests