Created
February 21, 2021 21:09
-
-
Save MylesBorins/2df2d7f6699c87e7c62e5a59b9281afd to your computer and use it in GitHub Desktop.
No more CJS `$ node --experimental-loader ./no-cjs.mjs index.mjs`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import './no-more.cjs'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = 'this should not work'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment