From 26ef1120e1c4a60da559aaba92b9c4c6acd1ea74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Reeves?= Date: Wed, 1 Dec 2021 15:49:14 +0100 Subject: [PATCH] Update esm.md (#1862) Move the chapter about configuration file at the top of the doc to give it more visibility --- docs/esm.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/esm.md b/docs/esm.md index 9e7e2a54e..bea20b256 100644 --- a/docs/esm.md +++ b/docs/esm.md @@ -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 @@ -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.