standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.26k stars 147 forks source link

Where is the documentation? #888

Open Neutrino-Sunset opened 3 years ago

Neutrino-Sunset commented 3 years ago

The readme.md file states "100% interoperability with CJS". How?

How do I import an ES module into a CJS module? The readme says check this release post for details, but there are no details there of how to use it, just a load of talk about how amazing it is.

Neutrino-Sunset commented 3 years ago

I managed to run a Jasmine test that imports an ES module by defining the test in a file named test.spec.cjs and importing the ES module into the test using the syntax

const esmImport = require('esm')(module);
const { HelloWorld } = esmImport('./module1');

This works, but the

"helpers": [
  "node_modules/esm"
]

In jasmine.json appears to have no effect whatsoever as it works with or without it.

I wish people would document how stuff is intended to be used!