Skip to content

Instantly share code, notes, and snippets.

@MylesBorins
Created February 21, 2021 21:09
Show Gist options
  • Save MylesBorins/2df2d7f6699c87e7c62e5a59b9281afd to your computer and use it in GitHub Desktop.
Save MylesBorins/2df2d7f6699c87e7c62e5a59b9281afd to your computer and use it in GitHub Desktop.
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`));
process.exit(1);
}
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