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

Support default export and UMD #301

Merged
merged 1 commit into from Mar 27, 2023

Conversation

remcohaszing
Copy link
Contributor

It’s possible to support both a CJS export and a .default property by defining the export as an interface that has a call expression and a default property. This makes it possible to use import classNames from 'classnames' or classNames.default('').

Also this packages exposes a UMD module, meaning classNames is available as a global when using a TypeScript script, but not when using a TypeScript module. This is supported by adding export as namespace classNames.

Technically this also declares it’s valid to use classNames.default when using classNames as a global. It may be better to move the line classNames.default = classNames outside of the if-statement at runtime.

It’s possible to support both a CJS export and a `.default` property by
defining the export as an interface that has a call expression and a
default property. This makes it possible to use
`import classNames from 'classnames'` or `classNames.default('')`.

Also this packages exposes a UMD module, meaning `classNames` is
available as a global when using a TypeScript script, but not when using
a TypeScript module. This is supported by adding
`export as namespace classNames`.
@dcousens
Copy link
Collaborator

dcousens commented Mar 27, 2023

Thanks @remcohaszing 💙

@dcousens dcousens merged commit d52250f into JedWatson:main Mar 27, 2023
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