Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
No more CJS `$ node --experimental-loader ./no-cjs.mjs index.mjs`
import './no-more.cjs';
* @param {string} url
* @param {Object} context (currently empty)
* @param {Function} defaultGetFormat
* @returns {Promise<{ format: string }>}
export async function getFormat(url, context, defaultGetFormat) {
const result = await defaultGetFormat(url);
if (result.format === 'commonjs') {
console.error(new Error(`${url} is a cjs module`));
return result;
module.exports = 'this should not work';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment