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

chore: drop commonjs support #1503

Merged
merged 1 commit into from Feb 15, 2023
Merged

chore: drop commonjs support #1503

merged 1 commit into from Feb 15, 2023

Conversation

43081j
Copy link
Contributor

@43081j 43081j commented Feb 14, 2023

@keithamus this is what we talked about before - removing the commonjs bundle.

i wasn't too sure about removing the exports so a second opinion would be great.

my thinking was that we have no conditional exports anymore, just the one entrypoint (chai.js). someone could try import the source files and they'd probably work ok in node (since it'd handle cjs dependencies). but really everyone should use the main entrypoint.

@43081j 43081j requested a review from a team as a code owner February 14, 2023 18:15
Copy link
Member

@keithamus keithamus left a comment

Choose a reason for hiding this comment

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

Yep this LGTM.

Here's what I'd like to see as an eventuality:

  • ./src/ houses a set of TypeScript files.
  • ./mod.ts imports all the TypeScript files - this is what Deno users will use.
  • ./lib/ is like ./src/ but with TS types compiled out.
  • ./index.js is like ./mod.ts but imports from ./lib/ not ./src/ - this is what Node users will use.
  • ./chai.js is an ESM bundle that's a single file that can be dropped into a <script> tag in the browser.

@keithamus keithamus merged commit ad82f62 into chaijs:5.x.x Feb 15, 2023
3 checks passed
@keithamus
Copy link
Member

@43081j please check your emails/notifications for an invite to the chai team where you can collect your maintainer badge 😄

@43081j 43081j deleted the drop-cjs branch February 15, 2023 09:12
@43081j
Copy link
Contributor Author

43081j commented Feb 15, 2023

Yep this LGTM.

Here's what I'd like to see as an eventuality:

  • ./src/ houses a set of TypeScript files.
  • ./mod.ts imports all the TypeScript files - this is what Deno users will use.
  • ./lib/ is like ./src/ but with TS types compiled out.
  • ./index.js is like ./mod.ts but imports from ./lib/ not ./src/ - this is what Node users will use.
  • ./chai.js is an ESM bundle that's a single file that can be dropped into a <script> tag in the browser.

i agree.

one thing we should consider too is what to use for a test runner going forward.

right now, karma works still because we create a bundle. however, if we try use the source JS (which is perfectly valid now in node), the bare specifiers in imports will cause it to fall over since we don't have an import map specified.

so either we'd need some karma plugin which understands import maps, or we use a test runner like web-test-runner which transforms the imports for you behind the scenes (other similar test runners do the same).

i've opened #1504 for that

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.

None yet

2 participants