From 79126fc29b8cb9d6d817961bcd1d2dffea33729a 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 PR-URL: https://github.com/nodejs/node/pull/30495 Reviewed-By: Myles Borins Reviewed-By: Guy Bedford --- 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 ```