Closed dy closed 4 years ago
Actually nvm, ES modules support in node seems to be still not reliable enough.
Actually, considering https://github.com/matthewp/haunted/issues/158, maybe you'd also like to provide commonjs support @UpperCod?
Good idea, it will be available in the next update 0.16.0, I will comment again when it is available
Atomico assumes the system of modules stable and recommended for web-oriented projects. indifferent to the state of this in node.js, since the Atomico target is the browser.
The use of cjs as a module will not be included in the package declaration, but if it exists in the cjs
folder of the package, this to support environments based on cjs
, but this requires the user to declare atomico/cjs/[module]
, eg:
import { useState } from "atomico/cjs/core";
I hope you find it useful
Oh, that's nice. Since you provide commonjs exports, it would be enough to add "exports"
to package.json
as
{
...
"exports": {
"require": "./cjs/core.js",
"default": "./core.js"
}
...
}
Ready added in version 0.16, https://github.com/atomicojs/atomico/blob/master/package.json#L68-L71, thanks for the recommendation
Optional module detection is only possible via
require
mechanism: https://stackoverflow.com/questions/33987742/optional-imports-in-es2015-node-js That is used by any-hooks and unihooks. The problem is that with ES modules support in node https://nodejs.org/api/esm.html, the atomico exports nothing, being imported ascommonjs
:That makes it impossible to test/run in nodejs.
That would be useful to provide a separate commonjs entry, eg as showed here.