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

Reduce ambiguity in *.js file extension in addon-root files by explicitly mentioning cjs or mjs #103

Merged
merged 2 commits into from
Jan 31, 2023

Conversation

NullVoxPopuli
Copy link
Collaborator

@NullVoxPopuli NullVoxPopuli commented Jan 19, 2023

This is partially w/r/t to linters being able to correctly match based on package.json settings, but partially because we currently rely on type to not be set at all in package.json, which implies that .js is common-js, but that's not always true.

For tooling sanity, this PR makes the cjs files .cjs, and the rollup file .mjs

This work came out of CrowdStrike/ember-toucan-core#9
Which, I'd normally say it isn't fair to change things just because of one person's lint configs, but the ambiguity in v2 addons right now is def troublesome

Copy link
Collaborator

@simonihmig simonihmig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

we currently rely on type to not be set at all in package.json

should we change that?

@@ -1,4 +1,4 @@
<% if (typescript) { %>import typescript from 'rollup-plugin-ts';<% } else { %>import babel from '@rollup/plugin-babel';<% } %>
<% if (typescript) { %>import typescript from 'rollup-plugin-ts';<% } else { %>import { babel } from '@rollup/plugin-babel';<% } %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this a real bug, or why this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even though the package exports both default and named babel, some tooling requires the named export.

I forget now, but I'd rather go with what's stable for all environments, than using default "just cause".
I should really have written this down when I encountered it :(

@NullVoxPopuli
Copy link
Collaborator Author

should we change that?

I don't think we can -- something to do with ember-auto-import, I think?
I forget why, but maybe @ef4 can expand on the not-specifying type: module in package.json -- I want to create some "fixers" (e.g.: here and here) soon because the amount of details that go wrong in a package.json before publishing are many, but I want to also explain, and I don't have an explanation for this one.

@ef4 ef4 merged commit 47b36d1 into main Jan 31, 2023
@ef4 ef4 deleted the consistent-cjs branch January 31, 2023 17:10
@ef4
Copy link
Contributor

ef4 commented Jan 31, 2023

We think type:module support might already be working now due to embroider-build/ember-auto-import#544

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

Successfully merging this pull request may close these issues.

3 participants