The build for _esm5 is pointed in the module of the package.json which corresponds to the native ESM modules loaders. However, the build doesn't produce the modules and almost not distinguishable from CJS.
This PR removes _esm5 altogether and instead uses the _esm2015 build. This build does produce correct ESM modules and has to be references in module entry point.
For only one reason to merge Lens namespace in lens/base.ts and lens/json.ts the library had side-effects listed in package.json. However, it always does this and no point of this artificial separation.
Now these namespace are moved to separate files (lens.ts, prism.ts, optic.ts) that don;t have namespaces and instead export all of their functions as plain names exports.
then to keep namaspacy-look in public API, they are re-exported as export * as so that they can still be accessed as Lens.blahblah.
Note, that no function code was actually changed, only re-arranged.
@oleksiilevzhynskyi I was thinking to add export map (export in package.json) to allow direct imports like import { key } from '@grammarly/focal-atom/lens'. What do you think?
1. Deprecated
_esm5
buildThe build for
_esm5
is pointed in themodule
of thepackage.json
which corresponds to the native ESM modules loaders. However, the build doesn't produce the modules and almost not distinguishable from CJS.This PR removes
_esm5
altogether and instead uses the_esm2015
build. This build does produce correct ESM modules and has to be references inmodule
entry point.Also, need to point that
es2015
entry point inpackage.json
is non-standard and is not used anywhere (ref: https://stackoverflow.com/questions/43131060/npm-package-json-undocumented-keys)2.
Lens
,Prism
,Optic
namespaces are now modulesFor only one reason to merge
Lens
namespace inlens/base.ts
andlens/json.ts
the library had side-effects listed inpackage.json
. However, it always does this and no point of this artificial separation.Now these namespace are moved to separate files (
lens.ts
,prism.ts
,optic.ts
) that don;t have namespaces and instead export all of their functions as plain names exports.then to keep namaspacy-look in public API, they are re-exported as
export * as
so that they can still be accessed asLens.blahblah
.Note, that no function code was actually changed, only re-arranged.