Skip to content

Commit

Permalink
Update esm.md
Browse files Browse the repository at this point in the history
Move the chapter about configuration file at the top of the doc to give it more visibility
  • Loading branch information
aurelien-reeves authored Dec 1, 2021
1 parent 9e9ec3c commit ba5ff34
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

You can optionally write your support code (steps, hooks, etc) with native ES modules syntax - i.e. using `import` and `export` statements without transpiling. This is enabled without any additional configuration, and you can use either of the `.js` or `.mjs` file extensions.

**Important**: please note that your configuration file referenced for [Profiles](./profiles.md) - aka `cucumber.js` file - must remain a CommonJS file. In a project with `type=module`, you can name the file `cucumber.cjs`, since Node expects `.js` files to be in ESM syntax in such projects.

Example (adapted from [our original example](./nodejs_example.md)):

```javascript
Expand Down Expand Up @@ -30,5 +32,3 @@ As well as support code, these things can also be in ES modules syntax:
You can use ES modules selectively/incrementally - so you can have a mixture of CommonJS and ESM in the same project.

When using a transpiler for e.g. TypeScript, ESM isn't supported - you'll need to configure your transpiler to output modules in CommonJS syntax (for now).

The config file referenced for [Profiles](./profiles.md) can only be in CommonJS syntax. In a project with `type=module`, you can name the file `cucumber.cjs`, since Node expects `.js` files to be in ESM syntax in such projects.

0 comments on commit ba5ff34

Please sign in to comment.