From d635f338d3cbb70b89a2bd919ef369c5e538319c Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Fri, 15 Nov 2019 09:29:18 -0800 Subject: [PATCH] doc: createRequire can take import.meta.url directly --- doc/api/esm.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/api/esm.md b/doc/api/esm.md index 086f359f5dee9f..f50aacac41c1c7 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -848,16 +848,15 @@ CommonJS, JSON, and Native modules can be used with [`module.createRequire()`][]. ```js -// cjs.js +// cjs.cjs module.exports = 'cjs'; // esm.mjs import { createRequire } from 'module'; -import { fileURLToPath as fromURL } from 'url'; -const require = createRequire(fromURL(import.meta.url)); +const require = createRequire(import.meta.url); -const cjs = require('./cjs'); +const cjs = require('./cjs.cjs'); cjs === 'cjs'; // true ```