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

Modernize the package (esm, tree-shaking) #94

Merged
merged 2 commits into from
Oct 16, 2023
Merged

Conversation

Igorbek
Copy link
Contributor

@Igorbek Igorbek commented Oct 16, 2023

1. Deprecated _esm5 build

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.

Also, need to point that es2015 entry point in package.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 modules

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.

- reorganize Lens, Prism, Optic namespaces into separate modules
- the public API is the same
@Igorbek
Copy link
Contributor Author

Igorbek commented Oct 16, 2023

@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?

@A-gambit A-gambit merged commit d2c617d into grammarly:master Oct 16, 2023
1 check passed
@Igorbek Igorbek deleted the f-esm branch October 16, 2023 21:52
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