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

Emit error for files with invalid formats #95

Open
benmccann opened this issue May 3, 2024 · 2 comments
Open

Emit error for files with invalid formats #95

benmccann opened this issue May 3, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@benmccann
Copy link
Contributor

https://publint.dev/@growthbook/[email protected]

./dist/esm/index.js is written in ESM, but is interpreted as CJS. Consider using the .mjs extension, e.g. ./dist/esm/index.mjs (More info) - this is breaking the library for users in SvelteKit/Vites, so it would be nice to see if be an error

Also, the one about "types" needing to come first in exports to satisfy TypeScript. I've never actually seen that break an app, so I wonder if it should be a warning?

@bluwy
Copy link
Member

bluwy commented May 5, 2024

Escalating the written in ESM... message as an error makes sense to me. Initially I have it as a warning because the library may not be meant for normal nodejs usage, but I think it's rare these days and is always worth aligning the node default. Might be safer to only change this in the next minor.

I think the types message still makes sense as an error. Because it implies an intention for types to work, but it'll never work in practice. Warnings are reserved for things that still may work in certain environments.

@bluwy bluwy added the enhancement New feature or request label May 5, 2024
@bluwy
Copy link
Member

bluwy commented Jan 6, 2025

I've been thinking of implementing this in the next breaking minor, but I'd feel more comfortable landing this once #19 is resolved. If we emit an error for a browser-only library, there's not much they can do other than adding "type": "module" or use .mjs (or the other way round for CJS). And both choice isn't really necessary for a browser-only library to make.

If we can safely infer the environment it's meant for, this should emit an error for Node.js and not emit anything for browser. (Plus we can detect usage of CJS for browsers which would be the bigger culprit). So I think I'll punt this off for later for now.

@bluwy bluwy changed the title Upgrade warning to error Emit error for files with invalid formats Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants