cucumber / cucumber-js

Cucumber for JavaScript
https://cucumber.io
MIT License
5.02k stars 1.09k forks source link

use import by default for support code #2337

Closed davidjgoss closed 10 months ago

davidjgoss commented 10 months ago

🤔 What's changed?

Previously if you specified neither require nor import options, Cucumber would look under your feature directories for .js files and load them using require(). As part of our gradual move to the newer JavaScript modules system, we want to have that default behaviour use await import() instead.

This should be backwards-compatible for at least 99% of cases, since CommonJS code can still be loaded with await import(). The require option should only be needed when transpiling with require-module - although in those cases users are almost certainly specifying the require option already due the different file extensions like .ts. There's now a warning emitted if require-module values are provided but no require which should help guide users. Nevertheless we'll release this under a major.

Also, update documentation to emphasise import over require, and JSON over other configuration file formats.

⚡️ What's your motivation?

From https://github.com/cucumber/cucumber-js/discussions/2059:

The default behaviour (if neither of [require or import options] specified) uses await import()

🏷️ What kind of change is this?

📋 Checklist:


This text was originally generated from a template, then edited by hand. You can modify the template here.