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

4.0.0 publishing is broken #139

Closed
mfedderly opened this issue Aug 21, 2024 · 6 comments
Closed

4.0.0 publishing is broken #139

mfedderly opened this issue Aug 21, 2024 · 6 comments
Labels

Comments

@mfedderly
Copy link

Via https://publint.dev/rbush@4.0.0

When changing the package.json to "type": "module" all .js files will be interpreted as ESM, but rbush.js is still CJS. That leads to an issue where certain module resolution setups will result in issues, trying to interpret rbush.js as ESM. I believe this would be resolved by simply changing the filename to rbush.cjs instead.

This came up when I was trying to update the types to support 4.0.0 here: DefinitelyTyped/DefinitelyTyped#70340

@mourner
Copy link
Owner

mourner commented Aug 21, 2024

I don't think it should be broken because according to the ESM docs, the exports field (which points to ESM entry point) supersedes the main field. However, I should probably have it pointed to the same entry point just in case some external tools like TS interpret this incorrectly.

@mourner mourner added the bug label Aug 21, 2024
@mfedderly
Copy link
Author

I think older resolvers (Typescript in node10 mode) will still use main, unfortunately. That's what made the typings hard to make correct in DefinitelyTyped.

@mourner
Copy link
Owner

mourner commented Aug 21, 2024

Should be fixed in 4.0.1.

@jakebailey
Copy link

I'm not sure that is the right fix... The old state was that exports always pointed to index.js, so ESM could import and CJS could dynamic import, with old non-type=module expecting things still being able to load from the main entrypoint (sort of unexpected). But now, both point to index.js, so they'll all fail.

rbush.js is what contains the CJS code (technically UMD), but by Node rules, that file will never acutally work due to its extension + type=module implying that it's ESM.

Is the intent that rbush.js must exist for back compat? Such that not using ESM in .js would be a better solution, and this can be written?

"exports": {
    ".": {
        "import": "./index.mjs",
        "require": "./rbush.js"
    }
}

Maybe?

@mourner
Copy link
Owner

mourner commented Aug 22, 2024

@jakebailey no, my intent is not to support CommonJS at all. UMD rbush.js is there for the old <script>-based CDN use for the browsers, not for Node, which supports ESM on all maintained versions since a long time ago.

@jakebailey
Copy link

Ah, then you don't need to publish with the "main" field at all.

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

No branches or pull requests

3 participants