Skip to content
Permalink
Browse files

doc: createRequire can take import.meta.url directly

PR-URL: #30495
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
  • Loading branch information
GeoffreyBooth authored and MylesBorins committed Nov 15, 2019
1 parent f61882b commit 79126fc29b8cb9d6d817961bcd1d2dffea33729a
Showing with 3 additions and 4 deletions.
  1. +3 −4 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
```

0 comments on commit 79126fc

Please sign in to comment.
You can’t perform that action at this time.