Docs: Add notes about esm support (closes #2278) · gulpjs/gulp@4091bd3

2 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -124,6 +124,8 @@ exports.default = build;

124124
125125

## Use latest JavaScript version in your gulpfile

126126
127+

__Most new versions of node support most features that Babel provides, except the `import`/`export` syntax. When only that syntax is desired, rename to `gulpfile.esm.js`, install the [esm][esm-module] module, and skip the Babel portion below.__

128+
127129

Node already supports a lot of __ES2015+__ features, but to avoid compatibility problems we suggest to install Babel and rename your `gulpfile.js` to `gulpfile.babel.js`.

128130
129131

```sh

Original file line numberDiff line numberDiff line change

@@ -20,6 +20,8 @@ You can write a gulpfile using a language that requires transpilation, like Type

2020

* For TypeScript, rename to `gulpfile.ts` and install the [ts-node][ts-node-module] module.

2121

* For Babel, rename to `gulpfile.babel.js` and install the [@babel/register][babel-register-module] module.

2222
23+

__Most new versions of node support most features that TypeScript or Babel provide, except the `import`/`export` syntax. When only that syntax is desired, rename to `gulpfile.esm.js` and install the [esm][esm-module] module.__

24+
2325

For a more advanced dive into this topic and the full list of supported extensions, see our [gulpfile transpilation][gulpfile-transpilation-advanced] documentation.

2426
2527

## Splitting a gulpfile

@@ -33,3 +35,4 @@ Node's module resolution allows you to replace your `gulpfile.js` file with a di

3335

[gulpfile-transpilation-advanced]: ../documentation-missing.md

3436

[ts-node-module]: https://www.npmjs.com/package/ts-node

3537

[babel-register-module]: https://www.npmjs.com/package/@babel/register

38+

[esm-module]: https://www.npmjs.com/package/esm