From 9d6c293966d03f10253a339a475f297c06df98cf 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 2fe6ffc2a9f050..862fcae43aa5f2 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -540,16 +540,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 ```