Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use js loader for .cjs and .mjs files #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

angeloashmore
Copy link

@angeloashmore angeloashmore commented Aug 20, 2021

This PR adds support for .cjs and .mjs files by overriding their loader to js.

Per esbuild's js loader docs, the js loader supports .cjs and .mjs files and treats them the same as .js files.

Without this PR, importing a .cjs or .mjs file prints the following error:

Error: Invalid loader: "cjs" (valid: js, jsx, ts, tsx, css, json, text, base64, dataurl, file, binary)

› /[project-path]/node_modules/esbuild/lib/main.js:1209:25
› /[project-path]/node_modules/esbuild/lib/main.js:606:9
› handleIncomingPacket (/[project-path]/node_modules/esbuild/lib/main.js:701:9)
› readFromStdout (/[project-path]/node_modules/esbuild/lib/main.js:573:7)
› runServiceSync (/[project-path]/node_modules/esbuild/lib/main.js:1808:3)
› buildSync (/[project-path]/node_modules/esbuild/lib/main.js:1628:3)
› compile (/[project-path]/register.js:112:39)
› requireExtensions.<computed> (/[project-path]/register.js:164:28)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant