Skip to content
This repository was archived by the owner on Apr 16, 2020. It is now read-only.

Conversation

@MylesBorins
Copy link
Contributor

@MylesBorins MylesBorins commented Mar 7, 2019

Original doesn't really make sense in retrospect

updates example to

// cjs.js module.exports = 'cjs'; // esm.mjs import { createRequireFromPath as createRequire } from 'module'; import { fileURLToPath as fromURL } from 'url'; const require = createRequire(fromURL(import.meta.url)); const cjs = require('./cjs'); cjs === 'cjs'; // true
@GeoffreyBooth
Copy link
Member

Can you please target the docs branch?

@MylesBorins MylesBorins changed the base branch from modules-lkgr to docs March 7, 2019 07:16
@MylesBorins
Copy link
Contributor Author

@GeoffreyBooth
Copy link
Member

Out of scope for this PR, but I just read the createRequireFromPath docs and they don’t explain why you’d want a require function where the argument it’s given is relative to some folder other than the one the current file is in. It seems pretty pointless outside of the ESM import.meta.url context.

@GeoffreyBooth GeoffreyBooth force-pushed the docs branch 2 times, most recently from b80ef53 to d3bd8e0 Compare March 7, 2019 10:20
Original doesn't really make sense in retrospect
@MylesBorins MylesBorins merged commit e32881f into docs Mar 8, 2019
@ljharb ljharb deleted the minor-tweak branch March 8, 2019 04:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants