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: don't obfuscate CommonJS/ESM file extension errors #103

Open
sheerlox opened this issue Feb 15, 2024 · 0 comments
Open

fix: don't obfuscate CommonJS/ESM file extension errors #103

sheerlox opened this issue Feb 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@sheerlox
Copy link
Owner

When an import throws an invalid module type for the file extension as follows:

This file is being treated as an ES module because it has a '.js' file extension and '/home/sherlox/workspace/OPENSOURCE/IMPORT_FROM/import-from-esm-repro-1/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

the error is caught by import-from-esm, which then throws the generic Cannot find module error message.

import-from-esm should not obfuscate this message, so the end user can understand the real cause of the issue.

Currently, the only way to see this error is by using DEBUG=import-from-esm.

Steps to reproduce:

npm install
cd playground/
npm install
npx semantic-release

Reproduction repo

@sheerlox sheerlox added the enhancement New feature or request label Feb 15, 2024
@sheerlox sheerlox changed the title import-from-esm abstracts CommonJS/ESM file extension errors Don't abstract CommonJS/ESM file extension errors Dec 30, 2024
@sheerlox sheerlox changed the title Don't abstract CommonJS/ESM file extension errors fix: don't abstract CommonJS/ESM file extension errors Dec 30, 2024
@sheerlox sheerlox added bug Something isn't working and removed enhancement New feature or request labels Dec 30, 2024
@sheerlox sheerlox changed the title fix: don't abstract CommonJS/ESM file extension errors fix: don't obfuscate CommonJS/ESM file extension errors Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant