question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

es module version

See original GitHub issue

As the browser world finally is united under the “es module” flag it would be nice if chai would offer an es module version.

this would enable test files like this “natively” in the browser

import { expect } from 'chai';

// even for plugins that would be really nice
// import { myPlugin } from 'my-chai-plugin';
// chai.use(myPlugin);

describe('True Checking', () => {
  it('is false by default', () => {
    expect(false).to.be.false;
  });
});

For direct use in script tags we could still have an umd module. (could be use on node as well?) Webpack and other bundling tools usually understand es modules directly.

There are 2 possible ways:

  • provide/build an es module version
  • convert the code to es module and provide/build an umd module.

if there is any interest I could provide an MR.

PS: this also means that all dependencies need to offer an es module version. Luckily all of them are also owned by chai itself. PPS: Overview http://npm.anvaka.com/#/view/2d/chai

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
daKmoRcommented, Aug 5, 2019

a humble request to ask if there are any updates? 🤗

0reactions
machineghostcommented, Mar 21, 2021

So … basically you claimed back at the start of 2019 that Chai would support modern JS (“very soon”). It’s now March of 2021 … maybe it’s time to admit you’re not going to support modern JS? Or at least provide some kind of status update?

P.S. For anyone looking for a solution instead of empty promises, see: https://github.com/bundled-es-modules/chai

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using ES modules in Node.js - LogRocket Blog
js module system or applying ES modules in their Node projects today. What are ES modules? With the release of Node version 15.3.0...
Read more >
ECMAScript modules | Node.js v19.3.0 Documentation
ECMAScript modules are the official standard format to package JavaScript code for reuse. Modules are defined using a variety of import and export...
Read more >
ES modules: A cartoon deep-dive - Mozilla Hacks - the Web ...
ES modules bring an official, standardized module system to JavaScript. With the release of Firefox 60 in May, all major browsers will ...
Read more >
How to use ES Modules with Node.js - DEV Community ‍ ‍
Since version 8.9.0 you could start to use ES Modules by adding the ... to Node that you are going to use a...
Read more >
How to Use ECMAScript Modules in Node.js
Starting version 13.2.0, Node.js has stable support of ES modules. ... The following ES module month-from-date.mjs (note the .mjs file ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found