From fa8a5316d81a14de3a33dcae1870221f2e38f7f4 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 10 Jun 2020 14:01:02 -0700 Subject: [PATCH 1/2] doc: clarify require/import mutual exclusivity --- doc/api/esm.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/api/esm.md b/doc/api/esm.md index 38885d7a0b243e..5cee9e103c0624 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -424,8 +424,10 @@ Node.js supports the following conditions: * `"import"` - matched when the package is loaded via `import` or `import()`. Can reference either an ES module or CommonJS file, as both `import` and `import()` can load either ES module or CommonJS sources. + _Mutually exclusive with the `"require"` condition._ * `"require"` - matched when the package is loaded via `require()`. As `require()` only supports CommonJS, the referenced file must be CommonJS. + _Mutually exclusive with the `"import"` condition._ * `"node"` - matched for any Node.js environment. Can be a CommonJS or ES module file. _This condition should always come after `"import"` or `"require"`._ From 4047e1e2b69832a1c344cfbb7c07a59d4b9f73d0 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 10 Jun 2020 15:50:35 -0700 Subject: [PATCH 2/2] thwarted again by boolean logic --- doc/api/esm.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/esm.md b/doc/api/esm.md index 5cee9e103c0624..e14a9d2877cd99 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -424,10 +424,10 @@ Node.js supports the following conditions: * `"import"` - matched when the package is loaded via `import` or `import()`. Can reference either an ES module or CommonJS file, as both `import` and `import()` can load either ES module or CommonJS sources. - _Mutually exclusive with the `"require"` condition._ + _Always matched when the `"require"` condition is not matched._ * `"require"` - matched when the package is loaded via `require()`. As `require()` only supports CommonJS, the referenced file must be CommonJS. - _Mutually exclusive with the `"import"` condition._ + _Always matched when the `"import"` condition is not matched._ * `"node"` - matched for any Node.js environment. Can be a CommonJS or ES module file. _This condition should always come after `"import"` or `"require"`._